Bob Mottram 8 years ago
parent
commit
607d4bdc95
61 changed files with 829 additions and 864 deletions
  1. 5
    1
      src/freedombone-addcert
  2. 2
    2
      src/freedombone-app-batman
  3. 6
    6
      src/freedombone-app-dlna
  4. 5
    7
      src/freedombone-app-dokuwiki
  5. 16
    43
      src/freedombone-app-gnusocial
  6. 2
    2
      src/freedombone-app-gogs
  7. 266
    274
      src/freedombone-app-htmly
  8. 5
    13
      src/freedombone-app-hubzilla
  9. 8
    12
      src/freedombone-app-ipfs
  10. 4
    12
      src/freedombone-app-librevault
  11. 2
    10
      src/freedombone-app-mediagoblin
  12. 2
    2
      src/freedombone-app-mumble
  13. 4
    10
      src/freedombone-app-rss
  14. 4
    10
      src/freedombone-app-searx
  15. 4
    4
      src/freedombone-app-sip
  16. 2
    2
      src/freedombone-app-syncthing
  17. 2
    2
      src/freedombone-app-tahoelafs
  18. 4
    6
      src/freedombone-app-tox
  19. 1
    5
      src/freedombone-app-webmail
  20. 3
    7
      src/freedombone-app-xmpp
  21. 5
    17
      src/freedombone-app-zeronet
  22. 1
    1
      src/freedombone-backup-remote
  23. 35
    47
      src/freedombone-base-email
  24. 2
    2
      src/freedombone-base-tripwire
  25. 1
    1
      src/freedombone-controlpanel
  26. 7
    1
      src/freedombone-encrypt-mail
  27. 2
    2
      src/freedombone-restore-local
  28. 6
    2
      src/freedombone-restore-remote
  29. 1
    1
      src/freedombone-rmuser
  30. 7
    7
      src/freedombone-syncthing
  31. 2
    2
      src/freedombone-utils-avahi
  32. 3
    3
      src/freedombone-utils-backup
  33. 2
    2
      src/freedombone-utils-cmake
  34. 85
    0
      src/freedombone-utils-config
  35. 32
    32
      src/freedombone-utils-cron
  36. 2
    2
      src/freedombone-utils-cryptopp
  37. 4
    4
      src/freedombone-utils-database
  38. 6
    6
      src/freedombone-utils-dns
  39. 3
    7
      src/freedombone-utils-filesystem
  40. 2
    2
      src/freedombone-utils-final
  41. 17
    17
      src/freedombone-utils-firewall
  42. 3
    6
      src/freedombone-utils-git
  43. 1
    1
      src/freedombone-utils-go
  44. 2
    2
      src/freedombone-utils-international
  45. 2
    2
      src/freedombone-utils-login
  46. 29
    29
      src/freedombone-utils-monkeysphere
  47. 42
    42
      src/freedombone-utils-network
  48. 2
    2
      src/freedombone-utils-nodejs
  49. 12
    22
      src/freedombone-utils-onion
  50. 2
    2
      src/freedombone-utils-passwords
  51. 6
    6
      src/freedombone-utils-repos
  52. 111
    111
      src/freedombone-utils-rng
  53. 3
    1
      src/freedombone-utils-selector
  54. 4
    6
      src/freedombone-utils-setup
  55. 6
    6
      src/freedombone-utils-ssh
  56. 2
    2
      src/freedombone-utils-tracker
  57. 4
    4
      src/freedombone-utils-upgrade
  58. 2
    2
      src/freedombone-utils-watchdog
  59. 9
    16
      src/freedombone-utils-web
  60. 6
    5
      src/freedombone-utils-wifi
  61. 9
    9
      src/freedombone-utils-zram

+ 5
- 1
src/freedombone-addcert View File

