Browse Source

Simplify install state checking

Bob Mottram 8 years ago
parent
commit
4956701174

+ 0
- 4
src/freedombone-app-babel View File

@@ -100,9 +100,6 @@ function configure_firewall_for_babel {
100 100
 }
101 101
 
102 102
 function install_babel {
103
-    if [[ $(app_is_installed babel) == "1" ]]; then
104
-        return
105
-    fi
106 103
     if [[ $ENABLE_BABEL != "yes" ]]; then
107 104
         return
108 105
     fi
@@ -115,7 +112,6 @@ function install_babel {
115 112
 
116 113
     function_check configure_firewall_for_babel
117 114
     configure_firewall_for_babel
118
-    install_completed babel
119 115
 }
120 116
 
121 117
 # NOTE: deliberately there is no "exit 0"

+ 0
- 4
src/freedombone-app-batman View File

@@ -135,9 +135,6 @@ function install_batman {
135 135
         mesh_install_batman
136 136
         return
137 137
     fi
138
-    if [[ $(app_is_installed batman) == "1" ]]; then
139
-        return
140
-    fi
141 138
     if [[ $ENABLE_BATMAN != "yes" ]]; then
142 139
         return
143 140
     fi
@@ -162,7 +159,6 @@ function install_batman {
162 159
 
163 160
     function_check configure_firewall_for_batman
164 161
     configure_firewall_for_batman
165
-    install_completed batman
166 162
 }
167 163
 
168 164
 # NOTE: deliberately no exit 0

+ 0
- 6
src/freedombone-app-blog View File

@@ -590,10 +590,6 @@ function install_blog_from_repo {
590 590
 }
591 591
 
592 592
 function install_blog {
593
-    if [[ $(app_is_installed blog) == "1" ]]; then
594
-        return
595
-    fi
596
-
597 593
     if [ ! $ONION_ONLY ]; then
598 594
         ONION_ONLY='no'
599 595
     fi
@@ -675,8 +671,6 @@ function install_blog {
675 671
     if ! grep -q "Blog domain:" $COMPLETION_FILE; then
676 672
         echo "Blog domain:$FULLBLOG_DOMAIN_NAME" >> $COMPLETION_FILE
677 673
     fi
678
-
679
-    install_completed blog
680 674
 }
681 675
 
682 676
 # NOTE: deliberately no exit 0

+ 0
- 6
src/freedombone-app-blogstatic View File

@@ -305,10 +305,6 @@ function install_blogstatic {
305 305
         return
306 306
     fi
307 307
 
308
-    if [[ $(app_is_installed blogstatic) == "1" ]]; then
309
-        return
310
-    fi
311
-
312 308
     apt-get -y install python-pip
313 309
     pip install ipython
314 310
     pip install Markdown
@@ -342,8 +338,6 @@ function install_blogstatic {
342 338
 
343 339
     chown -R $MY_USERNAME:$MY_USERNAME $STATIC_BLOG_INSTALL_DIR
344 340
     chown -R www-data:www-data $STATIC_BLOG_PATH
345
-
346
-    install_completed blogstatic
347 341
 }
348 342
 
349 343
 # NOTE: deliberately no exit 0

+ 1
- 4
src/freedombone-app-cjdns View File

@@ -529,13 +529,10 @@ function install_cjdns_tools {
529 529
     # initialise from the cjdns config
530 530
     /usr/bin/cjdcmd cjdnsadmin -file /etc/cjdns/cjdroute.conf
531 531
 
532
-    echo 'install_cjdns_tools' >> $COMPLETION_FILE
532
+    install_completed cjdns_tools
533 533
 }
534 534
 
535 535
 function install_cjdns {
536
-    if [[ $(app_is_installed cjdns) == "1" ]]; then
537
-        return
538
-    fi
539 536
     install_cjdns_main
540 537
     install_cjdns_tools
541 538
     install_completed cjdns

+ 0
- 4
src/freedombone-app-dlna View File

@@ -257,12 +257,8 @@ function script_for_attaching_usb_drive {
257 257
 }
258 258
 
259 259
 function install_dlna {
260
-    if [[ $(app_is_installed dlna) == "1" ]]; then
261
-        return
262
-    fi
263 260
     install_dlna_main
264 261
     script_for_attaching_usb_drive
265
-    install_completed dlna
266 262
 }
267 263
 
268 264
 # NOTE: deliberately no exit 0

+ 0
- 5
src/freedombone-app-emacs View File

@@ -108,9 +108,6 @@ function remove_emacs {
108 108
 }
109 109
 
110 110
 function install_emacs {
111
-    if [[ $(app_is_installed emacs) == "1" ]]; then
112
-        return
113
-    fi
114 111
     update-alternatives --set editor /usr/bin/emacs24
115 112
 
116 113
     # A minimal emacs configuration
@@ -185,8 +182,6 @@ function install_emacs {
185 182
     echo '(epa-file-enable)' >> /home/$MY_USERNAME/.emacs
186 183
     cp /home/$MY_USERNAME/.emacs /root/.emacs
187 184
     chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.emacs
188
-
189
-    install_completed emacs
190 185
 }
191 186
 
192 187
 # NOTE: deliberately no exit 0

+ 0
- 5
src/freedombone-app-gnusocial View File

@@ -1011,10 +1011,6 @@ function install_gnusocial_plugin_nsfw {
1011 1011
 }
1012 1012
 
1013 1013
 function install_gnusocial {
1014
-    if [[ $(app_is_installed gnusocial) == "1" ]]; then
1015
-        return
1016
-    fi
1017
-
1018 1014
     if [ ! $ONION_ONLY ]; then
1019 1015
         ONION_ONLY='no'
1020 1016
     fi
@@ -1044,7 +1040,6 @@ function install_gnusocial {
1044 1040
     install_gnusocial_plugin_sharings
1045 1041
     install_gnusocial_plugin_sharings_theme
1046 1042
     install_gnusocial_plugin_nsfw
1047
-    install_completed gnusocial
1048 1043
 }
1049 1044
 
1050 1045
 # NOTE: deliberately there is no "exit 0"

+ 0
- 5
src/freedombone-app-gogs View File

@@ -442,10 +442,6 @@ function install_gogs {
442 442
         return
443 443
     fi
444 444
 
445
-    if [[ $(app_is_installed gogs) == "1" ]]; then
446
-        return
447
-    fi
448
-
449 445
     adduser --disabled-login --gecos 'Gogs' $GOGS_USERNAME
450 446
 
451 447
     gogs_parameters
@@ -766,7 +762,6 @@ function install_gogs {
766 762
     else
767 763
         sed -i "s|Gogs version.*|Gogs version:$GOGS_VERSION|g" $COMPLETION_FILE
768 764
     fi
769
-    install_completed gogs
770 765
 }
771 766
 
772 767
 # NOTE: deliberately no exit 0

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

@@ -400,10 +400,6 @@ function install_hubzilla {
400 400
         return
401 401
     fi
402 402
 
403
-    if [[ $(app_is_installed hubzilla) == "1" ]]; then
404
-        return
405
-    fi
406
-
407 403
     HUBZILLA_PATH=/var/www/$HUBZILLA_DOMAIN_NAME/htdocs
408 404
 
409 405
     function_check install_mariadb
@@ -704,7 +700,6 @@ function install_hubzilla {
704 700
     ${PROJECT_NAME}-addemail -u $MY_USERNAME -e "noreply@$HUBZILLA_DOMAIN_NAME" -g hubzilla --public no
705 701
 
706 702
     echo "Hubzilla domain:${HUBZILLA_DOMAIN_NAME}" >> $COMPLETION_FILE
707
-    install_completed hubzilla
708 703
 }
709 704
 
710 705
 # NOTE: deliberately there is no "exit 0"

+ 0
- 4
src/freedombone-app-irc View File

@@ -371,12 +371,8 @@ function install_irc_client {
371 371
 }
372 372
 
373 373
 function install_irc {
374
-    if [[ $(app_is_installed irc) == "1" ]]; then
375
-        return
376
-    fi
377 374
     install_irc_server
378 375
     install_irc_client
379
-    install_completed irc
380 376
 }
381 377
 
382 378
 # NOTE: deliberately no exit 0

+ 0
- 6
src/freedombone-app-librevault View File

@@ -231,10 +231,6 @@ function install_librevault {
231 231
         return
232 232
     fi
233 233
 
234
-    if [[ $(app_is_installed librevault) == "1" ]]; then
235
-        return
236
-    fi
237
-
238 234
     install_tracker
239 235
     install_cmake
240 236
     install_cryptopp
@@ -326,8 +322,6 @@ function install_librevault {
326 322
 
327 323
     systemctl enable librevault-daemon
328 324
     systemctl start librevault-daemon
329
-
330
-    install_completed librevault
331 325
 }
332 326
 
333 327
 # NOTE: deliberately no exit 0

+ 28
- 7
src/freedombone-app-mediagoblin View File

@@ -128,7 +128,34 @@ function reconfigure_mediagoblin {
128 128
 }
129 129
 
130 130
 function upgrade_mediagoblin {
131
-    echo -n ''
131
+    if [ ! $ONION_ONLY ]; then
132
+        ONION_ONLY='no'
133
+    fi
134
+    if grep -q "ONION_ONLY" $CONFIGURATION_FILE; then
135
+        ONION_ONLY=$(grep "ONION_ONLY" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
136
+    fi
137
+    if grep -q "MEDIAGOBLIN_DOMAIN_NAME" $CONFIGURATION_FILE; then
138
+        MEDIAGOBLIN_DOMAIN_NAME=$(grep "MEDIAGOBLIN_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
139
+    fi
140
+    if grep -q "MEDIAGOBLIN_CODE" $CONFIGURATION_FILE; then
141
+        MEDIAGOBLIN_CODE=$(grep "MEDIAGOBLIN_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
142
+    fi
143
+    if grep -q "DDNS_PROVIDER" $CONFIGURATION_FILE; then
144
+        DDNS_PROVIDER=$(grep "DDNS_PROVIDER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
145
+    fi
146
+
147
+    if [ ! $MEDIAGOBLIN_DOMAIN_NAME ]; then
148
+        return
149
+    fi
150
+
151
+    MEDIAGOBLIN_WORKING_DIRECTORY=/var/www/$MEDIAGOBLIN_DOMAIN_NAME/htdocs
152
+
153
+    # update to a new commit if needed
154
+    function_check set_repo_commit
155
+    set_repo_commit $MEDIAGOBLIN_WORKING_DIRECTORY "Mediagoblin commit" "$MEDIAGOBLIN_COMMIT" $MEDIAGOBLIN_REPO
156
+    if [ -d $MEDIAGOBLIN_WORKING_DIRECTORY ]; then
157
+        chown -hR mediagoblin:www-data $MEDIAGOBLIN_WORKING_DIRECTORY
158
+    fi
132 159
 }
133 160
 
134 161
 function backup_local_mediagoblin {
@@ -209,10 +236,6 @@ function install_mediagoblin {
209 236
         chown -hR mediagoblin:www-data $MEDIAGOBLIN_WORKING_DIRECTORY
210 237
     fi
211 238
 
212
-    if [[ $(app_is_installed mediagoblin) == "1" ]]; then
213
-        return
214
-    fi
215
-
216 239
     apt-get -y install git-core python python-dev python-lxml python-pil
217 240
     apt-get -y install python-virtualenv npm nodejs-legacy automake
218 241
     apt-get -y install fcgiwrap
@@ -531,8 +554,6 @@ function install_mediagoblin {
531 554
     else
532 555
         sed -i "s/Mediagoblin domain.*/Mediagoblin domain:$MEDIAGOBLIN_DOMAIN_NAME/g" $COMPLETION_FILE
533 556
     fi
534
-
535
-    install_completed mediagoblin
536 557
 }
537 558
 
538 559
 # NOTE: deliberately no exit 0

+ 0
- 4
src/freedombone-app-mumble View File

@@ -199,9 +199,6 @@ function configure_firewall_for_voip {
199 199
 }
200 200
 
201 201
 function install_mumble {
202
-    if [[ $(app_is_installed mumble) == "1" ]]; then
203
-        return
204
-    fi
205 202
     apt-get -y install mumble-server
206 203
 
207 204
     function_check get_voip_server_password
@@ -289,7 +286,6 @@ function install_mumble {
289 286
 
290 287
     function_check configure_firewall_for_voip
291 288
     configure_firewall_for_voip
292
-    install_completed mumble
293 289
 }
294 290
 
295 291
 # NOTE: deliberately no exit 0

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

@@ -617,13 +617,9 @@ function install_rss_mobile_reader {
617 617
 }
618 618
 
619 619
 function install_rss {
620
-    if [[ $(app_is_installed rss) == "1" ]]; then
621
-        return
622
-    fi
623 620
     install_rss_main
624 621
     install_rss_gnusocial
625 622
     install_rss_mobile_reader
626
-    install_completed rss
627 623
 }
628 624
 
629 625
 # NOTE: deliberately no exit 0

+ 0
- 6
src/freedombone-app-searx View File

@@ -122,10 +122,6 @@ function install_searx {
122 122
         exit 62429
123 123
     fi
124 124
 
125
-    if [[ $(app_is_installed searx) == "1" ]]; then
126
-        return
127
-    fi
128
-
129 125
     apt-get -y install python-pip libyaml-dev python-werkzeug python-babel python-lxml apache2-utils
130 126
     apt-get -y install git build-essential libxslt-dev python-dev python-virtualenv python-pybabel zlib1g-dev uwsgi uwsgi-plugin-python libapache2-mod-uwsgi
131 127
 
@@ -292,8 +288,6 @@ function install_searx {
292 288
         chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
293 289
         chmod 600 /home/$MY_USERNAME/README
294 290
     fi
295
-
296
-    install_completed searx
297 291
 }
298 292
 
299 293
 # NOTE: deliberately no exit 0

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

@@ -446,12 +446,8 @@ function install_sip_turn {
446 446
 }
447 447
 
448 448
 function install_sip {
449
-    if [[ $(app_is_installed sip) == "1" ]]; then
450
-        return
451
-    fi
452 449
     install_sip_main
453 450
     update_sipwitch_daemon
454
-    install_completed sip
455 451
 }
456 452
 
457 453
 # NOTE: deliberately no exit 0

+ 0
- 5
src/freedombone-app-syncthing View File

@@ -470,10 +470,6 @@ function install_syncthing {
470 470
         return
471 471
     fi
472 472
 
473
-    if [[ $(app_is_installed syncthing) == "1" ]]; then
474
-        return
475
-    fi
476
-
477 473
     apt-get -y install curl
478 474
 
479 475
     curl -s https://syncthing.net/release-key.txt | apt-key add -
@@ -508,7 +504,6 @@ function install_syncthing {
508 504
 
509 505
     function_check configure_firewall_for_syncthing
510 506
     configure_firewall_for_syncthing
511
-    install_completed syncthing
512 507
 }
513 508
 
514 509
 # NOTE: deliberately no exit 0

+ 0
- 6
src/freedombone-app-tahoelafs View File

@@ -292,10 +292,6 @@ function install_tahoelafs {
292 292
         return
293 293
     fi
294 294
 
295
-    if [[ $(app_is_installed tahoelafs) == "1" ]]; then
296
-        return
297
-    fi
298
-
299 295
     apt-get -y install build-essential python-pip python-dev libffi-dev libssl-dev python-virtualenv
300 296
 
301 297
     # create a user to run the introducer
@@ -357,8 +353,6 @@ function install_tahoelafs {
357 353
     systemctl enable tahoelafs
358 354
     systemctl daemon-reload
359 355
     systemctl start tahoelafs
360
-
361
-    install_completed tahoelafs
362 356
 }
363 357
 
364 358
 # NOTE: deliberately no exit 0

+ 0
- 8
src/freedombone-app-tox View File

@@ -661,12 +661,6 @@ function enable_tox_repo {
661 661
 }
662 662
 
663 663
 function install_tox {
664
-    if [ ! $INSTALLING_MESH ]; then
665
-        if [[ $(app_is_installed tox) == "1" ]]; then
666
-            return
667
-        fi
668
-    fi
669
-
670 664
     configure_firewall_for_tox
671 665
 
672 666
     if [ $INSTALLING_MESH ]; then
@@ -678,8 +672,6 @@ function install_tox {
678 672
         tox_avahi
679 673
         install_tox_client
680 674
     fi
681
-
682
-    install_completed tox
683 675
 }
684 676
 
685 677
 # NOTE: deliberately no exit 0

+ 0
- 4
src/freedombone-app-vpn View File

@@ -68,9 +68,6 @@ function remove_vpn {
68 68
 }
69 69
 
70 70
 function install_vpn {
71
-    if [[ $(app_is_installed vpn) == "1" ]]; then
72
-        return
73
-    fi
74 71
     if ! grep -q "repo.universe-factory.net" /etc/apt/sources.list; then
75 72
         echo 'deb http://repo.universe-factory.net/debian/ sid main' >> /etc/apt/sources.list
76 73
         gpg --keyserver pgpkeys.mit.edu --recv-key 16EF3F64CB201D9C
@@ -84,7 +81,6 @@ function install_vpn {
84 81
             exit 52026
85 82
         fi
86 83
     fi
87
-    install_completed vpn
88 84
 }
89 85
 
90 86
 # NOTE: deliberately there is no "exit 0"

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

@@ -138,9 +138,6 @@ function remove_webmail {
138 138
 }
139 139
 
140 140
 function install_webmail {
141
-    if [[ $(app_is_installed webmail) == "1" ]]; then
142
-        return
143
-    fi
144 141
     if [ -d /etc/apache2 ]; then
145 142
         rm -rf /etc/apache2
146 143
         echo $'Removed Apache installation after Dokuwiki install'
@@ -259,8 +256,6 @@ function install_webmail {
259 256
         chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
260 257
         chmod 600 /home/$MY_USERNAME/README
261 258
     fi
262
-
263
-    install_completed webmail
264 259
 }
265 260
 
266 261
 # NOTE: deliberately no exit 0

+ 0
- 5
src/freedombone-app-wiki View File

@@ -270,10 +270,6 @@ function get_wiki_admin_password {
270 270
 }
271 271
 
272 272
 function install_wiki {
273
-    if [[ $(app_is_installed wiki) == "1" ]]; then
274
-        return
275
-    fi
276
-
277 273
     if [ ! $ONION_ONLY ]; then
278 274
         ONION_ONLY='no'
279 275
     fi
@@ -657,7 +653,6 @@ function install_wiki {
657 653
     fi
658 654
 
659 655
     echo "Wiki domain:$WIKI_DOMAIN_NAME" >> $COMPLETION_FILE
660
-    install_completed wiki
661 656
 }
662 657
 
663 658
 # NOTE: deliberately no exit 0

+ 0
- 4
src/freedombone-app-xmpp View File

@@ -502,12 +502,8 @@ function install_xmpp_client {
502 502
 }
503 503
 
504 504
 function install_xmpp {
505
-    if [[ $(app_is_installed xmpp) == "1" ]]; then
506
-        return
507
-    fi
508 505
     install_xmpp_main
509 506
     install_xmpp_client
510
-    install_completed xmpp
511 507
 }
512 508
 
513 509
 # NOTE: deliberately no exit 0

+ 0
- 4
src/freedombone-app-zeronet View File

@@ -675,14 +675,10 @@ function install_zeronet {
675 675
         mesh_zeronet_forum
676 676
         return
677 677
     fi
678
-    if [[ $(app_is_installed zeronet) == "1" ]]; then
679
-        return
680
-    fi
681 678
     install_zeronet_main
682 679
     install_zeronet_blog
683 680
     install_zeronet_mail
684 681
     install_zeronet_forum
685
-    install_completed zeronet
686 682
 }
687 683
 
688 684
 # NOTE: deliberately no exit 0

+ 20
- 6
src/freedombone-utils-selector View File

@@ -310,15 +310,29 @@ function install_apps {
310 310
                     # clears any removal indicator
311 311
                     reinstall_app ${a}
312 312
 
313
-                    echo $"Installing application from interactive: ${a}"
314
-                    install_${a}
315
-                    echo $"${a} was installed from interactive"
313
+                    if [[ $(app_is_installed ${a}) == "1" ]]; then
314
+                        echo $"Upgrading application from interactive: ${a}"
315
+                        upgrade_${a}
316
+                        echo $"${a} was upgraded from interactive"
317
+                    else
318
+                        echo $"Installing application from interactive: ${a}"
319
+                        install_${a}
320
+                        install_completed ${a}
321
+                        echo $"${a} was installed from interactive"
322
+                    fi
316 323
                 else
317 324
                     # check if the app was removed
318 325
                     if [[ $(app_is_removed ${a}) == "0" ]]; then
319
-                        echo $"Installing application: ${a}"
320
-                        install_${a}
321
-                        echo $"${a} was installed"
326
+                        if [[ $(app_is_installed ${a}) == "1" ]]; then
327
+                            echo $"Upgrading application: ${a}"
328
+                            upgrade_${a}
329
+                            echo $"${a} was upgraded"
330
+                        else
331
+                            echo $"Installing application: ${a}"
332
+                            install_${a}
333
+                            install_completed ${a}
334
+                            echo $"${a} was installed"
335
+                        fi
322 336
                     else
323 337
                         echo $"${a} has been removed and so will not be reinstalled"
324 338
                     fi