Przeglądaj źródła

Merge branch 'stretch' of https://github.com/bashrc/freedombone

Bob Mottram 7 lat temu
rodzic
commit
e79f2c9390

+ 1
- 0
src/freedombone-addremove Wyświetl plik

@@ -203,6 +203,7 @@ function install_apps_selected {
203 203
             fi
204 204
         fi
205 205
         app_index=$((app_index+1))
206
+
206 207
     done
207 208
 
208 209
     # if no apps to be installed then don't do anything

+ 1
- 0
src/freedombone-app-etherpad Wyświetl plik

@@ -30,6 +30,7 @@ VARIANTS="full full-vim writer"
30 30
 
31 31
 IN_DEFAULT_INSTALL=0
32 32
 SHOW_ON_ABOUT=1
33
+MINIMUM_RAM_MB=2000
33 34
 
34 35
 ETHERPAD_DOMAIN_NAME=
35 36
 ETHERPAD_CODE=

+ 8
- 3
src/freedombone-app-gnusocial Wyświetl plik

@@ -30,6 +30,7 @@ VARIANTS='full full-vim social'
30 30
 
31 31
 IN_DEFAULT_INSTALL=0
32 32
 SHOW_ON_ABOUT=1
33
+NOT_ON_ONION=1
33 34
 
34 35
 GNUSOCIAL_DOMAIN_NAME=
35 36
 GNUSOCIAL_CODE=
@@ -581,6 +582,7 @@ function remove_gnusocial {
581 582
     fi
582 583
     kill_pid=$(pgrep "/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/queuedaemon.php" | head -n 1)
583 584
     kill -9 "$kill_pid"
585
+    pkill "$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/queuedaemon.php"
584 586
 
585 587
     if [ -d "/var/www/$GNUSOCIAL_DOMAIN_NAME" ]; then
586 588
         rm -rf "/var/www/$GNUSOCIAL_DOMAIN_NAME"
@@ -911,8 +913,8 @@ function install_gnusocial_main {
911 913
 }
912 914
 
913 915
 function install_gnusocial {
914
-    if [ ! "$ONION_ONLY" ]; then
915
-        ONION_ONLY='no'
916
+    if [[ "$ONION_ONLY" != 'no' ]]; then
917
+        return
916 918
     fi
917 919
 
918 920
     install_gnusocial_main
@@ -935,9 +937,12 @@ function install_gnusocial {
935 937
         sed -i 's|"theme":.*|"theme": "base16-apathy.css",|g' "/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/static/config.json"
936 938
     fi
937 939
 
938
-    # unleash the daemons!
940
+    # this has to be run as root initially, otherwise database tables
941
+    # don't get created
939 942
     cd "/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs" || exit 236482684
940 943
     php scripts/checkschema.php
944
+    sh scripts/startdaemons.sh
945
+
941 946
     /etc/cron.hourly/gnusocial-daemons
942 947
 
943 948
     systemctl restart nginx

+ 1
- 0
src/freedombone-app-hubzilla Wyświetl plik

@@ -30,6 +30,7 @@ VARIANTS='full full-vim social'
30 30
 
31 31
 IN_DEFAULT_INSTALL=0
32 32
 SHOW_ON_ABOUT=1
33
+NOT_ON_ONION=1
33 34
 
34 35
 HUBZILLA_DOMAIN_NAME=
35 36
 HUBZILLA_CODE=

+ 1
- 0
src/freedombone-app-jitsi Wyświetl plik

@@ -32,6 +32,7 @@ VARIANTS=""
32 32
 
33 33
 IN_DEFAULT_INSTALL=0
34 34
 SHOW_ON_ABOUT=0
35
+NOT_ON_ONION=1
35 36
 
36 37
 VIDEOBRIDGE_PORT=5347
37 38
 JITSI_ONION_PORT=8102

+ 2
- 0
src/freedombone-app-matrix Wyświetl plik

@@ -36,6 +36,8 @@ VARIANTS='full full-vim chat'
36 36
 
37 37
 IN_DEFAULT_INSTALL=0
38 38
 SHOW_ON_ABOUT=1
39
+NOT_ON_ONION=1
40
+MINIMUM_RAM_MB=1500
39 41
 
40 42
 MATRIX_DOMAIN_NAME=
41 43
 MATRIX_CODE=

+ 10
- 3
src/freedombone-app-postactiv Wyświetl plik

@@ -30,6 +30,7 @@ VARIANTS='full full-vim media'
30 30
 
31 31
 IN_DEFAULT_INSTALL=0
32 32
 SHOW_ON_ABOUT=1
33
+NOT_ON_ONION=1
33 34
 
34 35
 POSTACTIV_DOMAIN_NAME=
35 36
 POSTACTIV_CODE=
@@ -595,6 +596,7 @@ function remove_postactiv {
595 596
     fi
596 597
     kill_pid=$(pgrep "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/scripts/queuedaemon.php" | head -n 1)
597 598
     kill -9 "$kill_pid"
599
+    pkill "$POSTACTIV_DOMAIN_NAME/htdocs/scripts/queuedaemon.php"
598 600
 
599 601
     if [ -d "/var/www/$POSTACTIV_DOMAIN_NAME" ]; then
600 602
         rm -rf "/var/www/$POSTACTIV_DOMAIN_NAME"
@@ -926,8 +928,8 @@ function install_postactiv_main {
926 928
 }
927 929
 
928 930
 function install_postactiv {
929
-    if [ ! "$ONION_ONLY" ]; then
930
-        ONION_ONLY='no'
931
+    if [[ "$ONION_ONLY" != 'no' ]]; then
932
+        return
931 933
     fi
932 934
 
933 935
     install_postactiv_main
@@ -952,7 +954,12 @@ function install_postactiv {
952 954
 
953 955
     expire_gnusocial_posts "$POSTACTIV_DOMAIN_NAME" "postactiv" "$POSTACTIV_EXPIRE_MONTHS"
954 956
 
955
-    # unleash the daemons!
957
+    # this has to be run as root initially, otherwise database tables
958
+    # don't get created
959
+    cd "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" || exit 3658254254
960
+    sh scripts/startdaemons.sh
961
+    php scripts/checkschema.php
962
+
956 963
     /etc/cron.hourly/postactiv-daemons
957 964
 
958 965
     systemctl restart nginx

+ 1
- 0
src/freedombone-app-riot Wyświetl plik

@@ -30,6 +30,7 @@ VARIANTS='full full-vim chat'
30 30
 
31 31
 IN_DEFAULT_INSTALL=0
32 32
 SHOW_ON_ABOUT=1
33
+NOT_ON_ONION=1
33 34
 
34 35
 RIOT_VERSION='0.13.3'
35 36
 RIOT_FILENAME="riot-v${RIOT_VERSION}"

+ 86
- 39
src/freedombone-utils-selector Wyświetl plik

@@ -272,6 +272,39 @@ function get_apps_installed_names {
272 272
     done
273 273
 }
274 274
 
275
+function app_not_on_onion_only {
276
+    app_name="$1"
277
+
278
+    read_config_param ONION_ONLY
279
+
280
+    if [[ "$ONION_ONLY" != 'no' ]]; then
281
+        if grep -q "NOT_ON_ONION=1" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}"; then
282
+            echo "0"
283
+            return
284
+        fi
285
+    fi
286
+    echo "1"
287
+}
288
+
289
+function enough_ram_for_app {
290
+    app_name="$1"
291
+
292
+    if ! grep -q "MINIMUM_RAM_MB=" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}"; then
293
+        echo "0"
294
+        return
295
+    fi
296
+
297
+    minimum_ram_MB=$(grep "MINIMUM_RAM_MB=" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}" | head -n 1 | awk -F '=' '{print $2}')
298
+    minimum_ram_bytes=$((minimum_ram_MB * 1024))
299
+
300
+    ram_available=$(grep MemTotal /proc/meminfo | awk '{print $2}')
301
+    if [ "$ram_available" -lt "$minimum_ram_bytes" ]; then
302
+        echo "1"
303
+        return
304
+    fi
305
+    echo "0"
306
+}
307
+
275 308
 # detects what apps are available
276 309
 function detect_apps {
277 310
     FILES="/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*"
@@ -285,11 +318,14 @@ function detect_apps {
285 318
     for filename in $FILES
286 319
     do
287 320
         app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
288
-
289
-        # shellcheck disable=SC2068
290
-        if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
291
-            APPS_AVAILABLE+=("${app_name}")
292
-            APPS_CHOSEN+=("0")
321
+        if [[ $(enough_ram_for_app "$app_name") == "0" ]]; then
322
+            if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
323
+                # shellcheck disable=SC2068
324
+                if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
325
+                    APPS_AVAILABLE+=("${app_name}")
326
+                    APPS_CHOSEN+=("0")
327
+                fi
328
+            fi
293 329
         fi
294 330
     done
295 331
 
@@ -318,16 +354,20 @@ function detect_installable_apps {
318 354
     do
319 355
         app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
320 356
 
321
-        # shellcheck disable=SC2068
322
-        if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
323
-            variants_list=$(app_variants "$filename")
324
-            # check for empty string
325
-            if [ ${#variants_list} -gt 0 ]; then
326
-                APPS_AVAILABLE+=("${app_name}")
327
-                APPS_CHOSEN+=("0")
328
-                APPS_INSTALLED+=("$(app_is_installed "$app_name")")
329
-                if [[ $(app_is_installed "$app_name") == "1" ]]; then
330
-                    APPS_INSTALLED_NAMES+=("$app_name")
357
+        if [[ $(enough_ram_for_app "$app_name") == "0" ]]; then
358
+            if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
359
+                # shellcheck disable=SC2068
360
+                if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
361
+                    variants_list=$(app_variants "$filename")
362
+                    # check for empty string
363
+                    if [ ${#variants_list} -gt 0 ]; then
364
+                        APPS_AVAILABLE+=("${app_name}")
365
+                        APPS_CHOSEN+=("0")
366
+                        APPS_INSTALLED+=("$(app_is_installed "$app_name")")
367
+                        if [[ $(app_is_installed "$app_name") == "1" ]]; then
368
+                            APPS_INSTALLED_NAMES+=("$app_name")
369
+                        fi
370
+                    fi
331 371
                 fi
332 372
             fi
333 373
         fi
@@ -350,13 +390,17 @@ function detect_installed_apps {
350 390
     do
351 391
         app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
352 392
 
353
-        if [[ $(app_is_installed "$app_name") == "1" ]]; then
354
-            # shellcheck disable=SC2068
355
-            if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
356
-                variants_list=$(app_variants "$filename")
357
-                if [ ${#variants_list} -gt 0 ]; then
358
-                    APPS_AVAILABLE+=("${app_name}")
359
-                    APPS_INSTALLED_NAMES+=("$app_name")
393
+        if [[ $(enough_ram_for_app "$app_name") == "0" ]]; then
394
+            if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
395
+                if [[ $(app_is_installed "$app_name") == "1" ]]; then
396
+                    # shellcheck disable=SC2068
397
+                    if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
398
+                        variants_list=$(app_variants "$filename")
399
+                        if [ ${#variants_list} -gt 0 ]; then
400
+                            APPS_AVAILABLE+=("${app_name}")
401
+                            APPS_INSTALLED_NAMES+=("$app_name")
402
+                        fi
403
+                    fi
360 404
                 fi
361 405
             fi
362 406
         fi
@@ -385,27 +429,30 @@ function choose_apps_for_variant {
385 429
     for filename in $FILES
386 430
     do
387 431
         app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
388
-
389
-        # shellcheck disable=SC2068
390
-        if item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
391
-            if grep -q "VARIANTS=" "${filename}"; then
392
-                variants_list=$(app_variants "$filename")
393
-                if [[ "${variants_list}" == 'all'* || \
394
-                      "${variants_list}" == "$variant_name" || \
395
-                      "${variants_list}" == "$variant_name "* || \
396
-                      "${variants_list}" == *" $variant_name "* || \
397
-                      "${variants_list}" == *" $variant_name" ]]; then
398
-                    if [[ $(app_is_removed "${a}") == "0" ]]; then
399
-                        #echo $"${app_name} chosen"
400
-                        APPS_CHOSEN+=("1")
432
+        if [[ $(enough_ram_for_app "$app_name") == "0" ]]; then
433
+            if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
434
+                # shellcheck disable=SC2068
435
+                if item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
436
+                    if grep -q "VARIANTS=" "${filename}"; then
437
+                        variants_list=$(app_variants "$filename")
438
+                        if [[ "${variants_list}" == 'all'* || \
439
+                                  "${variants_list}" == "$variant_name" || \
440
+                                  "${variants_list}" == "$variant_name "* || \
441
+                                  "${variants_list}" == *" $variant_name "* || \
442
+                                  "${variants_list}" == *" $variant_name" ]]; then
443
+                            if [[ $(app_is_removed "${a}") == "0" ]]; then
444
+                                #echo $"${app_name} chosen"
445
+                                APPS_CHOSEN+=("1")
446
+                            else
447
+                                APPS_CHOSEN+=("0")
448
+                            fi
449
+                        else
450
+                            APPS_CHOSEN+=("0")
451
+                        fi
401 452
                     else
402 453
                         APPS_CHOSEN+=("0")
403 454
                     fi
404
-                else
405
-                    APPS_CHOSEN+=("0")
406 455
                 fi
407
-            else
408
-                APPS_CHOSEN+=("0")
409 456
             fi
410 457
         fi
411 458
     done