From 6e99bbc0f70d0e76746bedfef3652ca0884ebe29 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 31 Mar 2016 11:46:20 +0100 Subject: [PATCH] Simplify update of dynamic dns --- src/freedombone | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/src/freedombone b/src/freedombone index 3becce2a..7ec7670d 100755 --- a/src/freedombone +++ b/src/freedombone @@ -114,7 +114,6 @@ IMAGE_PASSWORD_FILE=/root/login.txt DDNS_PROVIDER="default@freedns.afraid.org" DDNS_USERNAME= DDNS_PASSWORD= -CURRENT_DDNS_DOMAIN= EXIM_ONION_REPO="https://github.com/petterreinholdtsen/exim4-smtorp" @@ -6126,13 +6125,14 @@ function repair_databases_script { } function add_ddns_domain { - if [[ $ONION_ONLY != "no" ]]; then - return - fi - if [ ! $CURRENT_DDNS_DOMAIN ]; then + if [ ! $1 ]; then echo $'ddns domain not specified' exit 5638 fi + CURRENT_DDNS_DOMAIN="$1" + if [[ $ONION_ONLY != "no" ]]; then + return + fi if [ ! -f /etc/inadyn.conf ]; then echo $'Unable to find inadyn configuration file /etc/inadyn.conf' exit 5745 @@ -6156,9 +6156,6 @@ function add_ddns_domain { chmod 600 /etc/inadyn.conf systemctl restart inadyn systemctl daemon-reload - - # clear the arguments - CURRENT_DDNS_DOMAIN= } function upgrade_owncloud_start { @@ -6514,9 +6511,7 @@ function install_owncloud_official_deb { echo "Owncloud onion domain:${OWNCLOUD_ONION_HOSTNAME}" >> $COMPLETION_FILE fi - # update the dynamic DNS - CURRENT_DDNS_DOMAIN=$OWNCLOUD_DOMAIN_NAME - add_ddns_domain + add_ddns_domain $OWNCLOUD_DOMAIN_NAME if ! grep -q "Owncloud domain" $COMPLETION_FILE; then echo "Owncloud domain:$OWNCLOUD_DOMAIN_NAME" >> $COMPLETION_FILE @@ -6865,9 +6860,7 @@ function install_gogs { echo "Gogs onion domain:${GIT_ONION_HOSTNAME}" >> $COMPLETION_FILE fi - # update the dynamic DNS - CURRENT_DDNS_DOMAIN=$GIT_DOMAIN_NAME - add_ddns_domain + add_ddns_domain $GIT_DOMAIN_NAME echo "Gogs domain:$GIT_DOMAIN_NAME" >> $COMPLETION_FILE echo 'install_gogs' >> $COMPLETION_FILE @@ -7756,9 +7749,7 @@ function install_wiki { echo "Wiki onion domain:${WIKI_ONION_HOSTNAME}" >> $COMPLETION_FILE - # update the dynamic DNS - CURRENT_DDNS_DOMAIN=$WIKI_DOMAIN_NAME - add_ddns_domain + add_ddns_domain $WIKI_DOMAIN_NAME # add some post-install instructions if ! grep -q $"Wiki password" /home/$MY_USERNAME/README; then @@ -8130,9 +8121,7 @@ function install_blog { fi echo "Blog onion domain:${FULLBLOG_ONION_HOSTNAME}" >> $COMPLETION_FILE - # update the dynamic DNS - CURRENT_DDNS_DOMAIN=$FULLBLOG_DOMAIN_NAME - add_ddns_domain + add_ddns_domain $FULLBLOG_DOMAIN_NAME echo 'install_blog' >> $COMPLETION_FILE } @@ -8556,9 +8545,7 @@ function install_gnu_social { fi newaliases - # update the dynamic DNS - CURRENT_DDNS_DOMAIN=$MICROBLOG_DOMAIN_NAME - add_ddns_domain + add_ddns_domain $MICROBLOG_DOMAIN_NAME microblog_nginx_site=/etc/nginx/sites-available/$MICROBLOG_DOMAIN_NAME if [[ $ONION_ONLY == "no" ]]; then @@ -9242,9 +9229,7 @@ function install_hubzilla { echo "12,22,32,42,52 * * * * root cd $HUBZILLA_PATH; /usr/bin/timeout 500 /usr/bin/php include/poller.php" >> /etc/crontab fi - # update the dynamic DNS - CURRENT_DDNS_DOMAIN=$HUBZILLA_DOMAIN_NAME - add_ddns_domain + add_ddns_domain $HUBZILLA_DOMAIN_NAME if [[ $ONION_ONLY == "no" ]]; then nginx_http_redirect $HUBZILLA_DOMAIN_NAME @@ -9818,9 +9803,7 @@ function install_mediagoblin { systemctl restart php5-fpm systemctl restart nginx - # update the dynamic DNS - CURRENT_DDNS_DOMAIN=$MEDIAGOBLIN_DOMAIN_NAME - add_ddns_domain + add_ddns_domain $MEDIAGOBLIN_DOMAIN_NAME echo 'install_mediagoblin' >> $COMPLETION_FILE }