Browse Source

Simplify update of dynamic dns

Bob Mottram 9 years ago
parent
commit
6e99bbc0f7
1 changed files with 12 additions and 29 deletions
  1. 12
    29
      src/freedombone

+ 12
- 29
src/freedombone View File

114
 DDNS_PROVIDER="default@freedns.afraid.org"
114
 DDNS_PROVIDER="default@freedns.afraid.org"
115
 DDNS_USERNAME=
115
 DDNS_USERNAME=
116
 DDNS_PASSWORD=
116
 DDNS_PASSWORD=
117
-CURRENT_DDNS_DOMAIN=
118
 
117
 
119
 EXIM_ONION_REPO="https://github.com/petterreinholdtsen/exim4-smtorp"
118
 EXIM_ONION_REPO="https://github.com/petterreinholdtsen/exim4-smtorp"
120
 
119
 
6126
 }
6125
 }
6127
 
6126
 
6128
 function add_ddns_domain {
6127
 function add_ddns_domain {
6129
-    if [[ $ONION_ONLY != "no" ]]; then
6130
-        return
6131
-    fi
6132
-    if [ ! $CURRENT_DDNS_DOMAIN ]; then
6128
+    if [ ! $1 ]; then
6133
         echo $'ddns domain not specified'
6129
         echo $'ddns domain not specified'
6134
         exit 5638
6130
         exit 5638
6135
     fi
6131
     fi
6132
+    CURRENT_DDNS_DOMAIN="$1"
6133
+    if [[ $ONION_ONLY != "no" ]]; then
6134
+        return
6135
+    fi
6136
     if [ ! -f /etc/inadyn.conf ]; then
6136
     if [ ! -f /etc/inadyn.conf ]; then
6137
         echo $'Unable to find inadyn configuration file /etc/inadyn.conf'
6137
         echo $'Unable to find inadyn configuration file /etc/inadyn.conf'
6138
         exit 5745
6138
         exit 5745
6156
     chmod 600 /etc/inadyn.conf
6156
     chmod 600 /etc/inadyn.conf
6157
     systemctl restart inadyn
6157
     systemctl restart inadyn
6158
     systemctl daemon-reload
6158
     systemctl daemon-reload
6159
-
6160
-    # clear the arguments
6161
-    CURRENT_DDNS_DOMAIN=
6162
 }
6159
 }
6163
 
6160
 
6164
 function upgrade_owncloud_start {
6161
 function upgrade_owncloud_start {
6514
         echo "Owncloud onion domain:${OWNCLOUD_ONION_HOSTNAME}" >> $COMPLETION_FILE
6511
         echo "Owncloud onion domain:${OWNCLOUD_ONION_HOSTNAME}" >> $COMPLETION_FILE
6515
     fi
6512
     fi
6516
 
6513
 
6517
-    # update the dynamic DNS
6518
-    CURRENT_DDNS_DOMAIN=$OWNCLOUD_DOMAIN_NAME
6519
-    add_ddns_domain
6514
+    add_ddns_domain $OWNCLOUD_DOMAIN_NAME
6520
 
6515
 
6521
     if ! grep -q "Owncloud domain" $COMPLETION_FILE; then
6516
     if ! grep -q "Owncloud domain" $COMPLETION_FILE; then
6522
         echo "Owncloud domain:$OWNCLOUD_DOMAIN_NAME" >> $COMPLETION_FILE
6517
         echo "Owncloud domain:$OWNCLOUD_DOMAIN_NAME" >> $COMPLETION_FILE
6865
         echo "Gogs onion domain:${GIT_ONION_HOSTNAME}" >> $COMPLETION_FILE
6860
         echo "Gogs onion domain:${GIT_ONION_HOSTNAME}" >> $COMPLETION_FILE
6866
     fi
6861
     fi
6867
 
6862
 
6868
-    # update the dynamic DNS
6869
-    CURRENT_DDNS_DOMAIN=$GIT_DOMAIN_NAME
6870
-    add_ddns_domain
6863
+    add_ddns_domain $GIT_DOMAIN_NAME
6871
 
6864
 
6872
     echo "Gogs domain:$GIT_DOMAIN_NAME" >> $COMPLETION_FILE
6865
     echo "Gogs domain:$GIT_DOMAIN_NAME" >> $COMPLETION_FILE
6873
     echo 'install_gogs' >> $COMPLETION_FILE
6866
     echo 'install_gogs' >> $COMPLETION_FILE
7756
 
7749
 
7757
     echo "Wiki onion domain:${WIKI_ONION_HOSTNAME}" >> $COMPLETION_FILE
7750
     echo "Wiki onion domain:${WIKI_ONION_HOSTNAME}" >> $COMPLETION_FILE
7758
 
7751
 
7759
-    # update the dynamic DNS
7760
-    CURRENT_DDNS_DOMAIN=$WIKI_DOMAIN_NAME
7761
-    add_ddns_domain
7752
+    add_ddns_domain $WIKI_DOMAIN_NAME
7762
 
7753
 
7763
     # add some post-install instructions
7754
     # add some post-install instructions
7764
     if ! grep -q $"Wiki password" /home/$MY_USERNAME/README; then
7755
     if ! grep -q $"Wiki password" /home/$MY_USERNAME/README; then
8130
     fi
8121
     fi
8131
     echo "Blog onion domain:${FULLBLOG_ONION_HOSTNAME}" >> $COMPLETION_FILE
8122
     echo "Blog onion domain:${FULLBLOG_ONION_HOSTNAME}" >> $COMPLETION_FILE
8132
 
8123
 
8133
-    # update the dynamic DNS
8134
-    CURRENT_DDNS_DOMAIN=$FULLBLOG_DOMAIN_NAME
8135
-    add_ddns_domain
8124
+    add_ddns_domain $FULLBLOG_DOMAIN_NAME
8136
 
8125
 
8137
     echo 'install_blog' >> $COMPLETION_FILE
8126
     echo 'install_blog' >> $COMPLETION_FILE
8138
 }
8127
 }
