Bob Mottram преди 6 години
родител
ревизия
352b259bbb
променени са 1 файла, в които са добавени 57 реда и са изтрити 37 реда
  1. 57
    37
      src/freedombone-utils-selector

+ 57
- 37
src/freedombone-utils-selector Целия файл

@@ -285,11 +285,12 @@ function detect_apps {
285 285
     for filename in $FILES
286 286
     do
287 287
         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")
288
+        if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
289
+            # shellcheck disable=SC2068
290
+            if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
291
+                APPS_AVAILABLE+=("${app_name}")
292
+                APPS_CHOSEN+=("0")
293
+            fi
293 294
         fi
294 295
     done
295 296
 
@@ -298,6 +299,20 @@ function detect_apps {
298 299
     get_apps_installed_names
299 300
 }
300 301
 
302
+function app_not_on_onion_only {
303
+    app_name="$1"
304
+
305
+    read_config_param ONION_ONLY
306
+
307
+    if [[ "$ONION_ONLY" != 'no' ]]; then
308
+        if grep -q "NOT_ON_ONION=1" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}"; then
309
+            echo "0"
310
+            return
311
+        fi
312
+    fi
313
+    echo "1"
314
+}
315
+
301 316
 # detects what apps are available and can be installed
302 317
 # If the variants list within an app script is an empty string then
303 318
 # it is considered to be too experimental to be installable
@@ -318,16 +333,18 @@ function detect_installable_apps {
318 333
     do
319 334
         app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
320 335
 
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")
336
+        if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
337
+            # shellcheck disable=SC2068
338
+            if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
339
+                variants_list=$(app_variants "$filename")
340
+                # check for empty string
341
+                if [ ${#variants_list} -gt 0 ]; then
342
+                    APPS_AVAILABLE+=("${app_name}")
343
+                    APPS_CHOSEN+=("0")
344
+                    APPS_INSTALLED+=("$(app_is_installed "$app_name")")
345
+                    if [[ $(app_is_installed "$app_name") == "1" ]]; then
346
+                        APPS_INSTALLED_NAMES+=("$app_name")
347
+                    fi
331 348
                 fi
332 349
             fi
333 350
         fi
@@ -350,13 +367,15 @@ function detect_installed_apps {
350 367
     do
351 368
         app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
352 369
 
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")
370
+        if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
371
+            if [[ $(app_is_installed "$app_name") == "1" ]]; then
372
+                # shellcheck disable=SC2068
373
+                if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
374
+                    variants_list=$(app_variants "$filename")
375
+                    if [ ${#variants_list} -gt 0 ]; then
376
+                        APPS_AVAILABLE+=("${app_name}")
377
+                        APPS_INSTALLED_NAMES+=("$app_name")
378
+                    fi
360 379
                 fi
361 380
             fi
362 381
         fi
@@ -385,27 +404,28 @@ function choose_apps_for_variant {
385 404
     for filename in $FILES
386 405
     do
387 406
         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")
407
+        if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
408
+            # shellcheck disable=SC2068
409
+            if item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
410
+                if grep -q "VARIANTS=" "${filename}"; then
411
+                    variants_list=$(app_variants "$filename")
412
+                    if [[ "${variants_list}" == 'all'* || \
413
+                              "${variants_list}" == "$variant_name" || \
414
+                              "${variants_list}" == "$variant_name "* || \
415
+                              "${variants_list}" == *" $variant_name "* || \
416
+                              "${variants_list}" == *" $variant_name" ]]; then
417
+                        if [[ $(app_is_removed "${a}") == "0" ]]; then
418
+                            #echo $"${app_name} chosen"
419
+                            APPS_CHOSEN+=("1")
420
+                        else
421
+                            APPS_CHOSEN+=("0")
422
+                        fi
401 423
                     else
402 424
                         APPS_CHOSEN+=("0")
403 425
                     fi
404 426
                 else
405 427
                     APPS_CHOSEN+=("0")
406 428
                 fi
407
-            else
408
-                APPS_CHOSEN+=("0")
409 429
             fi
410 430
         fi
411 431
     done