瀏覽代碼

Loop on the about screen

Bob Mottram 7 年之前
父節點
當前提交
863eca60fb
共有 1 個檔案被更改,包括 121 行新增118 行删除
  1. 121
    118
      src/freedombone-controlpanel

+ 121
- 118
src/freedombone-controlpanel 查看文件

@@ -224,150 +224,153 @@ function show_tor_bridges {
224 224
 function show_domains {
225 225
     read_config_param "DEFAULT_DOMAIN_NAME"
226 226
 
227
-    W=()
227
+    while true
228
+    do
229
+        W=()
228 230
 
229
-    W+=("IPv4" "$(get_ipv4_address) / $(get_external_ipv4_address)")
230
-    ipv6_address="$(get_ipv6_address)"
231
-    if [ ${#ipv6_address} -gt 0 ]; then
232
-        W+=("IPv6" "${ipv6_address}")
233
-    fi
231
+        W+=("IPv4" "$(get_ipv4_address) / $(get_external_ipv4_address)")
232
+        ipv6_address="$(get_ipv6_address)"
233
+        if [ ${#ipv6_address} -gt 0 ]; then
234
+            W+=("IPv6" "${ipv6_address}")
235
+        fi
234 236
 
235
-    if [ -f /etc/ssh/ssh_host_rsa_key.pub ]; then
236
-        W+=("ssh rsa sha256" "$(awk '{print $2}' /etc/ssh/ssh_host_rsa_key.pub | base64 -d | sha256sum -b | awk '{print $1}' | xxd -r -p | base64 | sed 's|=||g')")
237
-    fi
238
-    if [ -f /etc/ssh/ssh_host_ed25519_key.pub ]; then
239
-        W+=("ssh ed25519 sha256" "$(awk '{print $2}' /etc/ssh/ssh_host_ed25519_key.pub | base64 -d | sha256sum -b | awk '{print $1}' | xxd -r -p | base64 | sed 's|=||g')")
240
-    fi
237
+        if [ -f /etc/ssh/ssh_host_rsa_key.pub ]; then
238
+            W+=("ssh rsa sha256" "$(awk '{print $2}' /etc/ssh/ssh_host_rsa_key.pub | base64 -d | sha256sum -b | awk '{print $1}' | xxd -r -p | base64 | sed 's|=||g')")
239
+        fi
240
+        if [ -f /etc/ssh/ssh_host_ed25519_key.pub ]; then
241
+            W+=("ssh ed25519 sha256" "$(awk '{print $2}' /etc/ssh/ssh_host_ed25519_key.pub | base64 -d | sha256sum -b | awk '{print $1}' | xxd -r -p | base64 | sed 's|=||g')")
242
+        fi
241 243
 
242
-    if grep -q "ssh onion domain" "$COMPLETION_FILE"; then
243
-        domain_onion=$(grep 'ssh onion domain' "${COMPLETION_FILE}" | awk -F ':' '{print $2}')
244
-        W+=("ssh" "${DEFAULT_DOMAIN_NAME} / ${domain_onion}")
245
-    fi
246
-    if grep -q "email onion domain" "$COMPLETION_FILE"; then
247
-        domain_onion=$(grep 'email onion domain' "${COMPLETION_FILE}" | awk -F ':' '{print $2}')
248
-        W+=("Email" "${DEFAULT_DOMAIN_NAME} / ${domain_onion}")
249
-    fi
250
-    if grep -q "sks onion domain" "$COMPLETION_FILE"; then
251
-        read_config_param "KEYSERVER_DOMAIN_NAME"
252
-        domain_onion=$(grep 'sks onion domain' "${COMPLETION_FILE}" | awk -F ':' '{print $2}')
253
-        W+=("SKS" "${KEYSERVER_DOMAIN_NAME} / ${domain_onion}")
254
-    fi
244
+        if grep -q "ssh onion domain" "$COMPLETION_FILE"; then
245
+            domain_onion=$(grep 'ssh onion domain' "${COMPLETION_FILE}" | awk -F ':' '{print $2}')
246
+            W+=("ssh" "${DEFAULT_DOMAIN_NAME} / ${domain_onion}")
247
+        fi
248
+        if grep -q "email onion domain" "$COMPLETION_FILE"; then
249
+            domain_onion=$(grep 'email onion domain' "${COMPLETION_FILE}" | awk -F ':' '{print $2}')
250
+            W+=("Email" "${DEFAULT_DOMAIN_NAME} / ${domain_onion}")
251
+        fi
252
+        if grep -q "sks onion domain" "$COMPLETION_FILE"; then
253
+            read_config_param "KEYSERVER_DOMAIN_NAME"
254
+            domain_onion=$(grep 'sks onion domain' "${COMPLETION_FILE}" | awk -F ':' '{print $2}')
255
+            W+=("SKS" "${KEYSERVER_DOMAIN_NAME} / ${domain_onion}")
256
+        fi
255 257
 
256
-    INTRODUCER_FILENAME=/home/tahoelafs/data/private/introducer.furl
257
-    if [ -f $INTRODUCER_FILENAME ]; then
258
-        W+=("Tahoe-LAFS" "$(cat $INTRODUCER_FILENAME)")
259
-    fi
258
+        INTRODUCER_FILENAME=/home/tahoelafs/data/private/introducer.furl
259
+        if [ -f $INTRODUCER_FILENAME ]; then
260
+            W+=("Tahoe-LAFS" "$(cat $INTRODUCER_FILENAME)")
261
+        fi
260 262
 
261
-    show_tor_bridges
263
+        show_tor_bridges
262 264
 
263
-    # shellcheck disable=SC2068
264
-    for app_name in ${APPS_INSTALLED_NAMES[@]}
265
-    do
266
-        if ! grep -q "SHOW_ON_ABOUT=1" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}"; then
267
-            continue
268
-        fi
265
+        # shellcheck disable=SC2068
266
+        for app_name in ${APPS_INSTALLED_NAMES[@]}
267
+        do
268
+            if ! grep -q "SHOW_ON_ABOUT=1" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}"; then
269
+                continue
270
+            fi
269 271
 
270
-        # handle the foibles of capitalisation
271
-        if ! grep -q "${app_name} domain" "$COMPLETION_FILE"; then
272
-            app_name_upper=$(echo "${app_name}" | awk '{print toupper($0)}')
273
-            if grep -q "${app_name_upper} domain" "$COMPLETION_FILE"; then
274
-                app_name=${app_name_upper}
275
-            else
276
-                app_name_first_upper="$(tr '[:lower:]' '[:upper:]' <<< "${app_name:0:1}")${app_name:1}"
277
-                if grep -q "${app_name_first_upper} domain" "$COMPLETION_FILE"; then
278
-                    app_name=${app_name_first_upper}
272
+            # handle the foibles of capitalisation
273
+            if ! grep -q "${app_name} domain" "$COMPLETION_FILE"; then
274
+                app_name_upper=$(echo "${app_name}" | awk '{print toupper($0)}')
275
+                if grep -q "${app_name_upper} domain" "$COMPLETION_FILE"; then
276
+                    app_name=${app_name_upper}
277
+                else
278
+                    app_name_first_upper="$(tr '[:lower:]' '[:upper:]' <<< "${app_name:0:1}")${app_name:1}"
279
+                    if grep -q "${app_name_first_upper} domain" "$COMPLETION_FILE"; then
280
+                        app_name=${app_name_first_upper}
281
+                    fi
279 282
                 fi
280 283
             fi
281
-        fi
282 284
 
283
-        if [ ${#app_name} -gt 0 ]; then
284
-            icann_address=$(get_app_icann_address "$app_name")
285
-            if grep -q "SHOW_ICANN_ADDRESS_ON_ABOUT=0" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}"; then
286
-                icann_address='-'
287
-            fi
288
-            if [[ "$ONION_ONLY" != 'no' ]]; then
289
-                if [[ "${icann_address}" != "${LOCAL_NAME}.local" ]]; then
285
+            if [ ${#app_name} -gt 0 ]; then
286
+                icann_address=$(get_app_icann_address "$app_name")
287
+                if grep -q "SHOW_ICANN_ADDRESS_ON_ABOUT=0" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}"; then
290 288
                     icann_address='-'
291 289
                 fi
292
-            fi
293
-            onion_address=$(get_app_onion_address "$app_name")
294
-            if [ ${#onion_address} -eq 0 ]; then
295
-                onion_address="-"
296
-            fi
297
-
298
-            if [[ "${icann_address}" != '-' ]]; then
299
-                if [[ "${onion_address}" != '-' ]]; then
300
-                    W+=("${app_name}" "${icann_address} / ${onion_address}")
301
-                else
302
-                    W+=("${app_name}" "${icann_address}")
290
+                if [[ "$ONION_ONLY" != 'no' ]]; then
291
+                    if [[ "${icann_address}" != "${LOCAL_NAME}.local" ]]; then
292
+                        icann_address='-'
293
+                    fi
294
+                fi
295
+                onion_address=$(get_app_onion_address "$app_name")
296
+                if [ ${#onion_address} -eq 0 ]; then
297
+                    onion_address="-"
303 298
                 fi
304
-            else
305
-                W+=("${app_name}" "${onion_address}")
306
-            fi
307 299
 
308
-            if grep -q "mobile${app_name} onion domain" "$COMPLETION_FILE"; then
309
-                onion_address=$(get_app_onion_address "${app_name}" "mobile")
310 300
                 if [[ "${icann_address}" != '-' ]]; then
311
-                    W+=("${app_name} (mobile)" "${icann_address} / ${onion_address}")
301
+                    if [[ "${onion_address}" != '-' ]]; then
302
+                        W+=("${app_name}" "${icann_address} / ${onion_address}")
303
+                    else
304
+                        W+=("${app_name}" "${icann_address}")
305
+                    fi
312 306
                 else
313
-                    W+=("${app_name} (mobile)" "${onion_address}")
307
+                    W+=("${app_name}" "${onion_address}")
308
+                fi
309
+
310
+                if grep -q "mobile${app_name} onion domain" "$COMPLETION_FILE"; then
311
+                    onion_address=$(get_app_onion_address "${app_name}" "mobile")
312
+                    if [[ "${icann_address}" != '-' ]]; then
313
+                        W+=("${app_name} (mobile)" "${icann_address} / ${onion_address}")
314
+                    else
315
+                        W+=("${app_name} (mobile)" "${onion_address}")
316
+                    fi
314 317
                 fi
315 318
             fi
316
-        fi
317
-    done
319
+        done
318 320
 
319
-    if grep -q "rss reader domain" "$COMPLETION_FILE"; then
320
-        if [ -d /var/lib/tor/hidden_service_ttrss ]; then
321
-            domain_onion=$(cat /var/lib/tor/hidden_service_ttrss/hostname)
322
-            W+=("RSS Reader" "${domain_onion}")
323
-        fi
324
-        if [ -d /var/lib/tor/hidden_service_mobilerss ]; then
325
-            domain_onion=$(cat /var/lib/tor/hidden_service_mobilerss/hostname)
326
-            W+=("RSS mobile" "${domain_onion}")
321
+        if grep -q "rss reader domain" "$COMPLETION_FILE"; then
322
+            if [ -d /var/lib/tor/hidden_service_ttrss ]; then
323
+                domain_onion=$(cat /var/lib/tor/hidden_service_ttrss/hostname)
324
+                W+=("RSS Reader" "${domain_onion}")
325
+            fi
326
+            if [ -d /var/lib/tor/hidden_service_mobilerss ]; then
327
+                domain_onion=$(cat /var/lib/tor/hidden_service_mobilerss/hostname)
328
+                W+=("RSS mobile" "${domain_onion}")
329
+            fi
327 330
         fi
328
-    fi
329 331
 
330
-    width=$(tput cols)
331
-    height=$(tput lines)
332
+        width=$(tput cols)
333
+        height=$(tput lines)
332 334
 
333
-    # shellcheck disable=SC2068
334
-    selected=$(dialog --backtitle $"Freedombone Control Panel" --title $"Domains" --menu $"Use Shift+cursors to select and copy onion addresses" $((height-4)) $((width-4)) $((height-4)) "${W[@]}" 3>&2 2>&1 1>&3)
335
-    if [ ! "$selected" ]; then
336
-        return
337
-    fi
338
-    # obtain the addresses from the key by itterating through
339
-    # the array. This is quite crude and maybe there's a better way
340
-    key_found=
341
-    selected_addresses=
342
-    for key in "${W[@]}";
343
-    do
344
-        if [ $key_found ]; then
345
-            selected_addresses="$key"
335
+        # shellcheck disable=SC2068
336
+        selected=$(dialog --backtitle $"Freedombone Control Panel" --title $"Domains" --menu $"Use Shift+cursors to select and copy onion addresses" $((height-4)) $((width-4)) $((height-4)) "${W[@]}" 3>&2 2>&1 1>&3)
337
+        if [ ! "$selected" ]; then
338
+            break
339
+        fi
340
+        # obtain the addresses from the key by itterating through
341
+        # the array. This is quite crude and maybe there's a better way
342
+        key_found=
343
+        selected_addresses=
344
+        for key in "${W[@]}";
345
+        do
346
+            if [ $key_found ]; then
347
+                selected_addresses="$key"
348
+                break
349
+            fi
350
+            if [[ "$key" == "$selected" ]]; then
351
+                key_found=1
352
+            fi
353
+        done
354
+        # Was the key matched?
355
+        if [ ! "$selected_addresses" ]; then
346 356
             break
347 357
         fi
348
-        if [[ "$key" == "$selected" ]]; then
349
-            key_found=1
358
+        # addresses were found - is this an onion?
359
+        if [[ "$selected_addresses" != *".onion"* ]]; then
360
+            continue
350 361
         fi
362
+        # There are two forms of addresses: "x / y.onion" and "x.onion"
363
+        if [[ "$selected_addresses" == *'/'* ]]; then
364
+            onion_addr=$(echo "$selected_addresses" | awk -F '/' '{print $2}' | awk -F ' ' '{print $1}')
365
+        else
366
+            onion_addr="$selected_addresses"
367
+        fi
368
+        # show the onion address as a QR code
369
+        clear
370
+        echo "$onion_addr"
371
+        echo -n "$onion_addr" | qrencode -t UTF8
372
+        any_key
351 373
     done
352
-    # Was the key matched?
353
-    if [ ! "$selected_addresses" ]; then
354
-        return
355
-    fi
356
-    # addresses were found - is this an onion?
357
-    if [[ "$selected_addresses" != *".onion"* ]]; then
358
-        return
359
-    fi
360
-    # There are two forms of addresses: "x / y.onion" and "x.onion"
361
-    if [[ "$selected_addresses" == *'/'* ]]; then
362
-        onion_addr=$(echo "$selected_addresses" | awk -F '/' '{print $2}' | awk -F ' ' '{print $1}')
363
-    else
364
-        onion_addr="$selected_addresses"
365
-    fi
366
-    # show the onion address as a QR code
367
-    clear
368
-    echo "$onion_addr"
369
-    echo -n "$onion_addr" | qrencode -t UTF8
370
-    any_key
371 374
 }
372 375
 
373 376
 function show_users {