@@ -186,7 +186,11 @@ function add_cert_letsencrypt {
186 186
     if [ ! $MY_EMAIL_ADDRESS ]; then
187 187
         if [ -f $COMPLETION_FILE ]; then
188 188
             if grep -q "Admin user:" $COMPLETION_FILE; then
189
-                ADMIN_USER=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
189
+                function_check get_completion_param
190
+                ADMIN_USER=$(get_completion_param "Admin user")
191
+                if [ ${#ADMIN_USER} -eq 0 ]; then
192
+                    exit 463732
193
+                fi
190 194
                 MY_EMAIL_ADDRESS=$ADMIN_USER@$HOSTNAME
191 195
             fi
192 196
         fi

+ 2
- 2
src/freedombone-app-batman View File

@@ -46,7 +46,7 @@ function change_password_batman {
46 46
 }
47 47
 
48 48
 function configure_firewall_for_batman {
49
-    if grep -Fxq "configure_firewall_for_batman" $COMPLETION_FILE; then
49
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
50 50
         return
51 51
     fi
52 52
     if [[ $ENABLE_BATMAN != "yes" ]]; then
@@ -55,7 +55,7 @@ function configure_firewall_for_batman {
55 55
 
56 56
     function_check save_firewall_settings
57 57
     save_firewall_settings
58
-    echo 'configure_firewall_for_batman' >> $COMPLETION_FILE
58
+    mark_completed $FUNCNAME
59 59
 }
60 60
 
61 61
 function reconfigure_batman {

+ 6
- 6
src/freedombone-app-dlna View File

@@ -78,7 +78,7 @@ function upgrade_dlna {
78 78
 }
79 79
 
80 80
 function configure_firewall_for_dlna {
81
-    if grep -Fxq "configure_firewall_for_dlna" $COMPLETION_FILE; then
81
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
82 82
         return
83 83
     fi
84 84
     if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
@@ -92,7 +92,7 @@ function configure_firewall_for_dlna {
92 92
 
93 93
     OPEN_PORTS+=('DLNA     1900')
94 94
     OPEN_PORTS+=('DLNA     8200')
95
-    echo 'configure_firewall_for_dlna' >> $COMPLETION_FILE
95
+    mark_completed $FUNCNAME
96 96
 }
97 97
 
98 98
 function backup_local_dlna {
@@ -168,7 +168,7 @@ function remove_dlna {
168 168
 }
169 169
 
170 170
 function install_dlna_main {
171
-    if grep -Fxq "install_dlna_main" $COMPLETION_FILE; then
171
+    if [[ $(app_is_installed dlna_main) == "1" ]]; then
172 172
         return
173 173
     fi
174 174
 
@@ -217,11 +217,11 @@ function install_dlna_main {
217 217
 
218 218
     function_check configure_firewall_for_dlna
219 219
     configure_firewall_for_dlna
220
-    echo 'install_dlna_main' >> $COMPLETION_FILE
220
+    install_completed dlna_main
221 221
 }
222 222
 
223 223
 function script_for_attaching_usb_drive {
224
-    if grep -Fxq "script_for_attaching_usb_drive" $COMPLETION_FILE; then
224
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
225 225
         return
226 226
     fi
227 227
     echo '#!/bin/bash' > /usr/bin/attach-music
@@ -256,7 +256,7 @@ function script_for_attaching_usb_drive {
256 256
     ln -s /usr/bin/remove-music /usr/bin/detach-pictures
257 257
     ln -s /usr/bin/remove-music /usr/bin/remove-pictures
258 258
 
259
-    echo 'script_for_attaching_usb_drive' >> $COMPLETION_FILE
259
+    mark_completed $FUNCNAME
260 260
 }
261 261
 
262 262
 function install_dlna {

+ 5
- 7
src/freedombone-app-dokuwiki View File

@@ -85,7 +85,8 @@ function backup_local_dokuwiki {
85 85
 function restore_local_dokuwiki {
86 86
     if [ -d /var/lib/dokuwiki ]; then
87 87
         echo $"Restoring Dokuwiki installation"
88
-        DOKUWIKI_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "dokuwiki domain" | awk -F ':' '{print $2}')
88
+        function_check get_completion_param
89
+        DOKUWIKI_DOMAIN_NAME=$(get_completion_param "dokuwiki domain")
89 90
         temp_restore_dir=/root/tempdokuwiki
90 91
         function_check restore_directory_from_usb
91 92
         restore_directory_from_usb $temp_restore_dir dokuwiki
@@ -131,7 +132,8 @@ function backup_remote_dokuwiki {
131 132
 
132 133
 function restore_remote_dokuwiki {
133 134
     if [ -d $SERVER_DIRECTORY/backup/dokuwiki ]; then
134
-        DOKUWIKI_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "dokuwiki domain" | awk -F ':' '{print $2}')
135
+        function_check get_completion_param
136
+        DOKUWIKI_DOMAIN_NAME=$(get_completion_param "dokuwiki domain")
135 137
         echo $"Restoring Dokuwiki installation $DOKUWIKI_DOMAIN_NAME"
136 138
         function_check restore_directory_from_friend
137 139
         restore_directory_from_friend /root/tempdokuwiki dokuwiki
@@ -561,11 +563,7 @@ function install_dokuwiki {
561 563
         chmod 600 /home/$MY_USERNAME/README
562 564
     fi
563 565
 
564
-    if ! grep -q "dokuwiki domain" $COMPLETION_FILE; then
565
-        echo "dokuwiki domain:$DOKUWIKI_DOMAIN_NAME" >> $COMPLETION_FILE
566
-    else
567
-        sed -i "s|dokuwiki domain.*|dokuwiki domain:$DOKUWIKI_DOMAIN_NAME|g" $COMPLETION_FILE
568
-    fi
566
+    set_completion_param "dokuwiki domain" "$DOKUWIKI_DOMAIN_NAME"
569 567
     APP_INSTALLED=1
570 568
 }
571 569
 

+ 16
- 43
src/freedombone-app-gnusocial View File

@@ -74,7 +74,8 @@ gnusocial_variables=(GNUSOCIAL_COMMIT
74 74
 function remove_user_gnusocial {
75 75
     remove_username="$1"
76 76
 
77
-    GNUSOCIAL_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "gnusocial domain" | head -n 1 | awk -F ':' '{print $2}')
77
+    function_check get_completion_param
78
+    GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
78 79
     if [ -d /var/www/$GNUSOCIAL_DOMAIN_NAME ]; then
79 80
         cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
80 81
         php scripts/deleteprofile.php -n $remove_username -y
@@ -85,7 +86,7 @@ function add_user_gnusocial {
85 86
     new_username="$1"
86 87
     new_user_password="$2"
87 88
 
88
-    GNUSOCIAL_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "gnusocial domain" | head -n 1 | awk -F ':' '{print $2}')
89
+    GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
89 90
     if [ -d /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs ]; then
90 91
         cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
91 92
         php scripts/registeruser.php -n $new_username -w "$new_user_password" -e "$new_username@$HOSTNAME"
@@ -231,7 +232,7 @@ function reconfigure_gnusocial {
231 232
 
232 233
 function upgrade_gnusocial {
233 234
     if grep -q "gnusocial domain" $COMPLETION_FILE; then
234
-        GNUSOCIAL_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "gnusocial domain" | head -n 1 | awk -F ':' '{print $2}')
235
+        GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
235 236
     fi
236 237
 
237 238
     # update to the next commit
@@ -246,7 +247,7 @@ function upgrade_gnusocial {
246 247
 function backup_local_gnusocial {
247 248
     GNUSOCIAL_DOMAIN_NAME='gnusocial'
248 249
     if grep -q "gnusocial domain" $COMPLETION_FILE; then
249
-        GNUSOCIAL_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "gnusocial domain" | head -n 1 | awk -F ':' '{print $2}')
250
+        GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
250 251
     fi
251 252
 
252 253
     source_directory=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
@@ -274,7 +275,7 @@ function restore_local_gnusocial {
274 275
     if ! grep -q "gnusocial domain" $COMPLETION_FILE; then
275 276
         return
276 277
     fi
277
-    GNUSOCIAL_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "gnusocial domain" | head -n 1 | awk -F ':' '{print $2}')
278
+    GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
278 279
     if [ $GNUSOCIAL_DOMAIN_NAME ]; then
279 280
         echo $"Restoring gnusocial"
280 281
         temp_restore_dir=/root/tempgnusocial
@@ -300,7 +301,7 @@ function restore_local_gnusocial {
300 301
 
301 302
 function backup_remote_gnusocial {
302 303
     if grep -q "gnusocial domain" $COMPLETION_FILE; then
303
-        GNUSOCIAL_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "gnusocial domain" | head -n 1 | awk -F ':' '{print $2}')
304
+        GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
304 305
         temp_backup_dir=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
305 306
         if [ -d $temp_backup_dir ]; then
306 307
             function_check suspend_site
@@ -325,7 +326,7 @@ function backup_remote_gnusocial {
325 326
 function restore_remote_gnusocial {
326 327
     if grep -q "gnusocial domain" $COMPLETION_FILE; then
327 328
         echo $"Restoring gnusocial"
328
-        GNUSOCIAL_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "gnusocial domain" | head -n 1 | awk -F ':' '{print $2}')
329
+        GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
329 330
 
330 331
         # stop the daemons
331 332
         cd /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
@@ -412,11 +413,7 @@ function install_gnusocial_main {
412 413
 
413 414
     cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
414 415
     git checkout $GNUSOCIAL_COMMIT -b $GNUSOCIAL_COMMIT
415
-    if ! grep -q "gnusocial commit" $COMPLETION_FILE; then
416
-        echo "gnusocial commit:$GNUSOCIAL_COMMIT" >> $COMPLETION_FILE
417
-    else
418
-        sed -i "s/gnusocial commit.*/gnusocial commit:$GNUSOCIAL_COMMIT/g" $COMPLETION_FILE
419
-    fi
416
+    set_completion_param "gnusocial commit" "$GNUSOCIAL_COMMIT"
420 417
 
421 418
     chmod a+w /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
422 419
     chown www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
@@ -642,11 +639,7 @@ function install_gnusocial_main {
642 639
         fi
643 640
     fi
644 641
 
645
-    if ! grep -q "gnusocial domain" $COMPLETION_FILE; then
646
-        echo "gnusocial domain:$GNUSOCIAL_DOMAIN_NAME" >> $COMPLETION_FILE
647
-    else
648
-        sed -i "s|gnusocial domain.*|gnusocial domain:$GNUSOCIAL_DOMAIN_NAME|g" $COMPLETION_FILE
649
-    fi
642
+    set_completion_param "gnusocial domain" "$GNUSOCIAL_DOMAIN_NAME"
650 643
 
651 644
     install_completed gnusocial_main
652 645
 }
@@ -715,11 +708,7 @@ function install_gnusocial_plugin_sharings {
715 708
 
716 709
     chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
717 710
 
718
-    if ! grep -q "gnusocial sharings plugin commit" $COMPLETION_FILE; then
719
-        echo "gnusocial sharings plugin commit:$SHARINGS_COMMIT" >> $COMPLETION_FILE
720
-    else
721
-        sed -i "s|gnusocial sharings plugin commit.*|gnusocial sharings plugin commit:$SHARINGS_COMMIT|g" $COMPLETION_FILE
722
-    fi
711
+    set_completion_param gnusocial "sharings plugin commit" "$SHARINGS_COMMIT"
723 712
     install_completed gnusocial_plugin_sharings
724 713
 }
725 714
 
@@ -761,11 +750,7 @@ function install_gnusocial_plugin_sharings_theme {
761 750
 
762 751
     chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
763 752
 
764
-    if ! grep -q "gnusocial sharings plugin theme commit" $COMPLETION_FILE; then
765
-        echo "gnusocial sharings plugin theme commit:$SHARINGS_THEME_COMMIT" >> $COMPLETION_FILE
766
-    else
767
-        sed -i "s|gnusocial sharings plugin theme commit.*|gnusocial sharings plugin theme commit:$SHARINGS_THEME_COMMIT|g" $COMPLETION_FILE
768
-    fi
753
+    set_completions_param "gnusocial sharings plugin theme commit" "$SHARINGS_THEME_COMMIT"
769 754
     install_completed gnusocial_plugin_sharings_theme
770 755
 }
771 756
 
@@ -914,11 +899,7 @@ function install_gnusocial_theme {
914 899
         fi
915 900
     fi
916 901
 
917
-    if ! grep -q "gnusocial theme commit" $COMPLETION_FILE; then
918
-        echo "gnusocial theme commit:$GNUSOCIAL_THEME_COMMIT" >> $COMPLETION_FILE
919
-    else
920
-        sed -i "s|gnusocial theme commit.*|gnusocial theme commit:$GNUSOCIAL_THEME_COMMIT|g" $COMPLETION_FILE
921
-    fi
902
+    set_completions_param "gnusocial theme commit" "$GNUSOCIAL_THEME_COMMIT"
922 903
 
923 904
     chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
924 905
 
@@ -957,11 +938,7 @@ function install_gnusocial_markdown {
957 938
         echo "addPlugin('Markdown');" >> $gnusocial_config_file
958 939
     fi
959 940
 
960
-    if ! grep -q "gnusocial Markdown commit" $COMPLETION_FILE; then
961
-        echo "gnusocial Markdown commit:$GNUSOCIAL_MARKDOWN_COMMIT" >> $COMPLETION_FILE
962
-    else
963
-        sed -i "s|gnusocial Markdown commit.*|gnusocial Markdown commit:$GNUSOCIAL_MARKDOWN_COMMIT|g" $COMPLETION_FILE
964
-    fi
941
+    set_completions_param "gnusocial markdown commit" "$GNUSOCIAL_MARKDOWN_COMMIT"
965 942
 
966 943
     chown -R www-data:www-data $GNUSOCIAL_PATH
967 944
 
@@ -978,7 +955,7 @@ function install_gnusocial_plugin_nsfw {
978 955
     function_check set_repo_commit
979 956
     set_repo_commit /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins "gnusocial NSFW plugin commit" "$GNUSOCIAL_NSFW_COMMIT" $GNUSOCIAL_NSFW_REPO
980 957
 
981
-    if grep -Fxq "install_gnusocial_plugin_nsfw" $COMPLETION_FILE; then
958
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
982 959
         return
983 960
     fi
984 961
 
@@ -1006,11 +983,7 @@ function install_gnusocial_plugin_nsfw {
1006 983
 
1007 984
     chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
1008 985
 
1009
-    if ! grep -q "gnusocial NSFW plugin commit" $COMPLETION_FILE; then
1010
-        echo "gnusocial NSFW plugin commit:$GNUSOCIAL_NSFW_COMMIT" >> $COMPLETION_FILE
1011
-    else
1012
-        sed -i "s|gnusocial NSFW plugin commit.*|gnusocial NSFW plugin commit:$GNUSOCIAL_NSFW_COMMIT|g" $COMPLETION_FILE
1013
-    fi
986
+    set_completions_param "gnusocial NSFW plugin commit" "$GNUSOCIAL_NSFW_COMMIT"
1014 987
     install_completed gnusocial_plugin_nsfw
1015 988
 }
1016 989
 

+ 2
- 2
src/freedombone-app-gogs View File

@@ -128,7 +128,7 @@ function upgrade_gogs {
128 128
         return
129 129
     fi
130 130
 
131
-    CURR_GOGS_VERSION=$(cat $COMPLETION_FILE | grep "gogs version" | head -n 1 | awk -F ':' '{print $2}')
131
+    CURR_GOGS_VERSION=$(get_completion_param "gogs version")
132 132
     if [[ "${CURR_GOGS_VERSION}" == "${GOGS_VERSION}" ]]; then
133 133
         return
134 134
     fi
@@ -288,7 +288,7 @@ function backup_remote_gogs {
288 288
 
289 289
 function restore_remote_gogs {
290 290
     if grep -q "gogs domain" $COMPLETION_FILE; then
291
-        GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "gogs domain" | awk -F ':' '{print $2}')
291
+        GIT_DOMAIN_NAME=$(get_completion_param "gogs domain")
292 292
 
293 293
         function_check gogs_create_database
294 294
         gogs_create_database

+ 266
- 274
src/freedombone-app-htmly View File

@@ -30,18 +30,18 @@
30 30
 
31 31
 VARIANTS="full full-vim writer"
32 32
 
33
-HYMLY_DOMAIN_NAME=
34
-HYMLY_CODE=
35
-HYMLY_ONION_PORT=8086
36
-HYMLY_REPO="https://github.com/danpros/htmly"
37
-HYMLY_COMMIT='bf5fe9486160be4da86d8987d3e5c977e1dc6d32'
33
+HTMLY_DOMAIN_NAME=
34
+HTMLY_CODE=
35
+HTMLY_ONION_PORT=8086
36
+HTMLY_REPO="https://github.com/danpros/htmly"
37
+HTMLY_COMMIT='bf5fe9486160be4da86d8987d3e5c977e1dc6d32'
38 38
 HTMLY_TITLE="My Htmly"
39 39
 HTMLY_SUBTITLE="Another ${PROJECT_NAME} Htmly"
40 40
 
41
-htmly_variables=(HYMLY_REPO
42
-                HYMLY_COMMIT
43
-                HYMLY_DOMAIN_NAME
44
-                HYMLY_CODE
41
+htmly_variables=(HTMLY_REPO
42
+                HTMLY_COMMIT
43
+                HTMLY_DOMAIN_NAME
44
+                HTMLY_CODE
45 45
                 HTMLY_TITLE
46 46
                 HTMLY_SUBTITLE
47 47
                 ONION_ONLY
@@ -91,8 +91,8 @@ function set_avatar_from_url {
91 91
 function remove_user_htmly {
92 92
     remove_username="$1"
93 93
 
94
-    if [ -f /var/www/${HYMLY_DOMAIN_NAME}/htdocs/config/users/${remove_username}.ini ]; then
95
-        rm /var/www/${HYMLY_DOMAIN_NAME}/htdocs/config/users/${remove_username}.ini
94
+    if [ -f /var/www/${HTMLY_DOMAIN_NAME}/htdocs/config/users/${remove_username}.ini ]; then
95
+        rm /var/www/${HTMLY_DOMAIN_NAME}/htdocs/config/users/${remove_username}.ini
96 96
     fi
97 97
 }
98 98
 
@@ -105,7 +105,7 @@ function add_user_htmly {
105 105
     new_username="$1"
106 106
     new_user_password="$2"
107 107
 
108
-    if [ ! -d /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users ]; then
108
+    if [ ! -d /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/users ]; then
109 109
         echo '2'
110 110
         return
111 111
     fi
@@ -114,11 +114,11 @@ function add_user_htmly {
114 114
         echo '3'
115 115
         return
116 116
     fi
117
-    echo ';Password' > /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$new_username.ini
118
-    echo "password = $NEW_USER_PASSWORD_HASH" >> /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$new_username.ini
119
-    echo 'encryption = password_hash' >> /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$new_username.ini
120
-    echo ';Role' >> /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$new_username.ini
121
-    echo 'role = admin' >> /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$new_username.ini
117
+    echo ';Password' > /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/users/$new_username.ini
118
+    echo "password = $NEW_USER_PASSWORD_HASH" >> /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/users/$new_username.ini
119
+    echo 'encryption = password_hash' >> /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/users/$new_username.ini
120
+    echo ';Role' >> /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/users/$new_username.ini
121
+    echo 'role = admin' >> /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/users/$new_username.ini
122 122
     echo '0'
123 123
 }
124 124
 
@@ -152,21 +152,19 @@ function install_interactive_htmly {
152 152
 
153 153
     if [[ $ONION_ONLY != "no" ]]; then
154 154
         HTMLY_TITLE='My Htmly'
155
-        HYMLY_DOMAIN_NAME='htmly.local'
155
+        HTMLY_DOMAIN_NAME='htmly.local'
156 156
         write_config_param "HTMLY_TITLE" "$HTMLY_TITLE"
157
-        write_config_param "HYMLY_DOMAIN_NAME" "$HYMLY_DOMAIN_NAME"
157
+        write_config_param "HTMLY_DOMAIN_NAME" "$HTMLY_DOMAIN_NAME"
158 158
     else
159 159
         function_check interactive_site_details_with_title
160
-        interactive_site_details_with_title "htmly" "HTMLY_TITLE" "HYMLY_DOMAIN_NAME" "HYMLY_CODE"
160
+        interactive_site_details_with_title "htmly" "HTMLY_TITLE" "HTMLY_DOMAIN_NAME" "HTMLY_CODE"
161 161
     fi
162 162
     APP_INSTALLED=1
163 163
 }
164 164
 
165 165
 function change_password_htmly {
166
-    if ! grep -q "htmly domain:" $COMPLETION_FILE; then
167
-        echo "htmly domain:$HYMLY_DOMAIN_NAME" >> $COMPLETION_FILE
168
-    fi
169
-    HYMLY_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "htmly domain" | head -n 1 | awk -F ':' '{print $2}')
166
+    set_completion_param "htmly domain" "$HTMLY_DOMAIN_NAME"
167
+    HTMLY_DOMAIN_NAME=$(get_completion_param "htmly domain")
170 168
 
171 169
     HTMLY_USERNAME="$1"
172 170
     HTMLY_PASSWORD="$2"
@@ -179,7 +177,7 @@ function change_password_htmly {
179 177
         echo $'Htmly admin password could not be hashed'
180 178
         exit 625728
181 179
     fi
182
-    sed -i "s|password =.*|password = $HTMLY_PASSWORD_HASH|g" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$HTMLY_USERNAME.ini
180
+    sed -i "s|password =.*|password = $HTMLY_PASSWORD_HASH|g" /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/users/$HTMLY_USERNAME.ini
183 181
 }
184 182
 
185 183
 function reconfigure_htmly {
@@ -187,25 +185,25 @@ function reconfigure_htmly {
187 185
 }
188 186
 
189 187
 function upgrade_htmly {
190
-    read_config_param "HYMLY_DOMAIN_NAME"
188
+    read_config_param "HTMLY_DOMAIN_NAME"
191 189
 
192 190
     function_check set_repo_commit
193
-    set_repo_commit /var/www/$HYMLY_DOMAIN_NAME/htdocs "htmly commit" "$HYMLY_COMMIT" $HYMLY_REPO
191
+    set_repo_commit /var/www/$HTMLY_DOMAIN_NAME/htdocs "htmly commit" "$HTMLY_COMMIT" $HTMLY_REPO
194 192
 }
195 193
 
196 194
 function backup_local_htmly {
197
-    HYMLY_DOMAIN_NAME='htmly'
195
+    HTMLY_DOMAIN_NAME='htmly'
198 196
     if grep -q "htmly domain" $COMPLETION_FILE; then
199
-        HYMLY_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "htmly domain" | awk -F ':' '{print $2}')
197
+        HTMLY_DOMAIN_NAME=$(get_completion_param "htmly domain")
200 198
     fi
201 199
 
202
-    source_directory=/var/www/${HYMLY_DOMAIN_NAME}/htdocs
200
+    source_directory=/var/www/${HTMLY_DOMAIN_NAME}/htdocs
203 201
     if [ -d $source_directory ]; then
204 202
         dest_directory=htmly
205 203
         echo $"Backing up $source_directory to $dest_directory"
206 204
 
207 205
         function_check suspend_site
208
-        suspend_site ${HYMLY_DOMAIN_NAME}
206
+        suspend_site ${HTMLY_DOMAIN_NAME}
209 207
 
210 208
         function_check backup_directory_to_usb
211 209
         backup_directory_to_usb $source_directory $dest_directory
@@ -218,52 +216,52 @@ function backup_local_htmly {
218 216
 }
219 217
 
220 218
 function restore_local_htmly {
221
-    HYMLY_DOMAIN_NAME='htmly'
219
+    HTMLY_DOMAIN_NAME='htmly'
222 220
     if grep -q "htmly domain" $COMPLETION_FILE; then
223
-        HYMLY_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "htmly domain" | awk -F ':' '{print $2}')
221
+        HTMLY_DOMAIN_NAME=$(get_completion_param "htmly domain")
224 222
     fi
225
-    if [ $HYMLY_DOMAIN_NAME ]; then
223
+    if [ $HTMLY_DOMAIN_NAME ]; then
226 224
         echo $"Restoring htmly installation"
227 225
         temp_restore_dir=/root/temphtmly
228 226
         restore_directory_from_usb $temp_restore_dir htmly
229
-        rm -rf /var/www/${HYMLY_DOMAIN_NAME}/htdocs
230
-        cp -r $temp_restore_dir/var/www/${HYMLY_DOMAIN_NAME}/htdocs /var/www/${HYMLY_DOMAIN_NAME}/
227
+        rm -rf /var/www/${HTMLY_DOMAIN_NAME}/htdocs
228
+        cp -r $temp_restore_dir/var/www/${HTMLY_DOMAIN_NAME}/htdocs /var/www/${HTMLY_DOMAIN_NAME}/
231 229
         if [ ! "$?" = "0" ]; then
232 230
             set_user_permissions
233 231
             backup_unmount_drive
234 232
             exit 593
235 233
         fi
236 234
         rm -rf $temp_restore_dir
237
-        if [ ! -d /var/www/${HYMLY_DOMAIN_NAME}/htdocs/content ]; then
235
+        if [ ! -d /var/www/${HTMLY_DOMAIN_NAME}/htdocs/content ]; then
238 236
             echo $"No content directory found after restoring htmly"
239 237
             set_user_permissions
240 238
             backup_unmount_drive
241 239
             exit 287
242 240
         fi
243
-        chown -R www-data:www-data /var/www/${HYMLY_DOMAIN_NAME}/htdocs
241
+        chown -R www-data:www-data /var/www/${HTMLY_DOMAIN_NAME}/htdocs
244 242
         # Ensure that the bundled SSL cert is being used
245
-        if [ -f /etc/ssl/certs/${HYMLY_DOMAIN_NAME}.bundle.crt ]; then
246
-            sed -i "s|${HYMLY_DOMAIN_NAME}.crt|${HYMLY_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${HYMLY_DOMAIN_NAME}
243
+        if [ -f /etc/ssl/certs/${HTMLY_DOMAIN_NAME}.bundle.crt ]; then
244
+            sed -i "s|${HTMLY_DOMAIN_NAME}.crt|${HTMLY_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${HTMLY_DOMAIN_NAME}
247 245
         fi
248 246
         for d in /home/*/ ; do
249 247
             USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
250 248
             if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
251
-                if [ -d /var/www/${HYMLY_DOMAIN_NAME}/htdocs/content/$USERNAME/htmly/uncategorized/post ]; then
252
-                    mv /var/www/${HYMLY_DOMAIN_NAME}/htdocs/content/$USERNAME/htmly/*.md /var/www/${HYMLY_DOMAIN_NAME}/htdocs/content/$USERNAME/htmly/uncategorized/post
249
+                if [ -d /var/www/${HTMLY_DOMAIN_NAME}/htdocs/content/$USERNAME/htmly/uncategorized/post ]; then
250
+                    mv /var/www/${HTMLY_DOMAIN_NAME}/htdocs/content/$USERNAME/htmly/*.md /var/www/${HTMLY_DOMAIN_NAME}/htdocs/content/$USERNAME/htmly/uncategorized/post
253 251
                 fi
254 252
             fi
255 253
         done
256
-        if [ -d /etc/letsencrypt/live/${HYMLY_DOMAIN_NAME} ]; then
257
-            ln -s /etc/letsencrypt/live/${HYMLY_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${HYMLY_DOMAIN_NAME}.key
258
-            ln -s /etc/letsencrypt/live/${HYMLY_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${HYMLY_DOMAIN_NAME}.pem
254
+        if [ -d /etc/letsencrypt/live/${HTMLY_DOMAIN_NAME} ]; then
255
+            ln -s /etc/letsencrypt/live/${HTMLY_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${HTMLY_DOMAIN_NAME}.key
256
+            ln -s /etc/letsencrypt/live/${HTMLY_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${HTMLY_DOMAIN_NAME}.pem
259 257
         fi
260 258
     fi
261 259
 }
262 260
 
263 261
 function backup_remote_htmly {
264 262
     if grep -q "htmly domain" $COMPLETION_FILE; then
265
-        HYMLY_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "htmly domain" | awk -F ':' '{print $2}')
266
-        temp_backup_dir=/var/www/${HYMLY_DOMAIN_NAME}/htdocs
263
+        HTMLY_DOMAIN_NAME=$(get_completion_param "htmly domain")
264
+        temp_backup_dir=/var/www/${HTMLY_DOMAIN_NAME}/htdocs
267 265
         if [ -d $temp_backup_dir ]; then
268 266
             echo $"Backing up htmly"
269 267
             backup_directory_to_friend $temp_backup_dir htmly
@@ -277,63 +275,63 @@ function backup_remote_htmly {
277 275
 
278 276
 function restore_remote_htmly {
279 277
     if [ -d $SERVER_DIRECTORY/backup/htmly ]; then
280
-        HYMLY_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "htmly domain" | awk -F ':' '{print $2}')
281
-        echo $"Restoring htmly installation $HYMLY_DOMAIN_NAME"
278
+        HTMLY_DOMAIN_NAME=$(get_completion_param "htmly domain")
279
+        echo $"Restoring htmly installation $HTMLY_DOMAIN_NAME"
282 280
         temp_restore_dir=/root/temphtmly
283 281
         mkdir $temp_restore_dir
284 282
         function_check restore_directory_from_friend
285 283
         restore_directory_from_friend $temp_restore_dir htmly
286
-        rm -rf /var/www/${HYMLY_DOMAIN_NAME}/htdocs
287
-        cp -r $temp_restore_dir/var/www/${HYMLY_DOMAIN_NAME}/htdocs /var/www/${HYMLY_DOMAIN_NAME}/
284
+        rm -rf /var/www/${HTMLY_DOMAIN_NAME}/htdocs
285
+        cp -r $temp_restore_dir/var/www/${HTMLY_DOMAIN_NAME}/htdocs /var/www/${HTMLY_DOMAIN_NAME}/
288 286
         if [ ! "$?" = "0" ]; then
289 287
             exit 593
290 288
         fi
291 289
         rm -rf $temp_restore_dir
292
-        if [ ! -d /var/www/${HYMLY_DOMAIN_NAME}/htdocs/content ]; then
290
+        if [ ! -d /var/www/${HTMLY_DOMAIN_NAME}/htdocs/content ]; then
293 291
             echo $"No content directory found after restoring htmly"
294 292
             exit 287
295 293
         fi
296 294
         # Ensure that the bundled SSL cert is being used
297
-        if [ -f /etc/ssl/certs/${HYMLY_DOMAIN_NAME}.bundle.crt ]; then
298
-            sed -i "s|${HYMLY_DOMAIN_NAME}.crt|${HYMLY_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${HYMLY_DOMAIN_NAME}
295
+        if [ -f /etc/ssl/certs/${HTMLY_DOMAIN_NAME}.bundle.crt ]; then
296
+            sed -i "s|${HTMLY_DOMAIN_NAME}.crt|${HTMLY_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${HTMLY_DOMAIN_NAME}
299 297
         fi
300 298
         for d in /home/*/ ; do
301 299
             USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
302 300
             if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
303
-                if [ -d /var/www/${HYMLY_DOMAIN_NAME}/htdocs/content/$USERNAME/htmly/uncategorized/post ]; then
304
-                    mv /var/www/${HYMLY_DOMAIN_NAME}/htdocs/content/$USERNAME/htmly/*.md /var/www/${HYMLY_DOMAIN_NAME}/htdocs/content/$USERNAME/htmly/uncategorized/post
301
+                if [ -d /var/www/${HTMLY_DOMAIN_NAME}/htdocs/content/$USERNAME/htmly/uncategorized/post ]; then
302
+                    mv /var/www/${HTMLY_DOMAIN_NAME}/htdocs/content/$USERNAME/htmly/*.md /var/www/${HTMLY_DOMAIN_NAME}/htdocs/content/$USERNAME/htmly/uncategorized/post
305 303
                 fi
306 304
             fi
307 305
         done
308
-        if [ -d /etc/letsencrypt/live/${HYMLY_DOMAIN_NAME} ]; then
309
-            ln -s /etc/letsencrypt/live/${HYMLY_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${HYMLY_DOMAIN_NAME}.key
310
-            ln -s /etc/letsencrypt/live/${HYMLY_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${HYMLY_DOMAIN_NAME}.pem
306
+        if [ -d /etc/letsencrypt/live/${HTMLY_DOMAIN_NAME} ]; then
307
+            ln -s /etc/letsencrypt/live/${HTMLY_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${HTMLY_DOMAIN_NAME}.key
308
+            ln -s /etc/letsencrypt/live/${HTMLY_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${HTMLY_DOMAIN_NAME}.pem
311 309
         fi
312 310
         echo $"Restore of htmly complete"
313 311
     fi
314 312
 }
315 313
 
316 314
 function remove_htmly {
317
-    if [ ${#HYMLY_DOMAIN_NAME} -eq 0 ]; then
315
+    if [ ${#HTMLY_DOMAIN_NAME} -eq 0 ]; then
318 316
         return
319 317
     fi
320 318
 
321
-    read_config_param "HYMLY_DOMAIN_NAME"
322
-    nginx_dissite $HYMLY_DOMAIN_NAME
323
-    if [ -f /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME ]; then
324
-        rm -f /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
319
+    read_config_param "HTMLY_DOMAIN_NAME"
320
+    nginx_dissite $HTMLY_DOMAIN_NAME
321
+    if [ -f /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME ]; then
322
+        rm -f /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
325 323
     fi
326
-    if [ -d /var/www/$HYMLY_DOMAIN_NAME ]; then
327
-        rm -rf /var/www/$HYMLY_DOMAIN_NAME
324
+    if [ -d /var/www/$HTMLY_DOMAIN_NAME ]; then
325
+        rm -rf /var/www/$HTMLY_DOMAIN_NAME
328 326
     fi
329
-    if [ $HYMLY_CODE ]; then
327
+    if [ $HTMLY_CODE ]; then
330 328
         if [ -f /usr/bin/dynamicdns ]; then
331
-            sed -i "/$HYMLY_DOMAIN_NAME/d" /usr/bin/dynamicdns
332
-            sed -i "/$HYMLY_CODE/d" /usr/bin/dynamicdns
329
+            sed -i "/$HTMLY_DOMAIN_NAME/d" /usr/bin/dynamicdns
330
+            sed -i "/$HTMLY_CODE/d" /usr/bin/dynamicdns
333 331
         fi
334 332
     fi
335 333
     function_check remove_onion_service
336
-    remove_onion_service htmly ${HYMLY_ONION_PORT}
334
+    remove_onion_service htmly ${HTMLY_ONION_PORT}
337 335
     sed -i '/install_htmly/d' $COMPLETION_FILE
338 336
     sed -i '/Htmly .*/d' $COMPLETION_FILE
339 337
 }
@@ -341,254 +339,250 @@ function remove_htmly {
341 339
 function get_htmly_admin_password {
342 340
     if [ -f /home/$MY_USERNAME/README ]; then
343 341
         if grep -q "Your htmly password is" /home/$MY_USERNAME/README; then
344
-            HYMLY_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "Your htmly password is" | awk -F ':' '{print $2}' | sed 's/^ *//')
342
+            HTMLY_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "Your htmly password is" | awk -F ':' '{print $2}' | sed 's/^ *//')
345 343
         fi
346 344
     fi
347 345
 }
348 346
 
349 347
 function install_htmly_social_networks {
350 348
     # set social networks
351
-    if grep -q "social.hubzilla" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini; then
352
-        sed -i "s|;social.hubzilla|social.hubzilla|g" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
353
-        sed -i "s|social.hubzilla.*|social.hubzilla = \"$HUBZILLA_DOMAIN_NAME\"|g" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
349
+    if grep -q "social.hubzilla" /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/config.ini; then
350
+        sed -i "s|;social.hubzilla|social.hubzilla|g" /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/config.ini
351
+        sed -i "s|social.hubzilla.*|social.hubzilla = \"$HUBZILLA_DOMAIN_NAME\"|g" /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/config.ini
354 352
     fi
355
-    if grep -q "social.gnusocial" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini; then
356
-        sed -i "s|;social.gnusocial|social.gnusocial|g" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
357
-        sed -i "s|social.gnusocial.*|social.gnusocial = \"$MICROHTMLY_DOMAIN_NAME\"|g" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
353
+    if grep -q "social.gnusocial" /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/config.ini; then
354
+        sed -i "s|;social.gnusocial|social.gnusocial|g" /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/config.ini
355
+        sed -i "s|social.gnusocial.*|social.gnusocial = \"$MICROHTMLY_DOMAIN_NAME\"|g" /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/config.ini
358 356
     fi
359 357
 
360 358
     # clear proprietary social network strings
361
-    sed -i 's|social.facebook.*|social.facebook = ""|g' /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
362
-    sed -i 's|social.twitter.*|social.twitter = ""|g' /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
363
-    sed -i 's|social.google.*|social.google = ""|g' /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
359
+    sed -i 's|social.facebook.*|social.facebook = ""|g' /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/config.ini
360
+    sed -i 's|social.twitter.*|social.twitter = ""|g' /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/config.ini
361
+    sed -i 's|social.google.*|social.google = ""|g' /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/config.ini
364 362
 }
365 363
 
366 364
 function install_htmly_user {
367 365
     # create a user password
368 366
     function_check get_htmly_admin_password
369 367
     get_htmly_admin_password
370
-    if [ ! $HYMLY_ADMIN_PASSWORD ]; then
368
+    if [ ! $HTMLY_ADMIN_PASSWORD ]; then
371 369
         if [ -f $IMAGE_PASSWORD_FILE ]; then
372
-            HYMLY_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
370
+            HTMLY_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
373 371
         else
374
-            HYMLY_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
372
+            HTMLY_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
375 373
         fi
376 374
         echo '' >> /home/$MY_USERNAME/README
377 375
         echo '' >> /home/$MY_USERNAME/README
378 376
         echo $'HTMLy Htmly' >> /home/$MY_USERNAME/README
379 377
         echo '==========' >> /home/$MY_USERNAME/README
380 378
         echo $"Your htmly username: $MY_USERNAME" >> /home/$MY_USERNAME/README
381
-        echo $"Your htmly password is: $HYMLY_ADMIN_PASSWORD" >> /home/$MY_USERNAME/README
379
+        echo $"Your htmly password is: $HTMLY_ADMIN_PASSWORD" >> /home/$MY_USERNAME/README
382 380
         if [[ $ONION_ONLY == 'no' ]]; then
383
-            echo $"Log into your htmly at https://$HYMLY_DOMAIN_NAME/login" >> /home/$MY_USERNAME/README
381
+            echo $"Log into your htmly at https://$HTMLY_DOMAIN_NAME/login" >> /home/$MY_USERNAME/README
384 382
         fi
385 383
         chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
386 384
         chmod 600 /home/$MY_USERNAME/README
387 385
     fi
388 386
 
389 387
     # create a user
390
-    HYMLY_ADMIN_PASSWORD_HASH=$(${PROJECT_NAME}-sec --htmlyhash "$HYMLY_ADMIN_PASSWORD")
391
-    if [ ${#HYMLY_ADMIN_PASSWORD_HASH} -lt 8 ]; then
388
+    HTMLY_ADMIN_PASSWORD_HASH=$(${PROJECT_NAME}-sec --htmlyhash "$HTMLY_ADMIN_PASSWORD")
389
+    if [ ${#HTMLY_ADMIN_PASSWORD_HASH} -lt 8 ]; then
392 390
         echo $'Htmly admin password could not be hashed'
393 391
         exit 625728
394 392
     fi
395
-    echo ';Password' > /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
396
-    echo "password = $HYMLY_ADMIN_PASSWORD_HASH" >> /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
397
-    echo 'encryption = password_hash' >> /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
398
-    echo ';Role' >> /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
399
-    echo 'role = admin' >> /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
393
+    echo ';Password' > /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
394
+    echo "password = $HTMLY_ADMIN_PASSWORD_HASH" >> /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
395
+    echo 'encryption = password_hash' >> /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
396
+    echo ';Role' >> /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
397
+    echo 'role = admin' >> /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
400 398
 }
401 399
 
402 400
 function install_htmly_settings {
403
-    cp /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini.example /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
404
-    sed -i "s|site.url.*|site.url = '/'|g" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
405
-    sed -i "s|htmly.title.*|htmly.title = '$HTMLY_TITLE'|g" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
406
-    sed -i "s|htmly.tagline.*|htmly.tagline = '$HTMLY_SUBTITLE'|g" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
407
-    sed -i 's|timezone.*|timezone = "Europe/London"|g' /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
408
-    sed -i "s|Your name|$MY_NAME|g" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
401
+    cp /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/config.ini.example /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/config.ini
402
+    sed -i "s|site.url.*|site.url = '/'|g" /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/config.ini
403
+    sed -i "s|htmly.title.*|htmly.title = '$HTMLY_TITLE'|g" /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/config.ini
404
+    sed -i "s|htmly.tagline.*|htmly.tagline = '$HTMLY_SUBTITLE'|g" /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/config.ini
405
+    sed -i 's|timezone.*|timezone = "Europe/London"|g' /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/config.ini
406
+    sed -i "s|Your name|$MY_NAME|g" /var/www/$HTMLY_DOMAIN_NAME/htdocs/config/config.ini
409 407
 }
410 408
 
411 409
 function install_htmly_website {
412 410
     function_check nginx_http_redirect
413
-    nginx_http_redirect $HYMLY_DOMAIN_NAME
414
-    echo 'server {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
415
-    echo '    listen 443 ssl;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
416
-    echo "    root /var/www/$HYMLY_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
417
-    echo "    server_name $HYMLY_DOMAIN_NAME;" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
418
-    echo '    access_log off;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
419
-    echo "    error_log /var/log/nginx/${HYMLY_DOMAIN_NAME}_error_ssl.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
420
-    echo '    index index.php;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
421
-    echo '    charset utf-8;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
422
-    echo '    proxy_read_timeout 86400s;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
411
+    nginx_http_redirect $HTMLY_DOMAIN_NAME
412
+    echo 'server {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
413
+    echo '    listen 443 ssl;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
414
+    echo "    root /var/www/$HTMLY_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
415
+    echo "    server_name $HTMLY_DOMAIN_NAME;" >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
416
+    echo '    access_log off;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
417
+    echo "    error_log /var/log/nginx/${HTMLY_DOMAIN_NAME}_error_ssl.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
418
+    echo '    index index.php;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
419
+    echo '    charset utf-8;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
420
+    echo '    proxy_read_timeout 86400s;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
423 421
     function_check nginx_ssl
424
-    nginx_ssl $HYMLY_DOMAIN_NAME
422
+    nginx_ssl $HTMLY_DOMAIN_NAME
425 423
     function_check nginx_disable_sniffing
426
-    nginx_disable_sniffing $HYMLY_DOMAIN_NAME
427
-    echo '    add_header Strict-Transport-Security "max-age=0;";' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
428
-    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
429
-    echo '    # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
430
-    echo '    location / {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
424
+    nginx_disable_sniffing $HTMLY_DOMAIN_NAME
425
+    echo '    add_header Strict-Transport-Security "max-age=0;";' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
426
+    echo '' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
427
+    echo '    # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
428
+    echo '    location / {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
431 429
     function_check nginx_limits
432
-    nginx_limits $HYMLY_DOMAIN_NAME
433
-    echo '        rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
434
-    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
435
-    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
436
-    echo "    # make sure webfinger and other well known services aren't blocked" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
437
-    echo '    # by denying dot files and rewrite request to the front controller' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
438
-    echo '    location ^~ /.well-known/ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
439
-    echo '        allow all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
440
-    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
441
-    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
442
-    echo '    # statically serve these file types when possible' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
443
-    echo '    # otherwise fall back to front controller' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
444
-    echo '    # allow browser to cache them' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
445
-    echo '    # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
446
-    echo '    location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
447
-    echo '        expires 30d;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
448
-    echo '        try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
449
-    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
450
-    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
451
-    echo '    # block these file types' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
452
-    echo '    location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
453
-    echo '        deny all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
454
-    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
455
-    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
456
-    echo '    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
457
-    echo '    # or a unix socket' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
458
-    echo '    location ~* \.php$ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
459
-    echo '        # Zero-day exploit defense.' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
460
-    echo '        # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
461
-    echo "        # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
462
-    echo "        # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
463
-    echo "        # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
464
-    echo "        # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
465
-    echo '        try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
466
-    echo '        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
467
-    echo '        fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
468
-    echo '        # With php5-cgi alone:' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
469
-    echo '        # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
470
-    echo '        # With php5-fpm:' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
471
-    echo '        fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
472
-    echo '        include fastcgi_params;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
473
-    echo '        fastcgi_index index.php;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
474
-    echo '        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
475
-    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
476
-    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
477
-    echo '    # deny access to all dot files' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
478
-    echo '    location ~ /\. {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
479
-    echo '        deny all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
480
-    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
481
-    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
482
-    echo '    #deny access to store' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
483
-    echo '    location ~ /store {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
484
-    echo '        deny all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
485
-    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
486
-    echo '    location ~ /(data|conf|bin|inc)/ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
487
-    echo '      deny all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
488
-    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
489
-    echo '    location ~ /\.ht {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
490
-    echo '      deny  all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
491
-    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
492
-    echo '}' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
493
-    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
430
+    nginx_limits $HTMLY_DOMAIN_NAME
431
+    echo '        rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
432
+    echo '    }' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
433
+    echo '' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
434
+    echo "    # make sure webfinger and other well known services aren't blocked" >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
435
+    echo '    # by denying dot files and rewrite request to the front controller' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
436
+    echo '    location ^~ /.well-known/ {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
437
+    echo '        allow all;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
438
+    echo '    }' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
439
+    echo '' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
440
+    echo '    # statically serve these file types when possible' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
441
+    echo '    # otherwise fall back to front controller' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
442
+    echo '    # allow browser to cache them' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
443
+    echo '    # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
444
+    echo '    location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
445
+    echo '        expires 30d;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
446
+    echo '        try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
447
+    echo '    }' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
448
+    echo '' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
449
+    echo '    # block these file types' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
450
+    echo '    location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
451
+    echo '        deny all;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
452
+    echo '    }' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
453
+    echo '' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
454
+    echo '    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
455
+    echo '    # or a unix socket' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
456
+    echo '    location ~* \.php$ {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
457
+    echo '        # Zero-day exploit defense.' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
458
+    echo '        # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
459
+    echo "        # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
460
+    echo "        # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
461
+    echo "        # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
462
+    echo "        # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
463
+    echo '        try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
464
+    echo '        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
465
+    echo '        fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
466
+    echo '        # With php5-cgi alone:' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
467
+    echo '        # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
468
+    echo '        # With php5-fpm:' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
469
+    echo '        fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
470
+    echo '        include fastcgi_params;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
471
+    echo '        fastcgi_index index.php;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
472
+    echo '        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
473
+    echo '    }' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
474
+    echo '' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
475
+    echo '    # deny access to all dot files' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
476
+    echo '    location ~ /\. {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
477
+    echo '        deny all;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
478
+    echo '    }' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
479
+    echo '' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
480
+    echo '    #deny access to store' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
481
+    echo '    location ~ /store {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
482
+    echo '        deny all;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
483
+    echo '    }' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
484
+    echo '    location ~ /(data|conf|bin|inc)/ {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
485
+    echo '      deny all;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
486
+    echo '    }' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
487
+    echo '    location ~ /\.ht {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
488
+    echo '      deny  all;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
489
+    echo '    }' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
490
+    echo '}' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
491
+    echo '' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
494 492
 }
495 493
 
496 494
 function install_htmly_website_onion {
497
-    echo 'server {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
498
-    echo "    listen 127.0.0.1:${HYMLY_ONION_PORT} default_server;" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
499
-    echo "    root /var/www/$HYMLY_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
500
-    echo "    server_name $HYMLY_DOMAIN_NAME;" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
501
-    echo '    access_log off;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
502
-    echo "    error_log /var/log/nginx/${HYMLY_DOMAIN_NAME}_error_ssl.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
503
-    echo '    index index.php;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
504
-    echo '    charset utf-8;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
505
-    echo '    proxy_read_timeout 86400s;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
495
+    echo 'server {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
496
+    echo "    listen 127.0.0.1:${HTMLY_ONION_PORT} default_server;" >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
497
+    echo "    root /var/www/$HTMLY_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
498
+    echo "    server_name $HTMLY_DOMAIN_NAME;" >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
499
+    echo '    access_log off;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
500
+    echo "    error_log /var/log/nginx/${HTMLY_DOMAIN_NAME}_error_ssl.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
501
+    echo '    index index.php;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
502
+    echo '    charset utf-8;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
503
+    echo '    proxy_read_timeout 86400s;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
506 504
     function_check nginx_disable_sniffing
507
-    nginx_disable_sniffing $HYMLY_DOMAIN_NAME
508
-    echo '    add_header Strict-Transport-Security "max-age=0;";' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
509
-    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
510
-    echo '    # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
511
-    echo '    location / {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
505
+    nginx_disable_sniffing $HTMLY_DOMAIN_NAME
506
+    echo '    add_header Strict-Transport-Security "max-age=0;";' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
507
+    echo '' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
508
+    echo '    # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
509
+    echo '    location / {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
512 510
     function_check nginx_limits
513
-    nginx_limits $HYMLY_DOMAIN_NAME
514
-    echo '        rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
515
-    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
516
-    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
517
-    echo "    # make sure webfinger and other well known services aren't blocked" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
518
-    echo '    # by denying dot files and rewrite request to the front controller' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
519
-    echo '    location ^~ /.well-known/ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
520
-    echo '        allow all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
521
-    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
522
-    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
523
-    echo '    # statically serve these file types when possible' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
524
-    echo '    # otherwise fall back to front controller' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
525
-    echo '    # allow browser to cache them' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
526
-    echo '    # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
527
-    echo '    location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
528
-    echo '        expires 30d;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
529
-    echo '        try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
530
-    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
531
-    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
532
-    echo '    # block these file types' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
533
-    echo '    location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
534
-    echo '        deny all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
535
-    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
536
-    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
537
-    echo '    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
538
-    echo '    # or a unix socket' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
539
-    echo '    location ~* \.php$ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
511
+    nginx_limits $HTMLY_DOMAIN_NAME
512
+    echo '        rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
513
+    echo '    }' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
514
+    echo '' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
515
+    echo "    # make sure webfinger and other well known services aren't blocked" >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
516
+    echo '    # by denying dot files and rewrite request to the front controller' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
517
+    echo '    location ^~ /.well-known/ {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
518
+    echo '        allow all;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
519
+    echo '    }' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
520
+    echo '' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
521
+    echo '    # statically serve these file types when possible' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
522
+    echo '    # otherwise fall back to front controller' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
523
+    echo '    # allow browser to cache them' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
524
+    echo '    # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
525
+    echo '    location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
526
+    echo '        expires 30d;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
527
+    echo '        try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
528
+    echo '    }' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
529
+    echo '' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
530
+    echo '    # block these file types' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
531
+    echo '    location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
532
+    echo '        deny all;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
533
+    echo '    }' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
534
+    echo '' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
535
+    echo '    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
536
+    echo '    # or a unix socket' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
537
+    echo '    location ~* \.php$ {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
540 538
     function_check nginx_limits
541
-    nginx_limits $HYMLY_DOMAIN_NAME
542
-    echo '        # Zero-day exploit defense.' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
543
-    echo '        # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
544
-    echo "        # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
545
-    echo "        # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
546
-    echo "        # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
547
-    echo "        # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
548
-    echo '        try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
549
-    echo '        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
550
-    echo '        fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
551
-    echo '        # With php5-cgi alone:' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
552
-    echo '        # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
553
-    echo '        # With php5-fpm:' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
554
-    echo '        fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
555
-    echo '        include fastcgi_params;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
556
-    echo '        fastcgi_index index.php;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
557
-    echo '        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
558
-    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
559
-    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
560
-    echo '    # deny access to all dot files' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
561
-    echo '    location ~ /\. {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
562
-    echo '        deny all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
563
-    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
564
-    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
565
-    echo '    #deny access to store' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
566
-    echo '    location ~ /store {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
567
-    echo '        deny all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
568
-    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
569
-    echo '    location ~ /(data|conf|bin|inc)/ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
570
-    echo '      deny all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
571
-    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
572
-    echo '    location ~ /\.ht {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
573
-    echo '      deny  all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
574
-    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
575
-    echo '}' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
539
+    nginx_limits $HTMLY_DOMAIN_NAME
540
+    echo '        # Zero-day exploit defense.' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
541
+    echo '        # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
542
+    echo "        # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
543
+    echo "        # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
544
+    echo "        # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
545
+    echo "        # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
546
+    echo '        try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
547
+    echo '        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
548
+    echo '        fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
549
+    echo '        # With php5-cgi alone:' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
550
+    echo '        # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
551
+    echo '        # With php5-fpm:' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
552
+    echo '        fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
553
+    echo '        include fastcgi_params;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
554
+    echo '        fastcgi_index index.php;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
555
+    echo '        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
556
+    echo '    }' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
557
+    echo '' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
558
+    echo '    # deny access to all dot files' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
559
+    echo '    location ~ /\. {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
560
+    echo '        deny all;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
561
+    echo '    }' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
562
+    echo '' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
563
+    echo '    #deny access to store' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
564
+    echo '    location ~ /store {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
565
+    echo '        deny all;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
566
+    echo '    }' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
567
+    echo '    location ~ /(data|conf|bin|inc)/ {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
568
+    echo '      deny all;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
569
+    echo '    }' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
570
+    echo '    location ~ /\.ht {' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
571
+    echo '      deny  all;' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
572
+    echo '    }' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
573
+    echo '}' >> /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
576 574
 }
577 575
 
578 576
 function install_htmly_from_repo {
579
-    if [ ! -d /var/www/$HYMLY_DOMAIN_NAME ]; then
580
-        mkdir /var/www/$HYMLY_DOMAIN_NAME
577
+    if [ ! -d /var/www/$HTMLY_DOMAIN_NAME ]; then
578
+        mkdir /var/www/$HTMLY_DOMAIN_NAME
581 579
     fi
582 580
 
583
-    cd /var/www/$HYMLY_DOMAIN_NAME
584
-    git_clone $HYMLY_REPO htdocs
581
+    cd /var/www/$HTMLY_DOMAIN_NAME
582
+    git_clone $HTMLY_REPO htdocs
585 583
     cd htdocs
586
-    git checkout $HYMLY_COMMIT -b $HYMLY_COMMIT
587
-    if ! grep -q "htmly commit" $COMPLETION_FILE; then
588
-        echo "htmly commit:$HYMLY_COMMIT" >> $COMPLETION_FILE
589
-    else
590
-        sed -i "s/htmly commit.*/htmly commit:$HYMLY_COMMIT/g" $COMPLETION_FILE
591
-    fi
584
+    git checkout $HTMLY_COMMIT -b $HTMLY_COMMIT
585
+    set_completion_param "htmly commit" "$HTMLY_COMMIT"
592 586
 }
593 587
 
594 588
 function install_htmly {
@@ -596,7 +590,7 @@ function install_htmly {
596 590
         ONION_ONLY='no'
597 591
     fi
598 592
 
599
-    if [ ! $HYMLY_DOMAIN_NAME ]; then
593
+    if [ ! $HTMLY_DOMAIN_NAME ]; then
600 594
         echo $'The htmly domain name was not specified'
601 595
         exit 5062
602 596
     fi
@@ -611,13 +605,13 @@ function install_htmly {
611 605
         function_check install_htmly_website
612 606
         install_htmly_website
613 607
     else
614
-        echo -n '' > /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
608
+        echo -n '' > /etc/nginx/sites-available/$HTMLY_DOMAIN_NAME
615 609
     fi
616 610
     function_check install_htmly_website_onion
617 611
     install_htmly_website_onion
618 612
 
619 613
     function_check create_site_certificate
620
-    create_site_certificate $HYMLY_DOMAIN_NAME 'yes'
614
+    create_site_certificate $HTMLY_DOMAIN_NAME 'yes'
621 615
 
622 616
     function_check configure_php
623 617
     configure_php
@@ -631,30 +625,28 @@ function install_htmly {
631 625
     function_check install_htmly_user
632 626
     install_htmly_user
633 627
 
634
-    chown -R www-data:www-data /var/www/$HYMLY_DOMAIN_NAME/htdocs
628
+    chown -R www-data:www-data /var/www/$HTMLY_DOMAIN_NAME/htdocs
635 629
 
636
-    HYMLY_ONION_HOSTNAME=$(add_onion_service htmly 80 ${HYMLY_ONION_PORT})
630
+    HTMLY_ONION_HOSTNAME=$(add_onion_service htmly 80 ${HTMLY_ONION_PORT})
637 631
 
638 632
     function_check nginx_ensite
639
-    nginx_ensite $HYMLY_DOMAIN_NAME
633
+    nginx_ensite $HTMLY_DOMAIN_NAME
640 634
 
641 635
     systemctl restart php5-fpm
642 636
     systemctl restart nginx
643 637
 
644 638
     if ! grep -q "Htmly onion domain" /home/$MY_USERNAME/README; then
645
-        echo $"Htmly onion domain: ${HYMLY_ONION_HOSTNAME}" >> /home/$MY_USERNAME/README
646
-        echo $"Log into your htmly at https://${HYMLY_ONION_HOSTNAME}/login" >> /home/$MY_USERNAME/README
639
+        echo $"Htmly onion domain: ${HTMLY_ONION_HOSTNAME}" >> /home/$MY_USERNAME/README
640
+        echo $"Log into your htmly at https://${HTMLY_ONION_HOSTNAME}/login" >> /home/$MY_USERNAME/README
647 641
         echo '' >> /home/$MY_USERNAME/README
648 642
         chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
649 643
         chmod 600 /home/$MY_USERNAME/README
650 644
     fi
651 645
 
652 646
     function_check add_ddns_domain
653
-    add_ddns_domain $HYMLY_DOMAIN_NAME
647
+    add_ddns_domain $HTMLY_DOMAIN_NAME
654 648
 
655
-    if ! grep -q "htmly domain:" $COMPLETION_FILE; then
656
-        echo "htmly domain:$HYMLY_DOMAIN_NAME" >> $COMPLETION_FILE
657
-    fi
649
+    set_completion_param "htmly domain" "$HTMLY_DOMAIN_NAME"
658 650
     APP_INSTALLED=1
659 651
 }
660 652
 

+ 5
- 13
src/freedombone-app-hubzilla View File

@@ -59,7 +59,7 @@ function hubzilla_renew_cert {
59 59
         1) return;;
60 60
         255) return;;
61 61
     esac
62
-    HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "hubzilla domain" | awk -F ':' '{print $2}')
62
+    HUBZILLA_DOMAIN_NAME=$(get_completion_param "hubzilla domain")
63 63
     if [ ! -d /var/www/$HUBZILLA_DOMAIN_NAME/htdocs ]; then
64 64
         dialog --title $"Renew SSL certificate" \
65 65
                --msgbox $"Hubzilla install directory not found" 6 40
@@ -80,7 +80,7 @@ function hubzilla_channel_directory_server {
80 80
                --msgbox $"Hubzilla is not installed on this system" 6 40
81 81
         return
82 82
     fi
83
-    HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "hubzilla domain" | awk -F ':' '{print $2}')
83
+    HUBZILLA_DOMAIN_NAME=$(get_completion_param "hubzilla domain")
84 84
     if [ ! -d /var/www/$HUBZILLA_DOMAIN_NAME/htdocs ]; then
85 85
         dialog --title $"Hubzilla channel directory server" \
86 86
                --msgbox $"Hubzilla install directory not found" 6 40
@@ -327,11 +327,7 @@ function install_hubzilla {
327 327
         function_check git_clone
328 328
         git_clone $HUBZILLA_REPO hubzilla
329 329
         git checkout $HUBZILLA_COMMIT -b $HUBZILLA_COMMIT
330
-        if ! grep -q "hubzilla commit" $COMPLETION_FILE; then
331
-            echo "hubzilla commit:$HUBZILLA_COMMIT" >> $COMPLETION_FILE
332
-        else
333
-            sed -i "s/hubzilla commit.*/hubzilla commit:$HUBZILLA_COMMIT/g" $COMPLETION_FILE
334
-        fi
330
+        set_completion_param "hubzilla commit" "$HUBZILLA_COMMIT"
335 331
 
336 332
         rm -rf $HUBZILLA_PATH
337 333
         mv hubzilla $HUBZILLA_PATH
@@ -339,11 +335,7 @@ function install_hubzilla {
339 335
         git_clone $HUBZILLA_ADDONS_REPO $HUBZILLA_PATH/addon
340 336
         cd $HUBZILLA_PATH/addon
341 337
         git checkout $HUBZILLA_ADDONS_COMMIT -b $HUBZILLA_ADDONS_COMMIT
342
-        if ! grep -q "hubzilla addons commit" $COMPLETION_FILE; then
343
-            echo "hubzilla addons commit:$HUBZILLA_ADDONS_COMMIT" >> $COMPLETION_FILE
344
-        else
345
-            sed -i "s/hubzilla addons commit.*/hubzilla addons commit:$HUBZILLA_ADDONS_COMMIT/g" $COMPLETION_FILE
346
-        fi
338
+        set_completion_param "hubzilla addons commit" "$HUBZILLA_ADDONS_COMMIT"
347 339
 
348 340
         # some extra themes
349 341
         git_clone $HUBZILLA_THEMES_REPO $HUBZILLA_PATH/redmatrix-themes1
@@ -599,7 +591,7 @@ function install_hubzilla {
599 591
 
600 592
     ${PROJECT_NAME}-addemail -u $MY_USERNAME -e "noreply@$HUBZILLA_DOMAIN_NAME" -g hubzilla --public no
601 593
 
602
-    echo "hubzilla domain:${HUBZILLA_DOMAIN_NAME}" >> $COMPLETION_FILE
594
+    set_completion_param "hubzilla domain" "${HUBZILLA_DOMAIN_NAME}"
603 595
     APP_INSTALLED=1
604 596
 }
605 597
 

+ 8
- 12
src/freedombone-app-ipfs View File

@@ -89,7 +89,7 @@ function backup_local_ipfs {
89 89
     if ! grep -q "Admin user" $COMPLETION_FILE; then
90 90
         return
91 91
     fi
92
-    ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
92
+    ADMIN_USERNAME=$(get_completion_param "Admin user")
93 93
     source_directory=/home/$ADMIN_USERNAME/.ipfs
94 94
     if [ -d $source_directory ]; then
95 95
         dest_directory=ipfs
@@ -111,7 +111,7 @@ function restore_local_ipfs {
111 111
         temp_restore_dir=/root/tempipfs
112 112
         function_check restore_directory_from_usb
113 113
         restore_directory_from_usb $temp_restore_dir ipfs
114
-        ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
114
+        ADMIN_USERNAME=$(get_completion_param "Admin user")
115 115
         cp -rf $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs
116 116
         if [ ! "$?" = "0" ]; then
117 117
             rm -rf $temp_restore_dir
@@ -130,7 +130,7 @@ function backup_remote_ipfs {
130 130
     if ! grep -q "Admin user" $COMPLETION_FILE; then
131 131
         return
132 132
     fi
133
-    ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
133
+    ADMIN_USERNAME=$(get_completion_param "Admin user")
134 134
     if [ -d /home/$ADMIN_USERNAME/.ipfs ]; then
135 135
         echo $"Backing up IPFS"
136 136
         backup_directory_to_friend /home/$ADMIN_USERNAME/.ipfs ipfs
@@ -193,7 +193,7 @@ function remove_ipfs {
193 193
 }
194 194
 
195 195
 function configure_firewall_for_ipfs {
196
-    if grep -Fxq "configure_firewall_for_ipfs" $COMPLETION_FILE; then
196
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
197 197
         return
198 198
     fi
199 199
     if [[ $ONION_ONLY != "no" ]]; then
@@ -204,11 +204,11 @@ function configure_firewall_for_ipfs {
204 204
     save_firewall_settings
205 205
 
206 206
     OPEN_PORTS+=("IPFS     $IPFS_PORT")
207
-    echo 'configure_firewall_for_ipfs' >> $COMPLETION_FILE
207
+    mark_completed $FUNCNAME
208 208
 }
209 209
 
210 210
 function mesh_install_ipfs_js {
211
-    if grep -Fxq "mesh_install_ipfs_js" $COMPLETION_FILE; then
211
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
212 212
         return
213 213
     fi
214 214
 
@@ -280,7 +280,7 @@ EOF
280 280
 
281 281
     chroot ${rootdir} systemctl enable ${IPFS_DAEMON_NAME}
282 282
 
283
-    echo 'mesh install_ipfs_js' >> $COMPLETION_FILE
283
+    mark_completed $FUNCNAME
284 284
 }
285 285
 
286 286
 function install_ipfs_js {
@@ -515,11 +515,7 @@ function install_ipfs_go {
515 515
         exit 735639
516 516
     fi
517 517
 
518
-    if ! grep -q "ipfs commit" $COMPLETION_FILE; then
519
-        echo "ipfs commit:$IPFS_COMMIT" >> $COMPLETION_FILE
520
-    else
521
-        sed -i "s/ipfs commit.*/ipfs commit:$IPFS_COMMIT/g" $COMPLETION_FILE
522
-    fi
518
+    set_completion_param "ipfs commit" "$IPFS_COMMIT"
523 519
 
524 520
     make install
525 521
     if [ ! "$?" = "0" ]; then

+ 4
- 12
src/freedombone-app-librevault View File

@@ -120,7 +120,7 @@ function remove_librevault {
120 120
 }
121 121
 
122 122
 function configure_firewall_for_librevault {
123
-    if grep -Fxq "configure_firewall_for_librevault" $COMPLETION_FILE; then
123
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
124 124
         return
125 125
     fi
126 126
     iptables -A INPUT -p udp --dport $LIBREVAULT_PORT -j ACCEPT
@@ -128,7 +128,7 @@ function configure_firewall_for_librevault {
128 128
     function_check save_firewall_settings
129 129
     save_firewall_settings
130 130
     OPEN_PORTS+=("Librevault $LIBREVAULT_PORT")
131
-    echo 'configure_firewall_for_librevault' >> $COMPLETION_FILE
131
+    mark_completed $FUNCNAME
132 132
 }
133 133
 
134 134
 function mesh_install_librevault {
@@ -263,11 +263,7 @@ function install_librevault {
263 263
     make install
264 264
     ldconfig
265 265
 
266
-    if ! grep -q "Protobuf commit" $COMPLETION_FILE; then
267
-        echo "Protobuf commit:$PROTOBUF_COMMIT" >> $COMPLETION_FILE
268
-    else
269
-        sed -i "s/Protobuf commit.*/Protobuf commit:$PROTOBUF_COMMIT/g" $COMPLETION_FILE
270
-    fi
266
+    set_completion_param "Protobuf commit" "$PROTOBUF_COMMIT"
271 267
 
272 268
     git_clone $LIBREVAULT_REPO $INSTALL_DIR/librevault
273 269
     cd $INSTALL_DIR/librevault
@@ -286,11 +282,7 @@ function install_librevault {
286 282
     cmake --build .
287 283
     make install
288 284
 
289
-    if ! grep -q "Librevault commit" $COMPLETION_FILE; then
290
-        echo "Librevault commit:$LIBREVAULT_COMMIT" >> $COMPLETION_FILE
291
-    else
292
-        sed -i "s/Librevault commit.*/Librevault commit:$LIBREVAULT_COMMIT/g" $COMPLETION_FILE
293
-    fi
285
+    set_completion_param "Librevault commit" "$LIBREVAULT_COMMIT"
294 286
 
295 287
     LIBREVAULT_DAEMON=/etc/systemd/system/librevault-daemon.service
296 288
     echo '[Unit]' > $LIBREVAULT_DAEMON

+ 2
- 10
src/freedombone-app-mediagoblin View File

@@ -211,11 +211,7 @@ function install_mediagoblin {
211 211
     git submodule init
212 212
     git submodule update
213 213
 
214
-    if ! grep -q "Mediagoblin commit" $COMPLETION_FILE; then
215
-        echo "Mediagoblin commit:$MEDIAGOBLIN_COMMIT" >> $COMPLETION_FILE
216
-    else
217
-        sed -i "s/Mediagoblin commit.*/Mediagoblin commit:$MEDIAGOBLIN_COMMIT/g" $COMPLETION_FILE
218
-    fi
214
+    set_completion_param "mediagoblin commit" "$MEDIAGOBLIN_COMMIT"
219 215
 
220 216
     chown -hR mediagoblin:www-data $MEDIAGOBLIN_WORKING_DIRECTORY
221 217
     su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bootstrap.sh" - mediagoblin
@@ -497,11 +493,7 @@ function install_mediagoblin {
497 493
 
498 494
     add_ddns_domain $MEDIAGOBLIN_DOMAIN_NAME
499 495
 
500
-    if ! grep -q "Mediagoblin domain" $COMPLETION_FILE; then
501
-        echo "Mediagoblin domain:$MEDIAGOBLIN_DOMAIN_NAME" >> $COMPLETION_FILE
502
-    else
503
-        sed -i "s/Mediagoblin domain.*/Mediagoblin domain:$MEDIAGOBLIN_DOMAIN_NAME/g" $COMPLETION_FILE
504
-    fi
496
+    set_completion_param "mediagoblin domain" "$MEDIAGOBLIN_DOMAIN_NAME"
505 497
     APP_INSTALLED=1
506 498
 }
507 499
 

+ 2
- 2
src/freedombone-app-mumble View File

@@ -178,7 +178,7 @@ function get_mumble_server_password {
178 178
 }
179 179
 
180 180
 function configure_firewall_for_mumble {
181
-    if grep -Fxq "configure_firewall_for_mumble" $COMPLETION_FILE; then
181
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
182 182
         return
183 183
     fi
184 184
     if [[ $ONION_ONLY != "no" ]]; then
@@ -190,7 +190,7 @@ function configure_firewall_for_mumble {
190 190
     save_firewall_settings
191 191
 
192 192
     OPEN_PORTS+=("Mumble   $MUMBLE_PORT")
193
-    echo 'configure_firewall_for_mumble' >> $COMPLETION_FILE
193
+    mark_completed $FUNCNAME
194 194
 }
195 195
 
196 196
 function install_mumble {

+ 4
- 10
src/freedombone-app-rss View File

@@ -129,7 +129,7 @@ function upgrade_rss {
129 129
 
130 130
 function backup_local_rss {
131 131
     if [ -d /etc/share/tt-rss ]; then
132
-        RSS_READER_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "rss reader domain" | awk -F ':' '{print $2}')
132
+        RSS_READER_DOMAIN_NAME=$(get_completion_param "rss reader domain")
133 133
 
134 134
         echo $"Backing up ttrss"
135 135
 
@@ -298,9 +298,7 @@ function install_rss_main {
298 298
     fi
299 299
     cd $RSS_READER_PATH
300 300
     git checkout $RSS_READER_COMMIT -b $RSS_READER_COMMIT
301
-    if ! grep -q "rss reader commit" $COMPLETION_FILE; then
302
-        echo "rss reader commit:$RSS_READER_COMMIT" >> $COMPLETION_FILE
303
-    fi
301
+    set_completion_param "rss reader commit" "$RSS_READER_COMMIT"
304 302
 
305 303
     function_check install_mariadb
306 304
     install_mariadb
@@ -543,9 +541,7 @@ function install_rss_gnusocial {
543 541
     cp -r $INSTALL_DIR/ttrss-gnusocial $RSS_READER_GNUSOCIAL_PATH
544 542
     cd $RSS_READER_GNUSOCIAL_PATH
545 543
     git checkout $RSS_READER_GNUSOCIAL_COMMIT -b $RSS_READER_GNUSOCIAL_COMMIT
546
-    if ! grep -q "rss reader gnusocial commit" $COMPLETION_FILE; then
547
-        echo "rss reader gnusocial commit:$RSS_READER_GNUSOCIAL_COMMIT" >> $COMPLETION_FILE
548
-    fi
544
+    set_completion_param "rss reader gnusocial commit" "$RSS_READER_GNUSOCIAL_COMMIT"
549 545
     chown -R www-data:www-data $RSS_READER_GNUSOCIAL_PATH
550 546
     install_completed rss_gnusocial
551 547
 }
@@ -584,9 +580,7 @@ function install_rss_mobile_reader {
584 580
     fi
585 581
     cd $RSS_MOBILE_READER_PATH
586 582
     git checkout $RSS_MOBILE_READER_COMMIT -b $RSS_MOBILE_READER_COMMIT
587
-    if ! grep -q "rss mobile reader commit" $COMPLETION_FILE; then
588
-        echo "rss mobile reader commit:$RSS_MOBILE_READER_COMMIT" >> $COMPLETION_FILE
589
-    fi
583
+    set_completion_param "rss mobile reader commit" "$RSS_MOBILE_READER_COMMIT"
590 584
 
591 585
     echo 'define({' > $RSS_MOBILE_READER_PATH/scripts/conf.js
592 586
     echo '  apiPath: "/tt-rss/"' >> $RSS_MOBILE_READER_PATH/scripts/conf.js

+ 4
- 10
src/freedombone-app-searx View File

@@ -69,7 +69,7 @@ function upgrade_searx {
69 69
                 echo '        http : socks5://127.0.0.1:9050' >> ${SEARX_PATH}/searx/searx/settings.yml
70 70
                 echo '        https: socks5://127.0.0.1:9050' >> ${SEARX_PATH}/searx/searx/settings.yml
71 71
             fi
72
-            SEARX_SECRET_KEY=$(cat $COMPLETION_FILE | grep "Search engine key" | awk -F ':' '{print $2}')
72
+            SEARX_SECRET_KEY=$(get_completion_param "searx key")
73 73
             sed -i "s|secret_key.*|secret_key : \"${SEARX_SECRET_KEY}\"|g" ${SEARX_PATH}/searx/searx/settings.yml
74 74
             if [ -f /var/lib/tor/hidden_service_searx/hostname ]; then
75 75
                 SEARX_ONION_HOSTNAME=$(echo /var/lib/tor/hidden_service_searx/hostname)
@@ -164,11 +164,7 @@ function install_searx {
164 164
     function_check git_clone
165 165
     git_clone $SEARX_REPO searx
166 166
     git checkout $SEARX_COMMIT -b $SEARX_COMMIT
167
-    if ! grep -q "Search engine commit" $COMPLETION_FILE; then
168
-        echo "Search engine commit:$SEARX_COMMIT" >> $COMPLETION_FILE
169
-    else
170
-        sed -i "s/Search engine commit.*/Search engine commit:$SEARX_COMMIT/g" $COMPLETION_FILE
171
-    fi
167
+    set_completion_param "searx commit" "$SEARX_COMMIT"
172 168
 
173 169
     # create an onion service
174 170
     SEARX_ONION_HOSTNAME=$(add_onion_service searx 80 ${SEARX_ONION_PORT})
@@ -235,12 +231,10 @@ function install_searx {
235 231
     echo '}' >> /etc/nginx/sites-available/searx
236 232
 
237 233
     # replace the secret key
238
-    if ! grep "Search engine key" $COMPLETION_FILE; then
234
+    if ! grep "searx key" $COMPLETION_FILE; then
239 235
         SEARX_SECRET_KEY="$(create_password 30)"
240
-        echo "Search engine key:${SEARX_SECRET_KEY}" >> $COMPLETION_FILE
241
-    else
242
-        SEARX_SECRET_KEY=$(cat $COMPLETION_FILE | grep "Search engine key" | awk -F ':' '{print $2}')
243 236
     fi
237
+    set_completion_param "searx key" "${SEARX_SECRET_KEY}"
244 238
     sed -i "s|secret_key.*|secret_key : \"${SEARX_SECRET_KEY}\"|g" ${SEARX_PATH}/searx/searx/settings.yml
245 239
     sed -i "s|secret_key.*|secret_key : \"${SEARX_SECRET_KEY}\"|g" ${SEARX_PATH}/searx/searx/settings_robot.yml
246 240
     sed -i '0,/RE/s/base_url.*/base_url : \"http://${SEARX_ONION_HOSTNAME}\/' ${SEARX_PATH}/searx/searx/settings.yml

+ 4
- 4
src/freedombone-app-sip View File

@@ -183,7 +183,7 @@ function remove_sip {
183 183
 }
184 184
 
185 185
 function configure_firewall_for_turn {
186
-    if grep -Fxq "configure_firewall_for_turn" $COMPLETION_FILE; then
186
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
187 187
         return
188 188
     fi
189 189
     if [[ $ONION_ONLY != "no" ]]; then
@@ -197,12 +197,12 @@ function configure_firewall_for_turn {
197 197
 
198 198
     OPEN_PORTS+=("TURN     $TURN_PORT")
199 199
     OPEN_PORTS+=("TURN TLS $TURN_TLS_PORT")
200
-    echo 'configure_firewall_for_turn' >> $COMPLETION_FILE
200
+    mark_completed $FUNCNAME
201 201
 }
202 202
 
203 203
 
204 204
 function configure_firewall_for_sip4 {
205
-    if grep -Fxq "configure_firewall_for_sip4" $COMPLETION_FILE; then
205
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
206 206
         return
207 207
     fi
208 208
     if [[ $ONION_ONLY != "no" ]]; then
@@ -217,7 +217,7 @@ function configure_firewall_for_sip4 {
217 217
 
218 218
     OPEN_PORTS+=("SIP      $SIP_PORT")
219 219
     OPEN_PORTS+=("SIP TLS  $SIP_TLS_PORT")
220
-    echo 'configure_firewall_for_sip4' >> $COMPLETION_FILE
220
+    mark_completed $FUNCNAME
221 221
 }
222 222
 
223 223
 function get_sip_server_password {

+ 2
- 2
src/freedombone-app-syncthing View File

@@ -476,7 +476,7 @@ function remove_syncthing {
476 476
 }
477 477
 
478 478
 function configure_firewall_for_syncthing {
479
-    if grep -Fxq "configure_firewall_for_syncthing" $COMPLETION_FILE; then
479
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
480 480
         return
481 481
     fi
482 482
 
@@ -486,7 +486,7 @@ function configure_firewall_for_syncthing {
486 486
     save_firewall_settings
487 487
 
488 488
     OPEN_PORTS+=("Syncthing $SYNCTHING_PORT")
489
-    echo 'configure_firewall_for_syncthing' >> $COMPLETION_FILE
489
+    mark_completed $FUNCNAME
490 490
 }
491 491
 
492 492
 function install_syncthing {

+ 2
- 2
src/freedombone-app-tahoelafs View File

@@ -203,7 +203,7 @@ function remove_tahoelafs {
203 203
 }
204 204
 
205 205
 function configure_firewall_for_tahoelafs {
206
-    if grep -Fxq "configure_firewall_for_tahoelafs" $COMPLETION_FILE; then
206
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
207 207
         return
208 208
     fi
209 209
     iptables -A INPUT -p udp --dport $TAHOELAFS_PORT -j ACCEPT
@@ -211,7 +211,7 @@ function configure_firewall_for_tahoelafs {
211 211
     function_check save_firewall_settings
212 212
     save_firewall_settings
213 213
     OPEN_PORTS+=("Tahoe-LAFS $TAHOELAFS_PORT")
214
-    echo 'configure_firewall_for_tahoelafs' >> $COMPLETION_FILE
214
+    mark_completed $FUNCNAME
215 215
 }
216 216
 
217 217
 function tahoelafs_update_script {

+ 4
- 6
src/freedombone-app-tox View File

@@ -283,7 +283,7 @@ function remove_tox {
283 283
 function configure_firewall_for_tox {
284 284
     if [ ! $INSTALLING_MESH ]; then
285 285
         if [ -f $COMPLETION_FILE ]; then
286
-            if grep -Fxq "configure_firewall_for_tox" $COMPLETION_FILE; then
286
+            if [[ $(is_completed $FUNCNAME) == "1" ]]; then
287 287
                 return
288 288
             fi
289 289
         fi
@@ -312,13 +312,11 @@ function configure_firewall_for_tox {
312 312
     save_firewall_settings
313 313
 
314 314
     OPEN_PORTS+=("Tox      $TOX_PORT")
315
-    if [ -f $COMPLETION_FILE ]; then
316
-        echo 'configure_firewall_for_tox' >> $COMPLETION_FILE
317
-    fi
315
+    mark_completed $FUNCNAME
318 316
 }
319 317
 
320 318
 function tox_avahi {
321
-    if grep -Fxq "tox_avahi" $COMPLETION_FILE; then
319
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
322 320
         return
323 321
     fi
324 322
 
@@ -351,7 +349,7 @@ function tox_avahi {
351 349
 
352 350
     systemctl restart avahi-daemon
353 351
 
354
-    echo 'tox_avahi' >> $COMPLETION_FILE
352
+    mark_completed $FUNCNAME
355 353
 }
356 354
 
357 355
 function install_tox_node {

+ 1
- 5
src/freedombone-app-webmail View File

@@ -163,11 +163,7 @@ function install_webmail {
163 163
         git_clone $WEBMAIL_REPO webmail
164 164
         cd $WEBMAIL_PATH
165 165
         git checkout $WEBMAIL_COMMIT -b $WEBMAIL_COMMIT
166
-        if ! grep -q "webmail commit" $COMPLETION_FILE; then
167
-            echo "webmail commit:$WEBMAIL_COMMIT" >> $COMPLETION_FILE
168
-        else
169
-            sed -i "s/webmail commit.*/webmail commit:$WEBMAIL_COMMIT/g" $COMPLETION_FILE
170
-        fi
166
+        set_completion_param "webmail commit" "$WEBMAIL_COMMIT"
171 167
     fi
172 168
     if [ ! -f $WEBMAIL_PATH/index.php ]; then
173 169
         echo $'Did not clone webmail repo'

+ 3
- 7
src/freedombone-app-xmpp View File

@@ -238,7 +238,7 @@ function configure_firewall_for_xmpp {
238 238
     if [ ! -d /etc/prosody ]; then
239 239
         return
240 240
     fi
241
-    if grep -Fxq "configure_firewall_for_xmpp" $COMPLETION_FILE; then
241
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
242 242
         return
243 243
     fi
244 244
     if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
@@ -257,7 +257,7 @@ function configure_firewall_for_xmpp {
257 257
     OPEN_PORTS+=('XMPP     5222-5223')
258 258
     OPEN_PORTS+=('XMPP     5269')
259 259
     OPEN_PORTS+=('XMPP     5280-5281')
260
-    echo 'configure_firewall_for_xmpp' >> $COMPLETION_FILE
260
+    mark_completed $FUNCNAME
261 261
 }
262 262
 
263 263
 function remove_xmpp_client {
@@ -444,11 +444,7 @@ function install_xmpp_main {
444 444
         echo "VirtualHost \"${XMPP_ONION_HOSTNAME}\"" >> /etc/prosody/conf.avail/xmpp.cfg.lua
445 445
         echo '    modules_enabled = { "onions" };' >> /etc/prosody/conf.avail/xmpp.cfg.lua
446 446
     fi
447
-    if ! grep -q "xmpp onion domain" $COMPLETION_FILE; then
448
-        echo "xmpp onion domain:${XMPP_ONION_HOSTNAME}" >> $COMPLETION_FILE
449
-    else
450
-        sed -i "s|xmpp onion domain.*|xmpp onion domain:${XMPP_ONION_HOSTNAME}|g" $COMPLETION_FILE
451
-    fi
447
+    set_completion_param "xmpp onion domain" "${XMPP_ONION_HOSTNAME}"
452 448
 
453 449
     if ! grep -q "Your xmpp password is" /home/$MY_USERNAME/README; then
454 450
         if [ ${#XMPP_PASSWORD} -lt 8 ]; then

+ 5
- 17
src/freedombone-app-zeronet View File

@@ -138,7 +138,7 @@ function remove_zeronet {
138 138
 }
139 139
 
140 140
 function configure_firewall_for_zeronet {
141
-    if grep -Fxq "configure_firewall_for_zeronet" $COMPLETION_FILE; then
141
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
142 142
         return
143 143
     fi
144 144
     iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport $ZERONET_PORT -j ACCEPT
@@ -151,7 +151,7 @@ function configure_firewall_for_zeronet {
151 151
 
152 152
     OPEN_PORTS+=("ZeroNet  $ZERONET_PORT")
153 153
     OPEN_PORTS+=("Tracker  $TRACKER_PORT")
154
-    echo 'configure_firewall_for_zeronet' >> $COMPLETION_FILE
154
+    mark_completed $FUNCNAME
155 155
 }
156 156
 
157 157
 function install_zeronet_blog {
@@ -212,11 +212,7 @@ function install_zeronet_blog {
212 212
     fi
213 213
     cd $MESH_INSTALL_DIR/zeronet/ZeroBlog
214 214
     git checkout $ZERONET_BLOG_COMMIT -b $ZERONET_BLOG_COMMIT
215
-    if ! grep -q "ZeroNet Blog commit" $COMPLETION_FILE; then
216
-        echo "ZeroNet Blog commit:$ZERONET_BLOG_COMMIT" >> $COMPLETION_FILE
217
-    else
218
-        sed -i "s/ZeroNet Blog commit.*/ZeroNet Blog commit:$ZERONET_BLOG_COMMIT/g" $COMPLETION_FILE
219
-    fi
215
+    set_completion_param "zeroNet blog commit" "$ZERONET_BLOG_COMMIT"
220 216
 
221 217
     echo $"ZeroNet Blog address:     $ZERONET_BLOG_ADDRESS"
222 218
     echo $"ZeroNet Blog private key: $ZERONET_BLOG_PRIVATE_KEY"
@@ -313,11 +309,7 @@ function install_zeronet_mail {
313 309
     fi
314 310
     cd $MESH_INSTALL_DIR/zeronet/ZeroMail
315 311
     git checkout $ZERONET_MAIL_COMMIT -b $ZERONET_MAIL_COMMIT
316
-    if ! grep -q "ZeroNet Mail commit" $COMPLETION_FILE; then
317
-        echo "ZeroNet Mail commit:$ZERONET_MAIL_COMMIT" >> $COMPLETION_FILE
318
-    else
319
-        sed -i "s/ZeroNet Mail commit.*/ZeroNet Mail commit:$ZERONET_MAIL_COMMIT/g" $COMPLETION_FILE
320
-    fi
312
+    set_completion_param "zeroNet mail commit" "$ZERONET_MAIL_COMMIT"
321 313
 
322 314
     echo $"ZeroNet Mail address:     $ZERONET_MAIL_ADDRESS"
323 315
     echo $"ZeroNet Mail private key: $ZERONET_MAIL_PRIVATE_KEY"
@@ -413,11 +405,7 @@ function install_zeronet_forum {
413 405
         exit 6739
414 406
     fi
415 407
     git checkout $ZERONET_FORUM_COMMIT -b $ZERONET_FORUM_COMMIT
416
-    if ! grep -q "ZeroNet Forum commit" $COMPLETION_FILE; then
417
-        echo "ZeroNet Forum commit:$ZERONET_FORUM_COMMIT" >> $COMPLETION_FILE
418
-    else
419
-        sed -i "s/ZeroNet Forum commit.*/ZeroNet Forum commit:$ZERONET_FORUM_COMMIT/g" $COMPLETION_FILE
420
-    fi
408
+    set_completion_param "zeroNet forum commit" "$ZERONET_FORUM_COMMIT"
421 409
 
422 410
     echo $"Forum address:     $ZERONET_FORUM_ADDRESS"
423 411
     echo $"Forum private key: $ZERONET_FORUM_PRIVATE_KEY"

+ 1
- 1
src/freedombone-backup-remote View File

@@ -57,7 +57,7 @@ SERVER_DIRECTORY=/root/remotebackup
57 57
 # get the version of Go being used
58 58
 GO_VERSION=$(cat /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-go | grep 'GO_VERSION=' | head -n 1 | awk -F '=' '{print $2}')
59 59
 
60
-ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
60
+ADMIN_USERNAME=$(get_completion_param "Admin user")
61 61
 ADMIN_NAME=$(getent passwd $ADMIN_USERNAME | cut -d: -f5 | cut -d, -f1)
62 62
 ADMIN_EMAIL_ADDRESS=${ADMIN_USERNAME}@${HOSTNAME}
63 63
 if [ ! -f /etc/ssl/private/backup.key ]; then

+ 35
- 47
src/freedombone-base-email View File

@@ -83,7 +83,7 @@ function backup_email {
83 83
 }
84 84
 
85 85
 function configure_firewall_for_email {
86
-    if grep -Fxq "configure_firewall_for_email" $COMPLETION_FILE; then
86
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
87 87
         return
88 88
     fi
89 89
     if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
@@ -104,7 +104,7 @@ function configure_firewall_for_email {
104 104
     OPEN_PORTS+=('Email    587')
105 105
     OPEN_PORTS+=('Email    465')
106 106
     OPEN_PORTS+=('Email    993')
107
-    echo 'configure_firewall_for_email' >> $COMPLETION_FILE
107
+    mark_completed $FUNCNAME
108 108
 }
109 109
 
110 110
 function encrypt_incoming_email {
@@ -119,7 +119,7 @@ function encrypt_incoming_email {
119 119
     function_check set_repo_commit
120 120
     set_repo_commit $INSTALL_DIR/gpgit "gpgit commit" "$GPGIT_COMMIT" $GPGIT_REPO
121 121
 
122
-    if grep -Fxq "encrypt_incoming_email" $COMPLETION_FILE; then
122
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
123 123
         return
124 124
     fi
125 125
 
@@ -134,11 +134,7 @@ function encrypt_incoming_email {
134 134
         git_clone $GPGIT_REPO $INSTALL_DIR/gpgit
135 135
         cd $INSTALL_DIR/gpgit
136 136
         git checkout $GPGIT_COMMIT -b $GPGIT_COMMIT
137
-        if ! grep -q "gpgit commit" $COMPLETION_FILE; then
138
-            echo "gpgit commit:$GPGIT_COMMIT" >> $COMPLETION_FILE
139
-        else
140
-            sed -i "s/gpgit commit.*/gpgit commit:$GPGIT_COMMIT/g" $COMPLETION_FILE
141
-        fi
137
+        set_completion_param "gpgit commit" "$GPGIT_COMMIT"
142 138
         cp gpgit.pl /usr/bin
143 139
     fi
144 140
 
@@ -153,7 +149,7 @@ function encrypt_incoming_email {
153 149
         echo -n '| /usr/bin/gpgit.pl --encrypt-mode prefer-inline --inline-flatten $USER@' >> /etc/skel/.procmailrc
154 150
         echo "$DEFAULT_DOMAIN_NAME" >> /etc/skel/.procmailrc
155 151
     fi
156
-    echo 'encrypt_incoming_email' >> $COMPLETION_FILE
152
+    mark_completed $FUNCNAME
157 153
 }
158 154
 
159 155
 function encrypt_outgoing_email {
@@ -163,7 +159,7 @@ function encrypt_outgoing_email {
163 159
     if [ ! -d /etc/exim4 ]; then
164 160
         return
165 161
     fi
166
-    if grep -Fxq "encrypt_outgoing_email" $COMPLETION_FILE; then
162
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
167 163
         return
168 164
     fi
169 165
     if [[ $GPG_ENCRYPT_STORED_EMAIL != "yes" ]]; then
@@ -203,7 +199,7 @@ function encrypt_outgoing_email {
203 199
         sed -i "s|set pgp_encrypt_sign_command.*|set pgp_encrypt_sign_command=\"/usr/lib/mutt/pgpewrap gpg %?p?--passphrase-fd 0? --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust --encrypt-to 0x$MY_GPG_PUBLIC_KEY_ID -- -r %r -- %f\"|g" /home/$MY_USERNAME/.muttrc
204 200
     fi
205 201
 
206
-    echo 'encrypt_outgoing_email' >> $COMPLETION_FILE
202
+    mark_completed $FUNCNAME
207 203
 }
208 204
 
209 205
 function encrypt_all_email {
@@ -221,7 +217,7 @@ function encrypt_all_email {
221 217
     fi
222 218
     chmod +x /usr/bin/encmaildir
223 219
 
224
-    if grep -Fxq "encrypt_all_email" $COMPLETION_FILE; then
220
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
225 221
         return
226 222
     fi
227 223
 
@@ -245,7 +241,7 @@ function encrypt_all_email {
245 241
         chmod 600 /home/$MY_USERNAME/README
246 242
     fi
247 243
 
248
-    echo 'encrypt_all_email' >> $COMPLETION_FILE
244
+    mark_completed $FUNCNAME
249 245
 }
250 246
 
251 247
 function email_client {
@@ -370,7 +366,7 @@ function email_client {
370 366
         chown ${GENERIC_IMAGE_USERNAME}:${GENERIC_IMAGE_USERNAME} /home/${GENERIC_IMAGE_USERNAME}/.mutt-alias
371 367
     fi
372 368
 
373
-    echo 'email_client' >> $COMPLETION_FILE
369
+    mark_completed $FUNCNAME
374 370
 }
375 371
 
376 372
 function email_archiving {
@@ -395,7 +391,7 @@ function email_archiving {
395 391
     function_check set_repo_commit
396 392
     set_repo_commit $INSTALL_DIR/cleanup-maildir "cleanup-maildir commit" "$CLEANUP_MAILDIR_COMMIT" $CLEANUP_MAILDIR_REPO
397 393
 
398
-    if grep -Fxq "email_archiving" $COMPLETION_FILE; then
394
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
399 395
         return
400 396
     fi
401 397
 
@@ -407,20 +403,16 @@ function email_archiving {
407 403
     git_clone $CLEANUP_MAILDIR_REPO $INSTALL_DIR/cleanup-maildir
408 404
     cd $INSTALL_DIR/cleanup-maildir
409 405
     git checkout $CLEANUP_MAILDIR_COMMIT -b $CLEANUP_MAILDIR_COMMIT
410
-    if ! grep -q "cleanup-maildir commit" $COMPLETION_FILE; then
411
-        echo "cleanup-maildir commit:$CLEANUP_MAILDIR_COMMIT" >> $COMPLETION_FILE
412
-    else
413
-        sed -i "s/cleanup-maildir commit.*/cleanup-maildir commit:$CLEANUP_MAILDIR_COMMIT/g" $COMPLETION_FILE
414
-    fi
406
+    set_completion_param "cleanup-maildir commit" "$CLEANUP_MAILDIR_COMMIT"
415 407
 
416 408
     cp $INSTALL_DIR/cleanup-maildir/cleanup-maildir /usr/bin
417 409
 
418
-    echo 'email_archiving' >> $COMPLETION_FILE
410
+    mark_completed $FUNCNAME
419 411
 }
420 412
 
421 413
 # Ensure that the from field is correct when sending email from Mutt
422 414
 function email_from_address {
423
-    if grep -Fxq "email_from_address" $COMPLETION_FILE; then
415
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
424 416
         return
425 417
     fi
426 418
 
@@ -433,14 +425,14 @@ function email_from_address {
433 425
         echo "set from='$MY_NAME <$MY_EMAIL_ADDRESS>'" >> /home/$MY_USERNAME/.muttrc
434 426
     fi
435 427
 
436
-    echo 'email_from_address' >> $COMPLETION_FILE
428
+    mark_completed $FUNCNAME
437 429
 }
438 430
 
439 431
 function create_public_mailing_list {
440 432
     if [ ! -d /etc/exim4 ]; then
441 433
         return
442 434
     fi
443
-    if grep -Fxq "create_public_mailing_list" $COMPLETION_FILE; then
435
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
444 436
         return
445 437
     fi
446 438
     if [ ! $PUBLIC_MAILING_LIST ]; then
@@ -530,7 +522,7 @@ function create_public_mailing_list {
530 522
 
531 523
     ${PROJECT_NAME}-addlist -u $MY_USERNAME -l "$PUBLIC_MAILING_LIST" -s "$PUBLIC_MAILING_LIST"
532 524
 
533
-    echo 'create_public_mailing_list' >> $COMPLETION_FILE
525
+    mark_completed $FUNCNAME
534 526
 }
535 527
 
536 528
 function create_private_mailing_list {
@@ -539,7 +531,7 @@ function create_private_mailing_list {
539 531
     fi
540 532
     # This installation doesn't work, results in ruby errors
541 533
     # There is currently no schleuder package for Debian jessie
542
-    if grep -Fxq "create_private_mailing_list" $COMPLETION_FILE; then
534
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
543 535
         return
544 536
     fi
545 537
     if [ ! $PRIVATE_MAILING_LIST ]; then
@@ -590,7 +582,7 @@ function create_private_mailing_list {
590 582
     adduser Debian-exim schleuder
591 583
     usermod -a -G mail schleuder
592 584
     #exim -d -bt $PRIVATE_MAILING_LIST@$DEFAULT_DOMAIN_NAME
593
-    echo 'create_private_mailing_list' >> $COMPLETION_FILE
585
+    mark_completed $FUNCNAME
594 586
 }
595 587
 
596 588
 function split_gpg_key_into_fragments {
@@ -648,7 +640,7 @@ function import_email {
648 640
             exit 9
649 641
         fi
650 642
     fi
651
-    echo 'import_email' >> $COMPLETION_FILE
643
+    mark_completed $FUNCNAME
652 644
     if [[ $SYSTEM_TYPE == "mail"* ]]; then
653 645
         function_check backup_to_friends_servers
654 646
         backup_to_friends_servers
@@ -721,11 +713,7 @@ function install_email {
721 713
         set_hostname ${EMAIL_ONION_HOSTNAME}
722 714
         MY_EMAIL_ADDRESS=${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}
723 715
     fi
724
-    if ! grep -q "email onion domain" $COMPLETION_FILE; then
725
-        echo "email onion domain:${EMAIL_ONION_HOSTNAME}" >> $COMPLETION_FILE
726
-    else
727
-        sed -i "s|email onion domain.*|email onion domain:${EMAIL_ONION_HOSTNAME}|g" $COMPLETION_FILE
728
-    fi
716
+    set_completion_param "email onion domain" "${EMAIL_ONION_HOSTNAME}"
729 717
 
730 718
     # see https://github.com/petterreinholdtsen/exim4-smtorp
731 719
     echo '# tor stuff first' > /etc/exim4/conf.d/router/100_exim4-smtorp
@@ -904,14 +892,14 @@ function install_email {
904 892
 
905 893
     function_check configure_firewall_for_email
906 894
     configure_firewall_for_email
907
-    echo 'install_email' >> $COMPLETION_FILE
895
+    mark_completed $FUNCNAME
908 896
 }
909 897
 
910 898
 function create_procmail {
911 899
     if [ ! -d /etc/exim4 ]; then
912 900
         return
913 901
     fi
914
-    if grep -Fxq "create_procmail" $COMPLETION_FILE; then
902
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
915 903
         return
916 904
     fi
917 905
     if [ ! -f /home/$MY_USERNAME/.procmailrc ]; then
@@ -938,7 +926,7 @@ function create_procmail {
938 926
         chown root:root /etc/skel/.procmailrc
939 927
     fi
940 928
 
941
-    echo 'create_procmail' >> $COMPLETION_FILE
929
+    mark_completed $FUNCNAME
942 930
 }
943 931
 
944 932
 function handle_admin_emails {
@@ -954,7 +942,7 @@ function spam_filtering {
954 942
     if [ ! -d /etc/exim4 ]; then
955 943
         return
956 944
     fi
957
-    if grep -Fxq "spam_filtering" $COMPLETION_FILE; then
945
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
958 946
         return
959 947
     fi
960 948
     apt-get -y install exim4-daemon-heavy
@@ -1108,14 +1096,14 @@ function spam_filtering {
1108 1096
     systemctl restart exim4
1109 1097
     systemctl restart cron
1110 1098
 
1111
-    echo 'spam_filtering' >> $COMPLETION_FILE
1099
+    mark_completed $FUNCNAME
1112 1100
 }
1113 1101
 
1114 1102
 function configure_imap {
1115 1103
     if [ ! -d /etc/exim4 ]; then
1116 1104
         return
1117 1105
     fi
1118
-    if grep -Fxq "configure_imap" $COMPLETION_FILE; then
1106
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
1119 1107
         return
1120 1108
     fi
1121 1109
 
@@ -1194,14 +1182,14 @@ function configure_imap {
1194 1182
     fi
1195 1183
 
1196 1184
     systemctl restart dovecot
1197
-    echo 'configure_imap' >> $COMPLETION_FILE
1185
+    mark_completed $FUNCNAME
1198 1186
 }
1199 1187
 
1200 1188
 function configure_imap_client_certs {
1201 1189
     if [ ! -d /etc/exim4 ]; then
1202 1190
         return
1203 1191
     fi
1204
-    if grep -Fxq "configure_imap_client_certs" $COMPLETION_FILE; then
1192
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
1205 1193
         return
1206 1194
     fi
1207 1195
     # http://strange.systems/certificate-based-auth-with-dovecot-sendmail/
@@ -1276,14 +1264,14 @@ function configure_imap_client_certs {
1276 1264
     echo 0001 > /etc/ssl/sslserial
1277 1265
     #${PROJECT_NAME}-clientcert -u $MY_USERNAME
1278 1266
     systemctl restart dovecot
1279
-    echo 'configure_imap_client_certs' >> $COMPLETION_FILE
1267
+    mark_completed $FUNCNAME
1280 1268
 }
1281 1269
 
1282 1270
 function create_gpg_subkey {
1283 1271
     if [ ! -d /etc/exim4 ]; then
1284 1272
         return
1285 1273
     fi
1286
-    if grep -Fxq "create_gpg_subkey" $COMPLETION_FILE; then
1274
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
1287 1275
         return
1288 1276
     fi
1289 1277
     apt-get -y install gnupg
@@ -1313,7 +1301,7 @@ function create_gpg_subkey {
1313 1301
     shred -zu /home/$MY_USERNAME/gpg-genkey.conf
1314 1302
     MY_GPG_SUBKEY_ID=$(su -c "gpg --list-keys $MY_EMAIL_ADDRESS | grep 'pub '" - $MY_USERNAME | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}')
1315 1303
 
1316
-    echo 'create_gpg_subkey' >> $COMPLETION_FILE
1304
+    mark_completed $FUNCNAME
1317 1305
 }
1318 1306
 
1319 1307
 function gpg_key_exists {
@@ -1351,7 +1339,7 @@ function configure_gpg {
1351 1339
     if [ ! -d /etc/exim4 ]; then
1352 1340
         return
1353 1341
     fi
1354
-    if grep -Fxq "configure_gpg" $COMPLETION_FILE; then
1342
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
1355 1343
         return
1356 1344
     fi
1357 1345
     apt-get -y install gnupg
@@ -1369,7 +1357,7 @@ function configure_gpg {
1369 1357
         chown -R $MY_USERNAME:$MY_USERNAME $gpg_dir
1370 1358
         chmod 700 $gpg_dir
1371 1359
         chmod 600 $gpg_dir/*
1372
-        echo 'configure_gpg' >> $COMPLETION_FILE
1360
+        mark_completed $FUNCNAME
1373 1361
         return
1374 1362
     fi
1375 1363
 
@@ -1477,7 +1465,7 @@ function configure_gpg {
1477 1465
         fi
1478 1466
     fi
1479 1467
 
1480
-    echo 'configure_gpg' >> $COMPLETION_FILE
1468
+    mark_completed $FUNCNAME
1481 1469
 }
1482 1470
 
1483 1471
 function refresh_gpg_keys {

+ 2
- 2
src/freedombone-base-tripwire View File

@@ -49,7 +49,7 @@ function remove_tripwire {
49 49
 }
50 50
 
51 51
 function install_tripwire {
52
-    if grep -Fxq "install_tripwire" $COMPLETION_FILE; then
52
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
53 53
         return
54 54
     fi
55 55
     apt-get -y install tripwire
@@ -99,7 +99,7 @@ function install_tripwire {
99 99
 
100 100
        ' | reset-tripwire
101 101
 
102
-    echo 'install_tripwire' >> $COMPLETION_FILE
102
+    mark_completed $FUNCNAME
103 103
 }
104 104
 
105 105
 # NOTE: deliberately no exit 0

+ 1
- 1
src/freedombone-controlpanel View File

@@ -1746,7 +1746,7 @@ if [ ! -f $COMPLETION_FILE ]; then
1746 1746
     exit 1
1747 1747
 fi
1748 1748
 
1749
-ADMIN_USER=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
1749
+ADMIN_USER=$(get_completion_param "Admin user")
1750 1750
 read_repo_servers
1751 1751
 menu_top_level
1752 1752
 clear

+ 7
- 1
src/freedombone-encrypt-mail View File

@@ -33,7 +33,13 @@ USERNAME=$1
33 33
 PROJECT_NAME='freedombone'
34 34
 COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
35 35
 
36
-ADMIN_USER=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
36
+UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
37
+for f in $UTILS_FILES
38
+do
39
+  source $f
40
+done
41
+
42
+ADMIN_USER=$(get_completion_param "Admin user")
37 43
 
38 44
 if [ ! $USERNAME ]; then
39 45
     USERNAME=$ADMIN_USER

+ 2
- 2
src/freedombone-restore-local View File

@@ -62,7 +62,7 @@ ADMIN_NAME=
62 62
 read_config_param USB_DRIVE
63 63
 
64 64
 if [ -f $COMPLETION_FILE ]; then
65
-    ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
65
+    ADMIN_USERNAME=$(get_completion_param "Admin user")
66 66
 fi
67 67
 
68 68
 # MariaDB password
@@ -152,7 +152,7 @@ function restore_configuration {
152 152
 }
153 153
 
154 154
 function same_admin_user {
155
-    PREV_ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
155
+    PREV_ADMIN_USERNAME=$(get_completion_param "Admin user")
156 156
     if [[ "$PREV_ADMIN_USERNAME" != "$ADMIN_USERNAME" ]]; then
157 157
         echo $"The admin username has changed from $PREV_ADMIN_USERNAME to $ADMIN_USERNAME. To restore you will first need to install a new ${PROJECT_NAME} system with an initial admin user named $PREV_ADMIN_USERNAME"
158 158
         set_user_permissions

+ 6
- 2
src/freedombone-restore-remote View File

@@ -36,7 +36,11 @@ BACKUP_EXTRA_DIRECTORIES=/root/backup-extra-dirs.csv
36 36
 export TEXTDOMAIN=${PROJECT_NAME}-restore-remote
37 37
 export TEXTDOMAINDIR="/usr/share/locale"
38 38
 
39
-source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-validation
39
+UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
40
+for f in $UTILS_FILES
41
+do
42
+  source $f
43
+done
40 44
 
41 45
 SERVER_NAME=$1
42 46
 
@@ -47,7 +51,7 @@ if [ ${2} ]; then
47 51
     RESTORE_APP=${2}
48 52
 fi
49 53
 
50
-ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | -nawk -F ':' '{print $2}')
54
+ADMIN_USERNAME=$(get_completion_param "Admin user")
51 55
 ADMIN_EMAIL_ADDRESS=${ADMIN_USERNAME}@${HOSTNAME}
52 56
 
53 57
 # Temporary location for data to be backed up to other servers

+ 1
- 1
src/freedombone-rmuser View File

@@ -74,7 +74,7 @@ if ! grep -q "Admin user" $COMPLETION_FILE; then
74 74
     exit 5
75 75
 fi
76 76
 
77
-ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
77
+ADMIN_USERNAME=$(get_completion_param "Admin user")
78 78
 if [ ! $ADMIN_USERNAME ]; then
79 79
     echo $"No admin username specified in $COMPLETION_FILE"
80 80
     exit 6

+ 7
- 7
src/freedombone-syncthing View File

@@ -36,7 +36,11 @@ PROJECT_NAME='freedombone'
36 36
 export TEXTDOMAIN=$PROJECT_NAME-syncthing
37 37
 export TEXTDOMAINDIR="/usr/share/locale"
38 38
 
39
-source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-validation
39
+UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
40
+for f in $UTILS_FILES
41
+do
42
+  source $f
43
+done
40 44
 
41 45
 # File which keeps track of what has already been installed
42 46
 COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
@@ -73,7 +77,7 @@ function new_syncthing_id {
73 77
 
74 78
 function create_syncthing_config {
75 79
     if grep -q "syncthing ID" $COMPLETION_FILE; then
76
-        SYNCTHING_ID=$(cat $COMPLETION_FILE | grep "syncthing ID" | awk -F ':' '{print $2}')
80
+        SYNCTHING_ID=$(get_completion_param "syncthing ID")
77 81
     else
78 82
         if [ -f $SYNCTHING_CONFIG_FILE ]; then
79 83
             SYNCTHING_ID=$(cat $SYNCTHING_CONFIG_FILE | grep "device id=" | head -n 1 | awk -F '"' '{print $2}')
@@ -82,11 +86,7 @@ function create_syncthing_config {
82 86
         fi
83 87
     fi
84 88
 
85
-    if ! grep -q "syncthing ID" $COMPLETION_FILE; then
86
-        echo "syncthing ID:$SYNCTHING_ID" >> $COMPLETION_FILE
87
-    else
88
-        sed -i "s|syncthing ID.*|syncthing ID:$SYNCTHING_ID|g" $COMPLETION_FILE
89
-    fi
89
+    set_completion_param "syncthing ID" "$SYNCTHING_ID"
90 90
 
91 91
     if [ ! -d $SYNCTHING_CONFIG_PATH ]; then
92 92
         mkdir -p $SYNCTHING_CONFIG_PATH

+ 2
- 2
src/freedombone-utils-avahi View File

@@ -99,7 +99,7 @@ function install_avahi {
99 99
         mesh_avahi
100 100
         return
101 101
     fi
102
-    if grep -Fxq "install_avahi" $COMPLETION_FILE; then
102
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
103 103
         return
104 104
     fi
105 105
     # only enable avahi if we're doing mesh networking
@@ -123,7 +123,7 @@ function install_avahi {
123 123
         sed -i "s|host-name=.*|host-name=P$PEER_ID|g" /etc/avahi/avahi-daemon.conf
124 124
     fi
125 125
 
126
-    echo 'install_avahi' >> $COMPLETION_FILE
126
+    mark_completed $FUNCNAME
127 127
 }
128 128
 
129 129
 # NOTE: deliberately there is no "exit 0"

+ 3
- 3
src/freedombone-utils-backup View File

@@ -49,7 +49,7 @@ function restart_site {
49 49
 }
50 50
 
51 51
 function configure_backup_key {
52
-    if grep -Fxq "configure_backup_key" $COMPLETION_FILE; then
52
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
53 53
         return
54 54
     fi
55 55
     apt-get -y install gnupg
@@ -102,7 +102,7 @@ function configure_backup_key {
102 102
     shred -zu ${MY_BACKUP_KEY}_public.asc
103 103
     shred -zu ${MY_BACKUP_KEY}_private.asc
104 104
 
105
-    echo 'configure_backup_key' >> $COMPLETION_FILE
105
+    mark_completed $FUNCNAME
106 106
 }
107 107
 
108 108
 function backup_to_friends_servers {
@@ -122,7 +122,7 @@ function backup_mount_drive {
122 122
     fi
123 123
 
124 124
     # get the admin user
125
-    ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
125
+    ADMIN_USERNAME=$(get_completion_param "Admin user")
126 126
     if [ $2 ]; then
127 127
         ADMIN_USERNAME=$2
128 128
     fi

+ 2
- 2
src/freedombone-utils-cmake View File

@@ -75,7 +75,7 @@ function install_cmake {
75 75
         fi
76 76
     fi
77 77
 
78
-    if grep -Fxq "install_cmake" $COMPLETION_FILE; then
78
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
79 79
         return
80 80
     fi
81 81
 
@@ -95,7 +95,7 @@ function install_cmake {
95 95
     fi
96 96
     make install
97 97
 
98
-    echo 'install_cmake' >> $COMPLETION_FILE
98
+    mark_completed $FUNCNAME
99 99
 }
100 100
 
101 101
 # NOTE: deliberately there is no "exit 0"

+ 85
- 0
src/freedombone-utils-config View File

@@ -99,6 +99,91 @@ configuration_variables=(FRIENDS_MIRRORS_SERVER
99 99
                          ENABLE_BATMAN
100 100
                          PUBLIC_MAILING_LIST)
101 101
 
102
+function get_completion_param {
103
+    param_name="$1"
104
+
105
+    if [ ${#param_name} -gt 0 ]; then
106
+        if [ $COMPLETION_FILE ]; then
107
+            if [ -f $COMPLETION_FILE ]; then
108
+                if grep -q "${param_name}:" $COMPLETION_FILE; then
109
+                    param_value=$(cat $COMPLETION_FILE | grep "${param_name}:" | head -n 1 | awk -F ':' '{print $2}')
110
+                    echo "$param_value"
111
+                    return
112
+                fi
113
+            fi
114
+        fi
115
+    fi
116
+    echo ""
117
+}
118
+
119
+function set_completion_param {
120
+    param_name="$1"
121
+    param_value="$2"
122
+
123
+    if [ ! $COMPLETION_FILE ]; then
124
+        COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
125
+    fi
126
+    if [ ${#COMPLETION_FILE} -eq 0 ]; then
127
+        COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
128
+    fi
129
+
130
+    if [ ${#param_name} -gt 0 ]; then
131
+        if [ ${#param_value} -gt 0 ]; then
132
+            if [ -f $COMPLETION_FILE ]; then
133
+                if grep -q "${param_name}:" $COMPLETION_FILE; then
134
+                    sed -i "s|${param_name}:.*|${param_name}:${param_value}|g" $COMPLETION_FILE
135
+                else
136
+                    echo "${param_name}:${param_value}" >> $COMPLETION_FILE
137
+                fi
138
+            else
139
+                echo "${param_name}:${param_value}" > $COMPLETION_FILE
140
+            fi
141
+        fi
142
+    fi
143
+}
144
+
145
+function mark_completed {
146
+    param_name="$1"
147
+
148
+    if [ ! $COMPLETION_FILE ]; then
149
+        COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
150
+    fi
151
+    if [ ${#COMPLETION_FILE} -eq 0 ]; then
152
+        COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
153
+    fi
154
+
155
+    if [ ${#param_name} -gt 0 ]; then
156
+        if [ -f $COMPLETION_FILE ]; then
157
+            if ! grep -Fxq "${param_name}" $COMPLETION_FILE; then
158
+                echo "${param_name}" >> $COMPLETION_FILE
159
+            fi
160
+        else
161
+            echo "${param_name}" > $COMPLETION_FILE
162
+        fi
163
+    fi
164
+}
165
+
166
+function is_completed {
167
+    param_name="$1"
168
+
169
+    if [ ! $COMPLETION_FILE ]; then
170
+        COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
171
+    fi
172
+    if [ ${#COMPLETION_FILE} -eq 0 ]; then
173
+        COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
174
+    fi
175
+
176
+    if [ ${#param_name} -gt 0 ]; then
177
+        if [ -f $COMPLETION_FILE ]; then
178
+            if grep -Fxq "${param_name}" $COMPLETION_FILE; then
179
+                echo "1"
180
+                return
181
+            fi
182
+        fi
183
+    fi
184
+    echo "0"
185
+}
186
+
102 187
 function read_config_param {
103 188
     param_name="$1"
104 189
 

+ 32
- 32
src/freedombone-utils-cron View File

@@ -29,48 +29,48 @@
29 29
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
30 30
 
31 31
 function cron_add_mins {
32
-	if ! grep -q "${2}" /etc/crontab; then
33
-		echo "*/${1}            * *   *   *   root ${2}" >> /etc/crontab
34
-		systemctl restart cron
35
-	fi
32
+    if ! grep -q "${2}" /etc/crontab; then
33
+        echo "*/${1}            * *   *   *   root ${2}" >> /etc/crontab
34
+        systemctl restart cron
35
+    fi
36 36
 }
37 37
 
38 38
 function randomize_cron {
39
-	# The predictable default timing of Debian cron jobs might
40
-	# be exploitable knowledge. Avoid too much predictability
41
-	# by randomizing the times when cron jobs run
42
-	if grep -Fxq "randomize_cron" $COMPLETION_FILE; then
43
-		return
44
-	fi
39
+    # The predictable default timing of Debian cron jobs might
40
+    # be exploitable knowledge. Avoid too much predictability
41
+    # by randomizing the times when cron jobs run
42
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
43
+        return
44
+    fi
45 45
 
46
-	# randomize the day on which the weekly cron job runs
47
-	randdow=$(($RANDOM%6+1))
48
-	sed -i "s|\* \* 7|* * $randdow|g" /etc/crontab
46
+    # randomize the day on which the weekly cron job runs
47
+    randdow=$(($RANDOM%6+1))
48
+    sed -i "s|\* \* 7|* * $randdow|g" /etc/crontab
49 49
 
50
-	# randomize the time when the weekly cron job runs
51
-	randmin=$(($RANDOM%60))
52
-	randhr=$(($RANDOM%3+1))
53
-	sed -i "s|47 6|$randmin $randhr|g" /etc/crontab
50
+    # randomize the time when the weekly cron job runs
51
+    randmin=$(($RANDOM%60))
52
+    randhr=$(($RANDOM%3+1))
53
+    sed -i "s|47 6|$randmin $randhr|g" /etc/crontab
54 54
 
55
-	# randomize the time when the daily cron job runs
56
-	randmin=$(($RANDOM%60))
57
-	randhr=$(($RANDOM%3+4))
58
-	sed -i "s|25 6\t\* \* \*|$randmin $randhr\t* * *|g" /etc/crontab
55
+    # randomize the time when the daily cron job runs
56
+    randmin=$(($RANDOM%60))
57
+    randhr=$(($RANDOM%3+4))
58
+    sed -i "s|25 6\t\* \* \*|$randmin $randhr\t* * *|g" /etc/crontab
59 59
 
60
-	# randomize the time when the hourly cron job runs
61
-	randmin=$(($RANDOM%60))
62
-	sed -i "s|17 \*\t|$randmin *\t|g" /etc/crontab
60
+    # randomize the time when the hourly cron job runs
61
+    randmin=$(($RANDOM%60))
62
+    sed -i "s|17 \*\t|$randmin *\t|g" /etc/crontab
63 63
 
64
-	# randomize monthly cron job time and day
65
-	randmin=$(($RANDOM%60))
66
-	randhr=$(($RANDOM%22+1))
67
-	randdom=$(($RANDOM%27+1))
68
-	sed -i "s|52 6\t|$randmin $randhr\t|g" /etc/crontab
69
-	sed -i "s|\t1 \* \*|\t$randdom * *|g" /etc/crontab
64
+    # randomize monthly cron job time and day
65
+    randmin=$(($RANDOM%60))
66
+    randhr=$(($RANDOM%22+1))
67
+    randdom=$(($RANDOM%27+1))
68
+    sed -i "s|52 6\t|$randmin $randhr\t|g" /etc/crontab
69
+    sed -i "s|\t1 \* \*|\t$randdom * *|g" /etc/crontab
70 70
 
71
-	systemctl restart cron
71
+    systemctl restart cron
72 72
 
73
-	echo 'randomize_cron' >> $COMPLETION_FILE
73
+    mark_completed $FUNCNAME
74 74
 }
75 75
 
76 76
 # NOTE: deliberately there is no "exit 0"

+ 2
- 2
src/freedombone-utils-cryptopp View File

@@ -76,7 +76,7 @@ function install_cryptopp {
76 76
         fi
77 77
     fi
78 78
 
79
-    if grep -Fxq "install_cryptopp" $COMPLETION_FILE; then
79
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
80 80
         return
81 81
     fi
82 82
 
@@ -98,7 +98,7 @@ function install_cryptopp {
98 98
     fi
99 99
     make install
100 100
 
101
-    echo 'install_cryptopp' >> $COMPLETION_FILE
101
+    mark_completed $FUNCNAME
102 102
 }
103 103
 
104 104
 # NOTE: deliberately there is no "exit 0"

+ 4
- 4
src/freedombone-utils-database View File

@@ -117,7 +117,7 @@ function get_mariadb_password {
117 117
 }
118 118
 
119 119
 function install_mariadb {
120
-    if grep -Fxq "install_mariadb" $COMPLETION_FILE; then
120
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
121 121
         return
122 122
     fi
123 123
     apt-get -y install python-software-properties debconf-utils
@@ -160,7 +160,7 @@ function install_mariadb {
160 160
     fi
161 161
 
162 162
     mysqladmin -u root password "$MARIADB_PASSWORD"
163
-    echo 'install_mariadb' >> $COMPLETION_FILE
163
+    mark_completed $FUNCNAME
164 164
 }
165 165
 
166 166
 function backup_databases_script_header {
@@ -209,7 +209,7 @@ function repair_databases_script {
209 209
         sed -i "s|/usr/bin/repairdatabase|${PROJECT_NAME}-repair-database|g" /etc/cron.hourly/repair
210 210
     fi
211 211
 
212
-    if grep -Fxq "repair_databases_script" $COMPLETION_FILE; then
212
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
213 213
         return
214 214
     fi
215 215
 
@@ -222,7 +222,7 @@ function repair_databases_script {
222 222
     chmod 600 /etc/cron.hourly/repair
223 223
     chmod +x /etc/cron.hourly/repair
224 224
 
225
-    echo 'repair_databases_script' >> $COMPLETION_FILE
225
+    mark_completed $FUNCNAME
226 226
 }
227 227
 
228 228
 function remove_database {

+ 6
- 6
src/freedombone-utils-dns View File

@@ -98,7 +98,7 @@ function create_freedns_updater {
98 98
     fi
99 99
 
100 100
     # currently inadyn doesn't work as expected with freeDNS, so this is a workaround
101
-    if grep -Fxq "create_freedns_updater" $COMPLETION_FILE; then
101
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
102 102
         return
103 103
     fi
104 104
     if [[ $DDNS_PROVIDER != *"freedns"* ]]; then
@@ -114,7 +114,7 @@ function create_freedns_updater {
114 114
         systemctl restart cron
115 115
     fi
116 116
 
117
-    echo 'create_freedns_updater' >> $COMPLETION_FILE
117
+    mark_completed $FUNCNAME
118 118
 }
119 119
 
120 120
 function add_ddns_domain {
@@ -152,7 +152,7 @@ function add_ddns_domain {
152 152
 }
153 153
 
154 154
 function configure_dns {
155
-    if grep -Fxq "configure_dns" $COMPLETION_FILE; then
155
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
156 156
         return
157 157
     fi
158 158
     echo 'domain localdomain' > /etc/resolv.conf
@@ -163,7 +163,7 @@ function configure_dns {
163 163
     # prevent resolv.conf from changing
164 164
     chattr +i /etc/resolv.conf
165 165
 
166
-    echo 'configure_dns' >> $COMPLETION_FILE
166
+    mark_completed $FUNCNAME
167 167
 }
168 168
 
169 169
 function set_hostname {
@@ -180,14 +180,14 @@ function set_hostname {
180 180
 }
181 181
 
182 182
 function set_your_domain_name {
183
-    if grep -Fxq "set_your_domain_name" $COMPLETION_FILE; then
183
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
184 184
         return
185 185
     fi
186 186
 
187 187
     function_check set_hostname
188 188
     set_hostname $DEFAULT_DOMAIN_NAME
189 189
 
190
-    echo 'set_your_domain_name' >> $COMPLETION_FILE
190
+    mark_completed $FUNCNAME
191 191
 }
192 192
 
193 193
 # NOTE: deliberately no exit 0

+ 3
- 7
src/freedombone-utils-filesystem View File

@@ -62,7 +62,7 @@ function install_tomb {
62 62
     set_repo_commit $INSTALL_DIR/tomb "tomb commit" "$TOMB_COMMIT" $TOMB_REPO
63 63
 
64 64
     if [ -f $COMPLETION_FILE ]; then
65
-        if grep -Fxq "install_tomb" $COMPLETION_FILE; then
65
+        if [[ $(is_completed $FUNCNAME) == "1" ]]; then
66 66
             return
67 67
         fi
68 68
     fi
@@ -77,18 +77,14 @@ function install_tomb {
77 77
     cd $INSTALL_DIR/tomb
78 78
 
79 79
     git checkout $TOMB_COMMIT -b $TOMB_COMMIT
80
-    if ! grep -q "tomb commit" $COMPLETION_FILE; then
81
-        echo "tomb commit:$TOMB_COMMIT" >> $COMPLETION_FILE
82
-    else
83
-        sed -i "s/tomb commit.*/tomb commit:$TOMB_COMMIT/g" $COMPLETION_FILE
84
-    fi
80
+    set_completion_param "tomb commit" "$TOMB_COMMIT"
85 81
 
86 82
     make install
87 83
     if [ ! -f /usr/local/bin/tomb ]; then
88 84
         exit 93462
89 85
     fi
90 86
 
91
-    echo 'install_tomb' >> $COMPLETION_FILE
87
+    mark_completed $FUNCNAME
92 88
 }
93 89
 
94 90
 # NOTE: deliberately no exit 0

+ 2
- 2
src/freedombone-utils-final View File

@@ -31,7 +31,7 @@
31 31
 OPEN_PORTS=()
32 32
 
33 33
 function install_final {
34
-    if grep -Fxq "install_final" $COMPLETION_FILE; then
34
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
35 35
         return
36 36
     fi
37 37
     # unmount any attached usb drive
@@ -41,7 +41,7 @@ function install_final {
41 41
     fi
42 42
     function_check split_gpg_key_into_fragments
43 43
     split_gpg_key_into_fragments
44
-    echo 'install_final' >> $COMPLETION_FILE
44
+    mark_completed $FUNCNAME
45 45
     clear
46 46
     echo ''
47 47
 

+ 17
- 17
src/freedombone-utils-firewall View File

@@ -64,7 +64,7 @@ function configure_firewall {
64 64
         # recreate the firewall to remove RELATED
65 65
         sed -i "/firewall/d" $COMPLETION_FILE
66 66
     fi
67
-    if grep -Fxq "configure_firewall" $COMPLETION_FILE; then
67
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
68 68
         return
69 69
     fi
70 70
     if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
@@ -98,7 +98,7 @@ function configure_firewall {
98 98
     # Incoming malformed NULL packets:
99 99
     iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
100 100
 
101
-    echo 'configure_firewall' >> $COMPLETION_FILE
101
+    mark_completed $FUNCNAME
102 102
 }
103 103
 
104 104
 function configure_firewall_ping {
@@ -113,11 +113,11 @@ function configure_firewall_ping {
113 113
     iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT
114 114
     function_check save_firewall_settings
115 115
     save_firewall_settings
116
-    echo 'configure_firewall_ping' >> $COMPLETION_FILE
116
+    mark_completed $FUNCNAME
117 117
 }
118 118
 
119 119
 function configure_firewall_for_avahi {
120
-    if grep -Fxq "configure_firewall_for_avahi" $COMPLETION_FILE; then
120
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
121 121
         return
122 122
     fi
123 123
     iptables -A INPUT -p tcp --dport 548 -j ACCEPT
@@ -128,11 +128,11 @@ function configure_firewall_for_avahi {
128 128
     iptables -A INPUT -p udp --dport 5354 -j ACCEPT
129 129
     function_check save_firewall_settings
130 130
     save_firewall_settings
131
-    echo 'configure_firewall_for_avahi' >> $COMPLETION_FILE
131
+    mark_completed $FUNCNAME
132 132
 }
133 133
 
134 134
 function configure_firewall_for_dns {
135
-    if grep -Fxq "configure_firewall_for_dns" $COMPLETION_FILE; then
135
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
136 136
         return
137 137
     fi
138 138
     if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
@@ -142,11 +142,11 @@ function configure_firewall_for_dns {
142 142
     iptables -A INPUT -p udp -m udp --dport 1024:65535 --sport 53 -j ACCEPT
143 143
     function_check save_firewall_settings
144 144
     save_firewall_settings
145
-    echo 'configure_firewall_for_dns' >> $COMPLETION_FILE
145
+    mark_completed $FUNCNAME
146 146
 }
147 147
 
148 148
 function configure_firewall_for_web_access {
149
-    if grep -Fxq "configure_firewall_for_web_access" $COMPLETION_FILE; then
149
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
150 150
         return
151 151
     fi
152 152
     if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
@@ -161,11 +161,11 @@ function configure_firewall_for_web_access {
161 161
     function_check save_firewall_settings
162 162
     save_firewall_settings
163 163
 
164
-    echo 'configure_firewall_for_web_access' >> $COMPLETION_FILE
164
+    mark_completed $FUNCNAME
165 165
 }
166 166
 
167 167
 function configure_firewall_for_web_server {
168
-    if grep -Fxq "configure_firewall_for_web_server" $COMPLETION_FILE; then
168
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
169 169
         return
170 170
     fi
171 171
     if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
@@ -182,11 +182,11 @@ function configure_firewall_for_web_server {
182 182
 
183 183
     OPEN_PORTS+=('HTTP     80')
184 184
     OPEN_PORTS+=('HTTPS    443')
185
-    echo 'configure_firewall_for_web_server' >> $COMPLETION_FILE
185
+    mark_completed $FUNCNAME
186 186
 }
187 187
 
188 188
 function configure_firewall_for_ssh {
189
-    if grep -Fxq "configure_firewall_for_ssh" $COMPLETION_FILE; then
189
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
190 190
         return
191 191
     fi
192 192
     if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
@@ -199,11 +199,11 @@ function configure_firewall_for_ssh {
199 199
     save_firewall_settings
200 200
 
201 201
     OPEN_PORTS+=("SSH      $SSH_PORT")
202
-    echo 'configure_firewall_for_ssh' >> $COMPLETION_FILE
202
+    mark_completed $FUNCNAME
203 203
 }
204 204
 
205 205
 function configure_firewall_for_git {
206
-    if grep -Fxq "configure_firewall_for_git" $COMPLETION_FILE; then
206
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
207 207
         return
208 208
     fi
209 209
     if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
@@ -218,11 +218,11 @@ function configure_firewall_for_git {
218 218
     save_firewall_settings
219 219
 
220 220
     OPEN_PORTS+=("Git      9418")
221
-    echo 'configure_firewall_for_git' >> $COMPLETION_FILE
221
+    mark_completed $FUNCNAME
222 222
 }
223 223
 
224 224
 function configure_internet_protocol {
225
-    if grep -Fxq "configure_internet_protocol" $COMPLETION_FILE; then
225
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
226 226
         return
227 227
     fi
228 228
     if [[ $SYSTEM_TYPE == "mesh"* ]]; then
@@ -257,7 +257,7 @@ function configure_internet_protocol {
257 257
         echo 'net.ipv4.tcp_keepalive_intvl = 75' >> /etc/sysctl.conf
258 258
         echo 'net.ipv4.tcp_keepalive_time = 7200' >> /etc/sysctl.conf
259 259
     fi
260
-    echo 'configure_internet_protocol' >> $COMPLETION_FILE
260
+    mark_completed $FUNCNAME
261 261
 }
262 262
 
263 263
 function mesh_firewall {

+ 3
- 6
src/freedombone-utils-git View File

@@ -90,7 +90,7 @@ function commit_has_changed {
90 90
     repo_commit=$3
91 91
     if [ -d $repo_dir ]; then
92 92
         if grep -q "$repo_commit_name" $COMPLETION_FILE; then
93
-            CURRENT_REPO_COMMIT=$(grep "$repo_commit_name" $COMPLETION_FILE | awk -F ':' '{print $2}')
93
+            CURRENT_REPO_COMMIT=$(get_completion_param "$repo_commit_name")
94 94
             if [[ "$CURRENT_REPO_COMMIT" != "$repo_commit" ]]; then
95 95
                 echo "1"
96 96
             fi
@@ -131,11 +131,8 @@ function set_repo_commit {
131 131
             systemctl restart inadyn
132 132
         fi
133 133
 
134
-        if ! grep -q "${repo_commit_name}:" $COMPLETION_FILE; then
135
-            echo "${repo_commit_name}:${repo_commit}" >> $COMPLETION_FILE
136
-        else
137
-            sed -i "s/${repo_commit_name}.*/${repo_commit_name}:$repo_commit/g" $COMPLETION_FILE
138
-        fi
134
+        function_check set_completion_param
135
+        set_completion_param "${repo_commit_name}" "${repo_commit}"
139 136
     fi
140 137
 }
141 138
 

+ 1
- 1
src/freedombone-utils-go View File

@@ -207,7 +207,7 @@ function upgrade_golang {
207 207
         systemctl restart gogs
208 208
     fi
209 209
 
210
-    echo "upgrade_golang:$GO_VERSION" >> $COMPLETION_FILE
210
+    set_completion_param "$FUNCNAME" "$GO_VERSION"
211 211
 }
212 212
 
213 213
 # NOTE: deliberately there is no "exit 0"

+ 2
- 2
src/freedombone-utils-international View File

@@ -29,7 +29,7 @@
29 29
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
30 30
 
31 31
 function locale_setup {
32
-    if grep -Fxq "locale_setup" $COMPLETION_FILE; then
32
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
33 33
         return
34 34
     fi
35 35
 
@@ -49,7 +49,7 @@ function locale_setup {
49 49
     update-locale LC_ALL=${DEFAULT_LANGUAGE}
50 50
     update-locale LC_CTYPE=${DEFAULT_LANGUAGE}
51 51
 
52
-    echo 'locale_setup' >> $COMPLETION_FILE
52
+    mark_completed $FUNCNAME
53 53
 }
54 54
 
55 55
 # NOTE: deliberately no exit 0

+ 2
- 2
src/freedombone-utils-login View File

@@ -29,7 +29,7 @@
29 29
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
30 30
 
31 31
 function change_login_message {
32
-    if grep -Fxq "change_login_message" $COMPLETION_FILE; then
32
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
33 33
         return
34 34
     fi
35 35
 
@@ -46,7 +46,7 @@ function change_login_message {
46 46
     echo "'    '     --'  --'  -' -  -' '  '   -' -'   -' '   -  --'" >> /etc/motd
47 47
     echo $'                  Freedom in the Cloud' >> /etc/motd
48 48
     echo '' >> /etc/motd
49
-    echo 'change_login_message' >> $COMPLETION_FILE
49
+    mark_completed $FUNCNAME
50 50
 }
51 51
 
52 52
 # NOTE: deliberately no exit 0

+ 29
- 29
src/freedombone-utils-monkeysphere View File

@@ -29,38 +29,38 @@
29 29
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
30 30
 
31 31
 function install_monkeysphere {
32
-	if grep -Fxq "install_monkeysphere" $COMPLETION_FILE; then
33
-		return
34
-	fi
35
-	apt-get -y install monkeysphere msva-perl
36
-	#su -c "monkeysphere gen-subkey $MY_GPG_PUBLIC_KEY_ID" - $MY_USERNAME
37
-	mkdir /home/$MY_USERNAME/.monkeysphere
38
-	chmod 755 /home/$MY_USERNAME/.monkeysphere
39
-	echo "$MY_NAME <${MY_EMAIL_ADDRESS}>" > /home/$MY_USERNAME/.monkeysphere/authorized_user_ids
40
-	chmod 644 /home/$MY_USERNAME/.monkeysphere/authorized_user_ids
41
-	chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.monkeysphere
42
-	monkeysphere-authentication update-users
32
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
33
+        return
34
+    fi
35
+    apt-get -y install monkeysphere msva-perl
36
+    #su -c "monkeysphere gen-subkey $MY_GPG_PUBLIC_KEY_ID" - $MY_USERNAME
37
+    mkdir /home/$MY_USERNAME/.monkeysphere
38
+    chmod 755 /home/$MY_USERNAME/.monkeysphere
39
+    echo "$MY_NAME <${MY_EMAIL_ADDRESS}>" > /home/$MY_USERNAME/.monkeysphere/authorized_user_ids
40
+    chmod 644 /home/$MY_USERNAME/.monkeysphere/authorized_user_ids
41
+    chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.monkeysphere
42
+    monkeysphere-authentication update-users
43 43
 
44
-	if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
45
-		echo $'monkeysphere import: ssh host key not found'
46
-		exit 76295
47
-	fi
48
-	monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key ssh://$DEFAULT_DOMAIN_NAME
49
-	SSH_ONION_HOSTNAME=$(cat ${COMPLETION_FILE} | grep 'ssh onion domain' | awk -F ':' '{print $2}')
50
-	monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key ssh://$SSH_ONION_HOSTNAME
44
+    if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
45
+        echo $'monkeysphere import: ssh host key not found'
46
+        exit 76295
47
+    fi
48
+    monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key ssh://$DEFAULT_DOMAIN_NAME
49
+    SSH_ONION_HOSTNAME=$(cat ${COMPLETION_FILE} | grep 'ssh onion domain' | awk -F ':' '{print $2}')
50
+    monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key ssh://$SSH_ONION_HOSTNAME
51 51
 
52
-	if [ ! $MY_GPG_PUBLIC_KEY_ID ]; then
53
-		MY_GPG_PUBLIC_KEY_ID=$(gpg_pubkey_from_email "$MY_USERNAME" "$MY_USERNAME@$HOSTNAME")
54
-		if [ ${#MY_GPG_PUBLIC_KEY_ID} -lt 4 ]; then
55
-			echo $'monkeysphere unable to get GPG key ID for user $MY_USERNAME'
56
-			exit 52825
57
-		fi
58
-	fi
59
-	# The admin user is the identity certifier
60
-	fpr=$(gpg --with-colons --fingerprint $MY_GPG_PUBLIC_KEY_ID | grep fpr | head -n 1 | awk -F ':' '{print $10}')
61
-	monkeysphere-authentication add-identity-certifier $fpr
52
+    if [ ! $MY_GPG_PUBLIC_KEY_ID ]; then
53
+        MY_GPG_PUBLIC_KEY_ID=$(gpg_pubkey_from_email "$MY_USERNAME" "$MY_USERNAME@$HOSTNAME")
54
+        if [ ${#MY_GPG_PUBLIC_KEY_ID} -lt 4 ]; then
55
+            echo $'monkeysphere unable to get GPG key ID for user $MY_USERNAME'
56
+            exit 52825
57
+        fi
58
+    fi
59
+    # The admin user is the identity certifier
60
+    fpr=$(gpg --with-colons --fingerprint $MY_GPG_PUBLIC_KEY_ID | grep fpr | head -n 1 | awk -F ':' '{print $10}')
61
+    monkeysphere-authentication add-identity-certifier $fpr
62 62
 
63
-	echo 'install_monkeysphere' >> $COMPLETION_FILE
63
+    mark_completed $FUNCNAME
64 64
 }
65 65
 
66 66
 # NOTE: deliberately no exit 0

+ 42
- 42
src/freedombone-utils-network View File

@@ -41,50 +41,50 @@ ROUTER_IP_ADDRESS="192.168.1.254"
41 41
 MESH_INSTALL_DIR=/var/lib
42 42
 
43 43
 function install_static_network {
44
-	if grep -Fxq "install_static_network" $COMPLETION_FILE; then
45
-		return
46
-	fi
47
-	if [[ $INSTALLING_ON_BBB == "yes" ]]; then
48
-		return
49
-	fi
50
-	if [ ! $LOCAL_NETWORK_STATIC_IP_ADDRESS ]; then
51
-		return
52
-	fi
44
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
45
+        return
46
+    fi
47
+    if [[ $INSTALLING_ON_BBB == "yes" ]]; then
48
+        return
49
+    fi
50
+    if [ ! $LOCAL_NETWORK_STATIC_IP_ADDRESS ]; then
51
+        return
52
+    fi
53 53
 
54
-	echo '# The loopback network interface' > /etc/network/interfaces
55
-	echo 'auto lo' >> /etc/network/interfaces
56
-	echo 'iface lo inet loopback' >> /etc/network/interfaces
57
-	echo '' >> /etc/network/interfaces
58
-	echo '# The primary network interface' >> /etc/network/interfaces
59
-	echo 'auto eth0' >> /etc/network/interfaces
60
-	echo 'iface eth0 inet static' >> /etc/network/interfaces
61
-	echo "    address $LOCAL_NETWORK_STATIC_IP_ADDRESS" >> /etc/network/interfaces
62
-	echo '    netmask 255.255.255.0' >> /etc/network/interfaces
63
-	echo "    gateway $ROUTER_IP_ADDRESS" >> /etc/network/interfaces
64
-	echo "    dns-nameservers $NAMESERVER1 $NAMESERVER2" >> /etc/network/interfaces
65
-	echo '# Example to keep MAC address between reboots' >> /etc/network/interfaces
66
-	echo '#hwaddress ether DE:AD:BE:EF:CA:FE' >> /etc/network/interfaces
67
-	echo '' >> /etc/network/interfaces
68
-	echo '# The secondary network interface' >> /etc/network/interfaces
69
-	echo '#auto eth1' >> /etc/network/interfaces
70
-	echo '#iface eth1 inet dhcp' >> /etc/network/interfaces
71
-	echo '' >> /etc/network/interfaces
72
-	echo '# WiFi Example' >> /etc/network/interfaces
73
-	echo "#auto $WIFI_INTERFACE" >> /etc/network/interfaces
74
-	echo "#iface $WIFI_INTERFACE inet dhcp" >> /etc/network/interfaces
75
-	echo '#    wpa-ssid "essid"' >> /etc/network/interfaces
76
-	echo '#    wpa-psk  "password"' >> /etc/network/interfaces
77
-	echo '' >> /etc/network/interfaces
78
-	echo '# Ethernet/RNDIS gadget (g_ether)' >> /etc/network/interfaces
79
-	echo '# ... or on host side, usbnet and random hwaddr' >> /etc/network/interfaces
80
-	echo '# Note on some boards, usb0 is automaticly setup with an init script' >> /etc/network/interfaces
81
-	echo '#iface usb0 inet static' >> /etc/network/interfaces
82
-	echo '#    address 192.168.7.2' >> /etc/network/interfaces
83
-	echo '#    netmask 255.255.255.0' >> /etc/network/interfaces
84
-	echo '#    network 192.168.7.0' >> /etc/network/interfaces
85
-	echo '#    gateway 192.168.7.1' >> /etc/network/interfaces
54
+    echo '# The loopback network interface' > /etc/network/interfaces
55
+    echo 'auto lo' >> /etc/network/interfaces
56
+    echo 'iface lo inet loopback' >> /etc/network/interfaces
57
+    echo '' >> /etc/network/interfaces
58
+    echo '# The primary network interface' >> /etc/network/interfaces
59
+    echo 'auto eth0' >> /etc/network/interfaces
60
+    echo 'iface eth0 inet static' >> /etc/network/interfaces
61
+    echo "    address $LOCAL_NETWORK_STATIC_IP_ADDRESS" >> /etc/network/interfaces
62
+    echo '    netmask 255.255.255.0' >> /etc/network/interfaces
63
+    echo "    gateway $ROUTER_IP_ADDRESS" >> /etc/network/interfaces
64
+    echo "    dns-nameservers $NAMESERVER1 $NAMESERVER2" >> /etc/network/interfaces
65
+    echo '# Example to keep MAC address between reboots' >> /etc/network/interfaces
66
+    echo '#hwaddress ether DE:AD:BE:EF:CA:FE' >> /etc/network/interfaces
67
+    echo '' >> /etc/network/interfaces
68
+    echo '# The secondary network interface' >> /etc/network/interfaces
69
+    echo '#auto eth1' >> /etc/network/interfaces
70
+    echo '#iface eth1 inet dhcp' >> /etc/network/interfaces
71
+    echo '' >> /etc/network/interfaces
72
+    echo '# WiFi Example' >> /etc/network/interfaces
73
+    echo "#auto $WIFI_INTERFACE" >> /etc/network/interfaces
74
+    echo "#iface $WIFI_INTERFACE inet dhcp" >> /etc/network/interfaces
75
+    echo '#    wpa-ssid "essid"' >> /etc/network/interfaces
76
+    echo '#    wpa-psk  "password"' >> /etc/network/interfaces
77
+    echo '' >> /etc/network/interfaces
78
+    echo '# Ethernet/RNDIS gadget (g_ether)' >> /etc/network/interfaces
79
+    echo '# ... or on host side, usbnet and random hwaddr' >> /etc/network/interfaces
80
+    echo '# Note on some boards, usb0 is automaticly setup with an init script' >> /etc/network/interfaces
81
+    echo '#iface usb0 inet static' >> /etc/network/interfaces
82
+    echo '#    address 192.168.7.2' >> /etc/network/interfaces
83
+    echo '#    netmask 255.255.255.0' >> /etc/network/interfaces
84
+    echo '#    network 192.168.7.0' >> /etc/network/interfaces
85
+    echo '#    gateway 192.168.7.1' >> /etc/network/interfaces
86 86
 
87
-	echo 'install_static_network' >> $COMPLETION_FILE
87
+    mark_completed $FUNCNAME
88 88
 }
89 89
 
90 90
 # NOTE: deliberately no exit 0

+ 2
- 2
src/freedombone-utils-nodejs View File

@@ -70,7 +70,7 @@ function install_nodejs {
70 70
         mesh_install_nodejs
71 71
         return
72 72
     fi
73
-    if grep -Fxq "install_nodejs" $COMPLETION_FILE; then
73
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
74 74
         return
75 75
     fi
76 76
 
@@ -101,7 +101,7 @@ EOF
101 101
     fi
102 102
     rm -f /root/install-nodejs.sh
103 103
 
104
-    echo 'install_nodejs' >> $COMPLETION_FILE
104
+    mark_completed $FUNCNAME
105 105
 }
106 106
 
107 107
 # NOTE: deliberately there is no "exit 0"

+ 12
- 22
src/freedombone-utils-onion View File

@@ -107,13 +107,7 @@ function add_onion_service {
107 107
     onion_address=$(cat /var/lib/tor/hidden_service_${onion_service_name}/hostname)
108 108
 
109 109
     # Record the domain in the completion file
110
-    if [ -f $COMPLETION_FILE ]; then
111
-        if ! grep "${onion_service_name} onion domain" $COMPLETION_FILE; then
112
-            echo "${onion_service_name} onion domain:${onion_address}" >> $COMPLETION_FILE
113
-        else
114
-            sed -i "s|${onion_service_name} onion domain.*|${onion_service_name} onion domain:${onion_address}|g" $COMPLETION_FILE
115
-        fi
116
-    fi
110
+    set_completion_param "${onion_service_name} onion domain" "${onion_address}"
117 111
 
118 112
     echo $onion_address
119 113
 }
@@ -179,7 +173,7 @@ function enable_ssh_via_onion {
179 173
     if [[ $SYSTEM_TYPE == "mesh"* ]]; then
180 174
         return
181 175
     fi
182
-    if grep -Fxq "enable_ssh_via_onion" $COMPLETION_FILE; then
176
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
183 177
         return
184 178
     fi
185 179
     apt-get -y install tor connect-proxy
@@ -199,11 +193,11 @@ function enable_ssh_via_onion {
199 193
         echo 'Host *.onion' >> /root/.ssh/config
200 194
         echo 'ProxyCommand connect -R remote -5 -S 127.0.0.1:9050 %h %p' >> /root/.ssh/config
201 195
     fi
202
-    echo 'enable_ssh_via_onion' >> $COMPLETION_FILE
196
+    mark_completed $FUNCNAME
203 197
 }
204 198
 
205 199
 function configure_ssh_onion {
206
-    if grep -Fxq "configure_ssh_onion" $COMPLETION_FILE; then
200
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
207 201
         return
208 202
     fi
209 203
     if [[ $SYSTEM_TYPE == "mesh"* ]]; then
@@ -212,20 +206,16 @@ function configure_ssh_onion {
212 206
 
213 207
     SSH_ONION_HOSTNAME=$(add_onion_service ssh ${SSH_PORT} ${SSH_PORT})
214 208
 
215
-    if ! grep -q "ssh onion domain" $COMPLETION_FILE; then
216
-        echo "ssh onion domain:${SSH_ONION_HOSTNAME}" >> $COMPLETION_FILE
217
-    else
218
-        sed -i "s|ssh onion domain.*|ssh onion domain:${SSH_ONION_HOSTNAME}|g" $COMPLETION_FILE
219
-    fi
209
+    set_completion_param "ssh onion domain" "${SSH_ONION_HOSTNAME}"
220 210
 
221
-    echo 'configure_ssh_onion' >> $COMPLETION_FILE
211
+    mark_completed $FUNCNAME
222 212
 }
223 213
 
224 214
 function install_tor {
225 215
     if [[ $SYSTEM_TYPE == "mesh*" ]]; then
226 216
         return
227 217
     fi
228
-    if grep -Fxq "install_tor" $COMPLETION_FILE; then
218
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
229 219
         return
230 220
     fi
231 221
     apt-get -y install tor
@@ -233,14 +223,14 @@ function install_tor {
233 223
         echo 'Tor failed to install'
234 224
         exit 38259
235 225
     fi
236
-    echo 'install_tor' >> $COMPLETION_FILE
226
+    mark_completed $FUNCNAME
237 227
 }
238 228
 
239 229
 function resolve_dns_via_tor {
240 230
     if [[ $SYSTEM_TYPE == "mesh"* ]]; then
241 231
         return
242 232
     fi
243
-    if grep -Fxq "resolve_dns_via_tor" $COMPLETION_FILE; then
233
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
244 234
         return
245 235
     fi
246 236
     if [ ! -f /etc/tor/torrc ]; then
@@ -265,13 +255,13 @@ function resolve_dns_via_tor {
265 255
     # prevent resolv.conf from changing
266 256
     chattr +i /etc/resolv.conf
267 257
 
268
-    echo 'resolve_dns_via_tor' >> $COMPLETION_FILE
258
+    mark_completed $FUNCNAME
269 259
 }
270 260
 
271 261
 # see https://trac.torproject.org/projects/tor/wiki/doc/TransparentProxy
272 262
 # Local Redirection and Anonymizing Middlebox
273 263
 function route_outgoing_traffic_through_tor {
274
-    if grep -Fxq "route_outgoing_traffic_through_tor" $COMPLETION_FILE; then
264
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
275 265
         return
276 266
     fi
277 267
     if [[ $ROUTE_THROUGH_TOR != "yes" ]]; then
@@ -364,7 +354,7 @@ function route_outgoing_traffic_through_tor {
364 354
         echo "DNSListenAddress $LOCAL_NETWORK_STATIC_IP_ADDRESS" >> /etc/tor/torrc
365 355
     fi
366 356
 
367
-    echo 'route_outgoing_traffic_through_tor' >> $COMPLETION_FILE
357
+    mark_completed $FUNCNAME
368 358
 }
369 359
 
370 360
 # NOTE: deliberately no exit 0

+ 2
- 2
src/freedombone-utils-passwords View File

@@ -41,13 +41,13 @@ DEFAULT_PASSWORD_LENGTH=20
41 41
 
42 42
 function enforce_good_passwords {
43 43
     # because humans are generally bad at choosing passwords
44
-    if grep -Fxq "enforce_good_passwords" $COMPLETION_FILE; then
44
+    if [[ $(is_completd $FUNCNAME) == "1" ]]; then
45 45
         return
46 46
     fi
47 47
     apt-get -y install libpam-cracklib
48 48
 
49 49
     sed -i 's/password.*requisite.*pam_cracklib.so.*/password        required                       pam_cracklib.so retry=2 dcredit=-4 ucredit=-1 ocredit=-1 lcredit=0 minlen=10 reject_username/g' /etc/pam.d/common-password
50
-    echo 'enforce_good_passwords' >> $COMPLETION_FILE
50
+    mark_completed $FUNCNAME
51 51
 }
52 52
 
53 53
 function create_password {

+ 6
- 6
src/freedombone-utils-repos View File

@@ -39,7 +39,7 @@ FRIENDS_MIRRORS_SERVER=
39 39
 FRIENDS_MIRRORS_SSH_PORT=2222
40 40
 
41 41
 function create_repo_sources {
42
-    if grep -Fxq "create_repo_sources" $COMPLETION_FILE; then
42
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
43 43
         return
44 44
     fi
45 45
     rm -rf /var/lib/apt/lists/*
@@ -60,7 +60,7 @@ function create_repo_sources {
60 60
     apt-get update
61 61
     apt-get -y install apt-transport-https
62 62
 
63
-    echo 'create_repo_sources' >> $COMPLETION_FILE
63
+    mark_completed $FUNCNAME
64 64
 }
65 65
 
66 66
 function read_repo_servers {
@@ -105,7 +105,7 @@ function read_repo_servers {
105 105
 
106 106
 # A command to create a git repository for a project
107 107
 function create_git_project {
108
-    if grep -Fxq "create_git_project" $COMPLETION_FILE; then
108
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
109 109
         return
110 110
     fi
111 111
     apt-get -y install git
@@ -133,18 +133,18 @@ function create_git_project {
133 133
     echo 'exit 0' >> /usr/bin/$CREATE_GIT_PROJECT_COMMAND
134 134
     chmod +x /usr/bin/$CREATE_GIT_PROJECT_COMMAND
135 135
 
136
-    echo 'create_git_project' >> $COMPLETION_FILE
136
+    mark_completed $FUNCNAME
137 137
 }
138 138
 
139 139
 function create_mirrors {
140 140
     if [ -d /home/trove ]; then
141 141
         userdel -r trove
142 142
     fi
143
-    if grep -Fxq "create_mirrors" $COMPLETION_FILE; then
143
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
144 144
         return
145 145
     fi
146 146
     ${PROJECT_NAME}-mirrors
147
-    echo 'create_mirrors' >> $COMPLETION_FILE
147
+    mark_completed $FUNCNAME
148 148
 }
149 149
 
150 150
 # NOTE: deliberately no exit 0

+ 111
- 111
src/freedombone-utils-rng View File

@@ -42,126 +42,126 @@ ONERNG_PACKAGE_HASH='78f1c2f52ae573e3b398a695ece7ab9f41868252657ea269f0d5cf0bd4f
42 42
 ONERNG_DEVICE='ttyACM0'
43 43
 
44 44
 function check_hwrng {
45
-	if [[ $HWRNG_TYPE == "beaglebone" ]]; then
46
-		# If hardware random number generation was enabled then make sure that the device exists.
47
-		# if /dev/hwrng is not found then any subsequent cryptographic key generation would
48
-		# suffer from low entropy and might be insecure
49
-		if [ ! -e /dev/hwrng ]; then
50
-			ls /dev/hw*
51
-			echo $'The hardware random number generator is enabled but could not be detected on'
52
-			echo $'/dev/hwrng.  There may be a problem with the installation or the Beaglebone hardware.'
53
-			exit 75
54
-		fi
55
-	fi
56
-
57
-	# If a OneRNG device was installed then verify its firmware
58
-	#check_onerng_verification
45
+    if [[ $HWRNG_TYPE == "beaglebone" ]]; then
46
+        # If hardware random number generation was enabled then make sure that the device exists.
47
+        # if /dev/hwrng is not found then any subsequent cryptographic key generation would
48
+        # suffer from low entropy and might be insecure
49
+        if [ ! -e /dev/hwrng ]; then
50
+            ls /dev/hw*
51
+            echo $'The hardware random number generator is enabled but could not be detected on'
52
+            echo $'/dev/hwrng.  There may be a problem with the installation or the Beaglebone hardware.'
53
+            exit 75
54
+        fi
55
+    fi
56
+
57
+    # If a OneRNG device was installed then verify its firmware
58
+    #check_onerng_verification
59 59
 }
60 60
 
61 61
 function check_onerng_verification {
62
-	if grep -Fxq "check_onerng_verification" $COMPLETION_FILE; then
63
-		return
64
-	fi
65
-	if [[ $HWRNG_TYPE != "onerng" ]]; then
66
-		return
67
-	fi
68
-	echo $'Checking OneRNG firmware verification'
69
-	last_onerng_validation=$(cat /var/log/syslog.1 | grep "OneRNG: firmware verification" | awk '/./{line=$0} END{print line}')
70
-	if [[ $last_onerng_validation != *"passed OK"* ]]; then
71
-		last_onerng_validation=$(cat /var/log/syslog | grep "OneRNG: firmware verification" | awk '/./{line=$0} END{print line}')
72
-		if [[ $last_onerng_validation != *"passed OK"* ]]; then
73
-			echo $last_onerng_validation
74
-			echo $'OneRNG firmware verification failed'
75
-			exit 735026
76
-		fi
77
-	fi
78
-	echo $'OneRNG firmware verification passed'
79
-	# if haveged was previously installed then remove it
80
-	apt-get -y remove haveged
81
-	echo 'check_onerng_verification' >> $COMPLETION_FILE
62
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
63
+        return
64
+    fi
65
+    if [[ $HWRNG_TYPE != "onerng" ]]; then
66
+        return
67
+    fi
68
+    echo $'Checking OneRNG firmware verification'
69
+    last_onerng_validation=$(cat /var/log/syslog.1 | grep "OneRNG: firmware verification" | awk '/./{line=$0} END{print line}')
70
+    if [[ $last_onerng_validation != *"passed OK"* ]]; then
71
+        last_onerng_validation=$(cat /var/log/syslog | grep "OneRNG: firmware verification" | awk '/./{line=$0} END{print line}')
72
+        if [[ $last_onerng_validation != *"passed OK"* ]]; then
73
+            echo $last_onerng_validation
74
+            echo $'OneRNG firmware verification failed'
75
+            exit 735026
76
+        fi
77
+    fi
78
+    echo $'OneRNG firmware verification passed'
79
+    # if haveged was previously installed then remove it
80
+    apt-get -y remove haveged
81
+    mark_completed $FUNCNAME
82 82
 }
83 83
 
84 84
 function install_onerng {
85
-	apt-get -y install rng-tools at python-gnupg
86
-
87
-	# Move to the installation directory
88
-	if [ ! -d $INSTALL_DIR ]; then
89
-		mkdir $INSTALL_DIR
90
-	fi
91
-	cd $INSTALL_DIR
92
-
93
-	# Download the package
94
-	if [ ! -f $ONERNG_PACKAGE ]; then
95
-		wget $ONERNG_PACKAGE_DOWNLOAD
96
-		mv "$ONERNG_PACKAGE?raw=true" $ONERNG_PACKAGE
97
-	fi
98
-	if [ ! -f $ONERNG_PACKAGE ]; then
99
-		echo $"OneRNG package could not be downloaded"
100
-		exit 59249
101
-	fi
102
-
103
-	# Check the hash
104
-	hash=$(sha256sum $ONERNG_PACKAGE | awk -F ' ' '{print $1}')
105
-	if [[ $hash != $ONERNG_PACKAGE_HASH ]]; then
106
-		echo $"OneRNG package: $ONERNG_PACKAGE"
107
-		echo $"Hash does not match. This could indicate that the package has been tampered with."
108
-		echo $"OneRNG expected package hash: $ONERNG_PACKAGE_HASH"
109
-		echo $"OneRNG actual hash: $hash"
110
-		exit 25934
111
-	fi
112
-
113
-	# install the package
114
-	dpkg -i $ONERNG_PACKAGE
115
-
116
-	# Check that the install worked
117
-	if [ ! -f /etc/onerng.conf ]; then
118
-		echo $'OneRNG configuration file not found. The package may not have installed successfully.'
119
-		exit 42904
120
-	fi
121
-
122
-	dialog --title $"OneRNG Device" \
123
-		   --msgbox $"Please plug in the OneRNG device" 6 40
124
-
125
-	# check rng-tools configuration
126
-	if ! grep -q "/dev/$ONERNG_DEVICE" /etc/default/rng-tools; then
127
-		echo "HRNGDEVICE=/dev/$ONERNG_DEVICE" >> /etc/default/rng-tools
128
-	fi
129
-
130
-	systemctl restart rng-tools
85
+    apt-get -y install rng-tools at python-gnupg
86
+
87
+    # Move to the installation directory
88
+    if [ ! -d $INSTALL_DIR ]; then
89
+        mkdir $INSTALL_DIR
90
+    fi
91
+    cd $INSTALL_DIR
92
+
93
+    # Download the package
94
+    if [ ! -f $ONERNG_PACKAGE ]; then
95
+        wget $ONERNG_PACKAGE_DOWNLOAD
96
+        mv "$ONERNG_PACKAGE?raw=true" $ONERNG_PACKAGE
97
+    fi
98
+    if [ ! -f $ONERNG_PACKAGE ]; then
99
+        echo $"OneRNG package could not be downloaded"
100
+        exit 59249
101
+    fi
102
+
103
+    # Check the hash
104
+    hash=$(sha256sum $ONERNG_PACKAGE | awk -F ' ' '{print $1}')
105
+    if [[ $hash != $ONERNG_PACKAGE_HASH ]]; then
106
+        echo $"OneRNG package: $ONERNG_PACKAGE"
107
+        echo $"Hash does not match. This could indicate that the package has been tampered with."
108
+        echo $"OneRNG expected package hash: $ONERNG_PACKAGE_HASH"
109
+        echo $"OneRNG actual hash: $hash"
110
+        exit 25934
111
+    fi
112
+
113
+    # install the package
114
+    dpkg -i $ONERNG_PACKAGE
115
+
116
+    # Check that the install worked
117
+    if [ ! -f /etc/onerng.conf ]; then
118
+        echo $'OneRNG configuration file not found. The package may not have installed successfully.'
119
+        exit 42904
120
+    fi
121
+
122
+    dialog --title $"OneRNG Device" \
123
+           --msgbox $"Please plug in the OneRNG device" 6 40
124
+
125
+    # check rng-tools configuration
126
+    if ! grep -q "/dev/$ONERNG_DEVICE" /etc/default/rng-tools; then
127
+        echo "HRNGDEVICE=/dev/$ONERNG_DEVICE" >> /etc/default/rng-tools
128
+    fi
129
+
130
+    systemctl restart rng-tools
131 131
 }
132 132
 
133 133
 function random_number_generator {
134
-	if grep -Fxq "random_number_generator" $COMPLETION_FILE; then
135
-		return
136
-	fi
137
-	if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
138
-		# it is assumed that docker uses the random number
139
-		# generator of the host system
140
-		return
141
-	fi
142
-
143
-	# if the hrng type has not been set but /dev/hwrng is detected
144
-	if [[ $HWRNG_TYPE != "beaglebone" ]]; then
145
-		if [ -e /dev/hwrng ]; then
146
-			HWRNG_TYPE="beaglebone"
147
-		fi
148
-	fi
149
-
150
-	case $HWRNG_TYPE in
151
-		beaglebone)
152
-			apt-get -y install rng-tools
153
-			sed -i 's|#HRNGDEVICE=/dev/hwrng|HRNGDEVICE=/dev/hwrng|g' /etc/default/rng-tools
154
-			;;
155
-		onerng)
156
-			function_check install_onerng
157
-			install_onerng
158
-			;;
159
-		*)
160
-			apt-get -y install haveged
161
-			;;
162
-	esac
163
-
164
-	echo 'random_number_generator' >> $COMPLETION_FILE
134
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
135
+        return
136
+    fi
137
+    if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
138
+        # it is assumed that docker uses the random number
139
+        # generator of the host system
140
+        return
141
+    fi
142
+
143
+    # if the hrng type has not been set but /dev/hwrng is detected
144
+    if [[ $HWRNG_TYPE != "beaglebone" ]]; then
145
+        if [ -e /dev/hwrng ]; then
146
+            HWRNG_TYPE="beaglebone"
147
+        fi
148
+    fi
149
+
150
+    case $HWRNG_TYPE in
151
+        beaglebone)
152
+            apt-get -y install rng-tools
153
+            sed -i 's|#HRNGDEVICE=/dev/hwrng|HRNGDEVICE=/dev/hwrng|g' /etc/default/rng-tools
154
+            ;;
155
+        onerng)
156
+            function_check install_onerng
157
+            install_onerng
158
+            ;;
159
+        *)
160
+            apt-get -y install haveged
161
+            ;;
162
+    esac
163
+
164
+    mark_completed $FUNCNAME
165 165
 }
166 166
 
167 167
 # NOTE: deliberately no exit 0

+ 3
- 1
src/freedombone-utils-selector View File

@@ -230,7 +230,9 @@ function install_completed {
230 230
     if [ ! ${1} ]; then
231 231
         exit 673935
232 232
     fi
233
-    echo "install_${1}" >> $COMPLETION_FILE
233
+    if ! grep -Fxq "install_${1}" $COMPLETION_FILE; then
234
+        echo "install_${1}" >> $COMPLETION_FILE
235
+    fi
234 236
 }
235 237
 
236 238
 # populates an array of "0" or "1" for whether apps are installed

+ 4
- 6
src/freedombone-utils-setup View File

@@ -82,7 +82,7 @@ CHECK_MESSAGE="Check your internet connection, /etc/network/interfaces and /etc/
82 82
 DH_KEYLENGTH=2048
83 83
 
84 84
 function initial_setup {
85
-    if grep -Fxq "initial_setup" $COMPLETION_FILE; then
85
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
86 86
         return
87 87
     fi
88 88
 
@@ -104,7 +104,7 @@ function initial_setup {
104 104
         mkdir -p $INSTALL_DIR
105 105
     fi
106 106
 
107
-    echo 'initial_setup' >> $COMPLETION_FILE
107
+    mark_completed $FUNCNAME
108 108
 }
109 109
 
110 110
 function search_for_attached_usb_drive {
@@ -210,13 +210,11 @@ function search_for_attached_usb_drive {
210 210
         fi
211 211
         echo $'No USB drive attached'
212 212
     fi
213
-    echo 'search_for_attached_usb_drive' >> $COMPLETION_FILE
213
+    mark_completed $FUNCNAME
214 214
 }
215 215
 
216 216
 function mark_admin_user_account {
217
-    if ! grep -q "Admin user:" $COMPLETION_FILE; then
218
-        echo "Admin user:$MY_USERNAME" >> $COMPLETION_FILE
219
-    fi
217
+    set_completion_param "Admin user" "$MY_USERNAME"
220 218
 }
221 219
 
222 220
 function remove_instructions_from_motd {

+ 6
- 6
src/freedombone-utils-ssh View File

@@ -37,7 +37,7 @@ SSH_KEX="diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie
37 37
 SSH_HOST_KEY_ALGORITHMS="ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-ed25519,ssh-rsa"
38 38
 
39 39
 function configure_ssh {
40
-    if grep -Fxq "configure_ssh" $COMPLETION_FILE; then
40
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
41 41
         return
42 42
     fi
43 43
     sed -i "s/Port .*/Port $SSH_PORT/g" /etc/ssh/sshd_config
@@ -82,7 +82,7 @@ function configure_ssh {
82 82
 
83 83
     function_check configure_firewall_for_ssh
84 84
     configure_firewall_for_ssh
85
-    echo 'configure_ssh' >> $COMPLETION_FILE
85
+    mark_completed $FUNCNAME
86 86
 }
87 87
 
88 88
 # see https://stribika.github.io/2015/01/04/secure-secure-shell.html
@@ -92,7 +92,7 @@ function ssh_remove_small_moduli {
92 92
 }
93 93
 
94 94
 function configure_ssh_client {
95
-    if grep -Fxq "configure_ssh_client" $COMPLETION_FILE; then
95
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
96 96
         return
97 97
     fi
98 98
     #sed -i 's/#   PasswordAuthentication.*/   PasswordAuthentication no/g' /etc/ssh/ssh_config
@@ -122,11 +122,11 @@ function configure_ssh_client {
122 122
 
123 123
     function_check ssh_remove_small_moduli
124 124
     ssh_remove_small_moduli
125
-    echo 'configure_ssh_client' >> $COMPLETION_FILE
125
+    mark_completed $FUNCNAME
126 126
 }
127 127
 
128 128
 function regenerate_ssh_keys {
129
-    if grep -Fxq "regenerate_ssh_keys" $COMPLETION_FILE; then
129
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
130 130
         return
131 131
     fi
132 132
     rm -f /etc/ssh/ssh_host_*
@@ -136,7 +136,7 @@ function regenerate_ssh_keys {
136 136
     ssh_remove_small_moduli
137 137
 
138 138
     systemctl restart ssh
139
-    echo 'regenerate_ssh_keys' >> $COMPLETION_FILE
139
+    mark_completed $FUNCNAME
140 140
 }
141 141
 
142 142
 # NOTE: deliberately no exit 0

+ 2
- 2
src/freedombone-utils-tracker View File

@@ -65,7 +65,7 @@ function install_tracker {
65 65
         return
66 66
     fi
67 67
 
68
-    if grep -Fxq "install_tracker" $COMPLETION_FILE; then
68
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
69 69
         return
70 70
     fi
71 71
 
@@ -97,7 +97,7 @@ function install_tracker {
97 97
     systemctl enable tracker.service
98 98
     systemctl start tracker.service
99 99
 
100
-    echo 'install_tracker' >> $COMPLETION_FILE
100
+    mark_completed $FUNCNAME
101 101
 }
102 102
 
103 103
 # NOTE: deliberately no exit 0

+ 4
- 4
src/freedombone-utils-upgrade View File

@@ -38,20 +38,20 @@ function create_upgrade_script {
38 38
         cp /usr/bin/${PROJECT_NAME}-upgrade /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
39 39
     fi
40 40
 
41
-    if grep -Fxq "create_upgrade_script" $COMPLETION_FILE; then
41
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
42 42
         return
43 43
     fi
44 44
 
45 45
     apt-get -y install unattended-upgrades
46 46
 
47
-    echo 'create_upgrade_script' >> $COMPLETION_FILE
47
+    mark_completed $FUNCNAME
48 48
 }
49 49
 
50 50
 function upgrade_installation_from_previous_versions {
51 51
     if [ ! -f $COMPLETION_FILE ]; then
52 52
         return
53 53
     fi
54
-    if grep -Fxq "upgrade_installation_from_previous_versions" $COMPLETION_FILE; then
54
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
55 55
         return
56 56
     fi
57 57
 
@@ -84,7 +84,7 @@ function upgrade_installation_from_previous_versions {
84 84
         rm /usr/local/bin/zeronetavahi
85 85
     fi
86 86
 
87
-    echo 'upgrade_installation_from_previous_versions' >> $COMPLETION_FILE
87
+    mark_completed $FUNCNAME
88 88
 }
89 89
 
90 90
 # NOTE: deliberately no exit 0

+ 2
- 2
src/freedombone-utils-watchdog View File

@@ -34,7 +34,7 @@
34 34
 WATCHDOG_SCRIPT_NAME="keepon"
35 35
 
36 36
 function install_watchdog_script {
37
-    if grep -Fxq "install_watchdog_script" $COMPLETION_FILE; then
37
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
38 38
         return
39 39
     fi
40 40
     echo '#!/bin/bash' > /usr/bin/$WATCHDOG_SCRIPT_NAME
@@ -46,7 +46,7 @@ function install_watchdog_script {
46 46
     function_check cron_add_mins
47 47
     cron_add_mins 1 "/usr/bin/$WATCHDOG_SCRIPT_NAME"
48 48
 
49
-    echo 'install_watchdog_script' >> $COMPLETION_FILE
49
+    mark_completed $FUNCNAME
50 50
 }
51 51
 
52 52
 function add_watchdog_daemon {

+ 9
- 16
src/freedombone-utils-web View File

@@ -336,7 +336,7 @@ function install_dynamicdns {
336 336
     function_check set_repo_commit
337 337
     set_repo_commit $INSTALL_DIR/inadyn "inadyn commit" "$INADYN_COMMIT" $INADYN_REPO
338 338
 
339
-    if grep -Fxq "install_dynamicdns" $COMPLETION_FILE; then
339
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
340 340
         return
341 341
     fi
342 342
 
@@ -357,11 +357,7 @@ function install_dynamicdns {
357 357
     fi
358 358
     cd $INSTALL_DIR/inadyn
359 359
     git checkout $INADYN_COMMIT -b $INADYN_COMMIT
360
-    if ! grep -q "inadyn commit" $COMPLETION_FILE; then
361
-        echo "inadyn commit:$INADYN_COMMIT" >> $COMPLETION_FILE
362
-    else
363
-        sed -i "s/inadyn commit.*/inadyn commit:$INADYN_COMMIT/g" $COMPLETION_FILE
364
-    fi
360
+    set_completion_param "inadyn commit" "$INADYN_COMMIT"
365 361
 
366 362
     ./configure
367 363
     if [ ! "$?" = "0" ]; then
@@ -403,11 +399,11 @@ function install_dynamicdns {
403 399
     systemctl start inadyn
404 400
     systemctl daemon-reload
405 401
 
406
-    echo 'install_dynamicdns' >> $COMPLETION_FILE
402
+    mark_completed $FUNCNAME
407 403
 }
408 404
 
409 405
 function install_command_line_browser {
410
-    if grep -Fxq "install_command_line_browser" $COMPLETION_FILE; then
406
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
411 407
         return
412 408
     fi
413 409
     apt-get -y install elinks
@@ -421,7 +417,7 @@ function install_command_line_browser {
421 417
         fi
422 418
     fi
423 419
 
424
-    echo 'install_command_line_browser' >> $COMPLETION_FILE
420
+    mark_completed $FUNCNAME
425 421
 }
426 422
 
427 423
 function mesh_web_server {
@@ -448,7 +444,7 @@ function install_web_server {
448 444
     function_check set_repo_commit
449 445
     set_repo_commit $INSTALL_DIR/nginx_ensite "nginx-ensite commit" "$NGINX_ENSITE_COMMIT" $NGINX_ENSITE_REPO
450 446
 
451
-    if grep -Fxq "install_web_server" $COMPLETION_FILE; then
447
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
452 448
         return
453 449
     fi
454 450
     # remove apache
@@ -562,11 +558,8 @@ function install_web_server {
562 558
     git_clone $NGINX_ENSITE_REPO $INSTALL_DIR/nginx_ensite
563 559
     cd $INSTALL_DIR/nginx_ensite
564 560
     git checkout $NGINX_ENSITE_COMMIT -b $NGINX_ENSITE_COMMIT
565
-    if ! grep -q "nginx-ensite commit" $COMPLETION_FILE; then
566
-        echo "nginx-ensite commit:$NGINX_ENSITE_COMMIT" >> $COMPLETION_FILE
567
-    else
568
-        sed -i "s/nginx-ensite commit.*/nginx-ensite commit:$NGINX_ENSITE_COMMIT/g" $COMPLETION_FILE
569
-    fi
561
+
562
+    set_completion_param "nginx-ensite commit" "$NGINX_ENSITE_COMMIT"
570 563
 
571 564
     make install
572 565
     nginx_dissite default
@@ -574,7 +567,7 @@ function install_web_server {
574 567
     function_check configure_firewall_for_web_access
575 568
     configure_firewall_for_web_access
576 569
 
577
-    echo 'install_web_server' >> $COMPLETION_FILE
570
+    mark_completed $FUNCNAME
578 571
 }
579 572
 
580 573
 # NOTE: deliberately no exit 0

+ 6
- 5
src/freedombone-utils-wifi View File

@@ -49,7 +49,8 @@ function setup_wifi {
49 49
     if [ ${#WIFI_SSID} -lt 2 ]; then
50 50
         return
51 51
     fi
52
-    if grep -Fxq "setup_wifi" $COMPLETION_FILE; then
52
+
53
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
53 54
         return
54 55
     fi
55 56
 
@@ -60,7 +61,7 @@ function setup_wifi {
60 61
 
61 62
     if [ -f $WIFI_NETWORKS_FILE ]; then
62 63
         ${PROJECT_NAME}-wifi -i $WIFI_INTERFACE --networks $WIFI_NETWORKS_FILE
63
-        echo 'setup_wifi' >> $COMPLETION_FILE
64
+        mark_completed $FUNCNAME
64 65
         return
65 66
     fi
66 67
 
@@ -77,12 +78,12 @@ function setup_wifi {
77 78
     else
78 79
         ${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE --hotspot $HOTSPOT --networks $WIFI_NETWORKS_FILE
79 80
     fi
80
-    echo 'setup_wifi' >> $COMPLETION_FILE
81
+    mark_completed $FUNCNAME
81 82
 }
82 83
 
83 84
 # ath9k_htc driver
84 85
 function install_atheros_wifi {
85
-    if grep -Fxq "install_atheros_wifi" $COMPLETION_FILE; then
86
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
86 87
         return
87 88
     fi
88 89
     if [ $INSTALLING_ON_BBB != "yes" ]; then
@@ -127,7 +128,7 @@ function install_atheros_wifi {
127 128
     if [ ! "$?" = "0" ]; then
128 129
         exit 74681
129 130
     fi
130
-    echo 'install_atheros_wifi' >> $COMPLETION_FILE
131
+    mark_completed $FUNCNAME
131 132
 }
132 133
 
133 134
 # NOTE: deliberately no exit 0

+ 9
- 9
src/freedombone-utils-zram View File

@@ -29,18 +29,18 @@
29 29
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
30 30
 
31 31
 function enable_zram {
32
-	if grep -Fxq "enable_zram" $COMPLETION_FILE; then
33
-		return
34
-	fi
32
+    if [[ $(is_completed $FUNCNAME) == "1" ]]; then
33
+        return
34
+    fi
35 35
 
36
-	if [[ $INSTALLED_WITHIN_DOCKER == "yes" || $INSTALLING_ON_BBB != "yes" ]]; then
37
-		${PROJECT_NAME}-zram off
38
-		return
39
-	fi
36
+    if [[ $INSTALLED_WITHIN_DOCKER == "yes" || $INSTALLING_ON_BBB != "yes" ]]; then
37
+        ${PROJECT_NAME}-zram off
38
+        return
39
+    fi
40 40
 
41
-	${PROJECT_NAME}-zram on
41
+    ${PROJECT_NAME}-zram on
42 42
 
43
-	echo 'enable_zram' >> $COMPLETION_FILE
43
+    mark_completed $FUNCNAME
44 44
 }
45 45
 
46 46
 # NOTE: deliberately no exit 0