8556
     fi
8545
     fi
8557
     newaliases
8546
     newaliases
8558
 
8547
 
8559
-    # update the dynamic DNS
8560
-    CURRENT_DDNS_DOMAIN=$MICROBLOG_DOMAIN_NAME
8561
-    add_ddns_domain
8548
+    add_ddns_domain $MICROBLOG_DOMAIN_NAME
8562
 
8549
 
8563
     microblog_nginx_site=/etc/nginx/sites-available/$MICROBLOG_DOMAIN_NAME
8550
     microblog_nginx_site=/etc/nginx/sites-available/$MICROBLOG_DOMAIN_NAME
8564
     if [[ $ONION_ONLY == "no" ]]; then
8551
     if [[ $ONION_ONLY == "no" ]]; then
9242
         echo "12,22,32,42,52 * *   *   *   root cd $HUBZILLA_PATH; /usr/bin/timeout 500 /usr/bin/php include/poller.php" >> /etc/crontab
9229
         echo "12,22,32,42,52 * *   *   *   root cd $HUBZILLA_PATH; /usr/bin/timeout 500 /usr/bin/php include/poller.php" >> /etc/crontab
9243
     fi
9230
     fi
9244
 
9231
 
9245
-    # update the dynamic DNS
9246
-    CURRENT_DDNS_DOMAIN=$HUBZILLA_DOMAIN_NAME
9247
-    add_ddns_domain
9232
+    add_ddns_domain $HUBZILLA_DOMAIN_NAME
9248
 
9233
 
9249
     if [[ $ONION_ONLY == "no" ]]; then
9234
     if [[ $ONION_ONLY == "no" ]]; then
9250
         nginx_http_redirect $HUBZILLA_DOMAIN_NAME
9235
         nginx_http_redirect $HUBZILLA_DOMAIN_NAME
9818
     systemctl restart php5-fpm
9803
     systemctl restart php5-fpm
9819
     systemctl restart nginx
9804
     systemctl restart nginx
9820
 
9805
 
9821
-    # update the dynamic DNS
9822
-    CURRENT_DDNS_DOMAIN=$MEDIAGOBLIN_DOMAIN_NAME
9823
-    add_ddns_domain
9806
+    add_ddns_domain $MEDIAGOBLIN_DOMAIN_NAME
9824
 
9807
 
9825
     echo 'install_mediagoblin' >> $COMPLETION_FILE
9808
     echo 'install_mediagoblin' >> $COMPLETION_FILE
9826
 }
9809
 }