From bbcc17f2d1bdaaf6827fb1c3bfb1e28e19f8f059 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 5 Aug 2017 21:16:37 +0100 Subject: [PATCH] Only copy files which have changed --- src/freedombone-base-email | 20 ++++++++++++++++++-- src/freedombone-utils-firewall | 7 +++++-- src/freedombone-utils-git | 24 +++++++++++++++++++++--- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/freedombone-base-email b/src/freedombone-base-email index 22bf49cf..68f75862 100755 --- a/src/freedombone-base-email +++ b/src/freedombone-base-email @@ -326,9 +326,25 @@ function encrypt_all_email { fi if [ -f /usr/local/bin/${PROJECT_NAME}-encrypt-mail ]; then - cp -u /usr/local/bin/${PROJECT_NAME}-encrypt-mail /usr/bin/encmaildir + if [ ! -f /usr/bin/encmaildir ]; then + cp /usr/local/bin/${PROJECT_NAME}-encrypt-mail /usr/bin/encmaildir + else + HASH1=$(sha256sum /usr/local/bin/${PROJECT_NAME}-encrypt-mail | awk -F ' ' '{print $1}') + HASH2=$(sha256sum /usr/bin/encmaildir | awk -F ' ' '{print $1}') + if [[ "$HASH1" != "$HASH2" ]]; then + cp /usr/local/bin/${PROJECT_NAME}-encrypt-mail /usr/bin/encmaildir + fi + fi else - cp -u /usr/bin/${PROJECT_NAME}-encrypt-mail /usr/bin/encmaildir + if [ ! -f /usr/bin/encmaildir ]; then + cp /usr/bin/${PROJECT_NAME}-encrypt-mail /usr/bin/encmaildir + else + HASH1=$(sha256sum /usr/bin/${PROJECT_NAME}-encrypt-mail | awk -F ' ' '{print $1}') + HASH2=$(sha256sum /usr/bin/encmaildir | awk -F ' ' '{print $1}') + if [[ "$HASH1" != "$HASH2" ]]; then + cp /usr/bin/${PROJECT_NAME}-encrypt-mail /usr/bin/encmaildir + fi + fi fi if [[ $(is_completed $FUNCNAME) == "1" ]]; then diff --git a/src/freedombone-utils-firewall b/src/freedombone-utils-firewall index 0c646f34..d82306ac 100755 --- a/src/freedombone-utils-firewall +++ b/src/freedombone-utils-firewall @@ -90,10 +90,13 @@ function firewall_block_bad_ip_ranges { function global_rate_limit { if ! grep -q "tcp_challenge_ack_limit" /etc/sysctl.conf; then echo 'net.ipv4.tcp_challenge_ack_limit = 999999999' >> /etc/sysctl.conf + sysctl -p -q else - sed -i 's|net.ipv4.tcp_challenge_ack_limit.*|net.ipv4.tcp_challenge_ack_limit = 999999999|g' /etc/sysctl.conf + if ! grep -q "net.ipv4.tcp_challenge_ack_limit = 999999999" /etc/sysctl.conf; then + sed -i 's|net.ipv4.tcp_challenge_ack_limit.*|net.ipv4.tcp_challenge_ack_limit = 999999999|g' /etc/sysctl.conf + sysctl -p -q + fi fi - sysctl -p -q } function enable_ipv6 { diff --git a/src/freedombone-utils-git b/src/freedombone-utils-git index 883be12d..34a8b1d8 100755 --- a/src/freedombone-utils-git +++ b/src/freedombone-utils-git @@ -95,13 +95,31 @@ function set_repo_commit { chown -R www-data:www-data $repo_dir fi if [[ $repo_dir == *"gpgit" ]]; then - cp -u gpgit.pl /usr/bin/gpgit.pl + if [ ! -f /usr/bin/gpgit.pl ]; then + cp gpgit.pl /usr/bin/gpgit.pl + else + HASH1=$(sha256sum gpgit.pl | awk -F ' ' '{print $1}') + HASH2=$(sha256sum /usr/bin/gpgit.pl | awk -F ' ' '{print $1}') + if [[ "$HASH1" != "$HASH2" ]]; then + cp gpgit.pl /usr/bin/gpgit.pl + fi + fi fi if [[ $repo_dir == *"cleanup-maildir" ]]; then - cp -u $INSTALL_DIR/cleanup-maildir/cleanup-maildir /usr/bin + if [ ! -f /usr/bin/cleanup-maildir ]; then + cp $INSTALL_DIR/cleanup-maildir/cleanup-maildir /usr/bin + else + HASH1=$(sha256sum $INSTALL_DIR/cleanup-maildir/cleanup-maildir | awk -F ' ' '{print $1}') + HASH2=$(sha256sum /usr/bin/cleanup-maildir | awk -F ' ' '{print $1}') + if [[ "$HASH1" != "$HASH2" ]]; then + cp $INSTALL_DIR/cleanup-maildir/cleanup-maildir /usr/bin + fi + fi fi if [[ $repo_dir == *"nginx_ensite" ]]; then - make install + if [ ! -f /usr/local/bin/nginx_ensite ]; then + make install + fi fi if [[ $repo_dir == *"inadyn" ]]; then ./configure