Pārlūkot izejas kodu

Tidying interactive config

Bob Mottram 8 gadus atpakaļ
vecāks
revīzija
8cc9916d9c
2 mainītis faili ar 64 papildinājumiem un 150 dzēšanām
  1. 0
    150
      src/freedombone-config
  2. 64
    0
      src/freedombone-utils-keys

+ 0
- 150
src/freedombone-config Parādīt failu

@@ -251,52 +251,6 @@ function choose_default_domain_name {
251 251
     save_configuration_values
252 252
 }
253 253
 
254
-function choose_static_ip {
255
-    if [[ $MINIMAL_INSTALL == "no" && $ONION_ONLY == "no" ]]; then
256
-        SET_STATIC_IP="no"
257
-        dialog --title $"Static local IP address" \
258
-               --backtitle $"Freedombone Configuration" \
259
-               --defaultno \
260
-               --yesno $"\nDo you want to set a static local IP address for this system?\n\nFor example, 192.168.1.10" 10 60
261
-        sel=$?
262
-        case $sel in
263
-            0) SET_STATIC_IP="yes";;
264
-            255) exit 1;;
265
-        esac
266
-
267
-        if [[ $SET_STATIC_IP == "yes" ]]; then
268
-            if [ ! $LOCAL_NETWORK_STATIC_IP_ADDRESS ]; then
269
-                LOCAL_NETWORK_STATIC_IP_ADDRESS=$(grep 'LOCAL_NETWORK_STATIC_IP_ADDRESS' temp.cfg | awk -F '=' '{print $2}')
270
-                if [ ! $LOCAL_NETWORK_STATIC_IP_ADDRESS ]; then
271
-                    LOCAL_NETWORK_STATIC_IP_ADDRESS='192.168..'
272
-                fi
273
-            fi
274
-            if [ ! $ROUTER_IP_ADDRESS ]; then
275
-                ROUTER_IP_ADDRESS=$(grep 'ROUTER_IP_ADDRESS' temp.cfg | awk -F '=' '{print $2}')
276
-                if [ ! $ROUTER_IP_ADDRESS ]; then
277
-                    ROUTER_IP_ADDRESS='192.168..'
278
-                fi
279
-            fi
280
-            data=$(tempfile 2>/dev/null)
281
-            trap "rm -f $data" 0 1 2 5 15
282
-            dialog --backtitle $"Freedombone Configuration" \
283
-                   --title $"Local Network Configuration" \
284
-                   --form $"\nPlease enter the IP addresses:" 11 55 3 \
285
-                   $"This system:" 1 1 "$LOCAL_NETWORK_STATIC_IP_ADDRESS" 1 16 16 15 \
286
-                   $"Internet router:" 2 1 "$ROUTER_IP_ADDRESS" 2 16 16 15 \
287
-                   2> $data
288
-            sel=$?
289
-            case $sel in
290
-                1) exit 1;;
291
-                255) exit 1;;
292
-            esac
293
-            LOCAL_NETWORK_STATIC_IP_ADDRESS=$(cat $data | sed -n 1p)
294
-            ROUTER_IP_ADDRESS=$(cat $data | sed -n 2p)
295
-            save_configuration_values
296
-        fi
297
-    fi
298
-}
299
-
300 254
 function choose_dynamic_dns {
301 255
     if [[ $SYSTEM_TYPE != "mesh"* && $ONION_ONLY == "no" ]]; then
302 256
 
@@ -659,31 +613,6 @@ function choose_social_key_management {
659 613
     fi
660 614
 }
661 615
 
662
-function choose_beaglebone_options {
663
-    if [[ $MINIMAL_INSTALL == "no" ]]; then
664
-        if [[ $(grep "INSTALLING_ON_BBB" temp.cfg | awk -F '=' '{print $2}') == "yes" ]]; then
665
-            dialog --title $"Install Target" \
666
-                   --backtitle $"Freedombone Configuration" \
667
-                   --yesno $"\nAre you installing onto a Beaglebone Black?" 7 60
668
-        else
669
-            dialog --title $"Install Target" \
670
-                   --backtitle $"Freedombone Configuration" \
671
-                   --defaultno \
672
-                   --yesno $"\nAre you installing onto a Beaglebone Black?" 7 60
673
-        fi
674
-        sel=$?
675
-        case $sel in
676
-            0) INSTALLING_ON_BBB="yes";;
677
-            1) INSTALLING_ON_BBB="no";;
678
-            255) exit 1;;
679
-        esac
680
-        if [[ $INSTALLING_ON_BBB == "yes" ]]; then
681
-            USB_DRIVE=/dev/sda1
682
-        fi
683
-        save_configuration_values
684
-    fi
685
-}
686
-
687 616
 function choose_username {
688 617
     if [ -d /home/$GENERIC_IMAGE_USERNAME ]; then
689 618
         if [ ! -f $IMAGE_PASSWORD_FILE ]; then
@@ -875,83 +804,6 @@ do
875 804
     shift
876 805
 done
877 806
 
878
-# test a domain name to see if it's valid
879
-function validate_domain_name {
880
-    # count the number of dots in the domain name
881
-    dots=${TEST_DOMAIN_NAME//[^.]}
882
-    no_of_dots=${#dots}
883
-    if (( no_of_dots > 3 )); then
884
-        TEST_DOMAIN_NAME="The domain $TEST_DOMAIN_NAME has too many subdomains. It should be of the type w.x.y.z, x.y.z or y.z"
885
-    fi
886
-    if (( no_of_dots == 0 )); then
887
-        TEST_DOMAIN_NAME="The domain $TEST_DOMAIN_NAME has no top level domain. It should be of the type w.x.y.z, x.y.z or y.z"
888
-    fi
889
-}
890
-
891
-function interactive_gpg_from_remote {
892
-    REMOTE_SERVERS_LIST=/home/$MY_USERNAME/keyshareservers.txt
893
-
894
-    # get a list of remote servers
895
-    ${PROJECT_NAME}-remote -u $MY_USERNAME -l $REMOTE_SERVERS_LIST -t "Remote server"
896
-
897
-    if [ ! -f $REMOTE_SERVERS_LIST ]; then
898
-        dialog --title $"Encryption keys" --msgbox $'Error obtaining server list' 6 70
899
-        return 1
900
-    fi
901
-
902
-    # check the number of entries in the file
903
-    no_of_servers=$(cat $REMOTE_SERVERS_LIST | wc -l)
904
-    if (( no_of_servers < 3 )); then
905
-        dialog --title $"Encryption keys" \
906
-               --msgbox $'There must be at least three servers to recover the key' 6 70
907
-        return 2
908
-    fi
909
-
910
-    # try to recover the key from the servers
911
-    apt-get -yq install libgfshare-bin gnupg
912
-    ${PROJECT_NAME}-recoverkey -u $MY_USERNAME -l $REMOTE_SERVERS_LIST
913
-    if [ ! "$?" = "0" ]; then
914
-        dialog --title $"Encryption keys" --msgbox $'Your key could not be recovered' 6 70
915
-        return 3
916
-    fi
917
-
918
-    dialog --title $"Encryption keys" --msgbox $'Your key has been recovered' 6 70
919
-
920
-    return 0
921
-}
922
-
923
-function interactive_gpg {
924
-    GPG_CONFIGURED="no"
925
-    while [[ $GPG_CONFIGURED != "yes" ]]
926
-    do
927
-        GPG_CONFIGURED="yes"
928
-        data=$(tempfile 2>/dev/null)
929
-        trap "rm -f $data" 0 1 2 5 15
930
-        dialog --backtitle $"Freedombone Configuration" \
931
-               --radiolist $"GPG/PGP keys for your system:" 13 70 3 \
932
-               1 $"Generate new keys (new user)" on \
933
-               2 $"Import keys from USB drive/s" off \
934
-               3 $"Retrieve keys from friends servers" off 2> $data
935
-        sel=$?
936
-        case $sel in
937
-            1) exit 1;;
938
-            255) exit 2;;
939
-        esac
940
-        case $(cat $data) in
941
-            1) if [ -d /home/${MY_USERNAME}/.gnupg ]; then
942
-                   rm -rf /home/${MY_USERNAME}/.gnupg
943
-               fi
944
-               break;;
945
-            2) interactive_gpg_from_usb
946
-               break;;
947
-            3) interactive_gpg_from_remote
948
-               if [ ! "$?" = "0" ]; then
949
-                   GPG_CONFIGURED="no"
950
-               fi;;
951
-        esac
952
-    done
953
-}
954
-
955 807
 function set_main_repo {
956 808
     data=$(tempfile 2>/dev/null)
957 809
     trap "rm -f $data" 0 1 2 5 15
@@ -1207,14 +1059,12 @@ function interactive_config {
1207 1059
     set_main_repo
1208 1060
     choose_username
1209 1061
     choose_full_name
1210
-    choose_beaglebone_options
1211 1062
     choose_social_key_management
1212 1063
     choose_rng
1213 1064
     choose_debian_repo
1214 1065
     choose_dns
1215 1066
     ${PROJECT_NAME}-wifi --networksinteractive $WIFI_NETWORKS_FILE
1216 1067
     choose_dynamic_dns
1217
-    choose_static_ip
1218 1068
     choose_default_domain_name
1219 1069
     choose_email_address
1220 1070
 

+ 64
- 0
src/freedombone-utils-keys Parādīt failu

@@ -163,4 +163,68 @@ function interactive_gpg_from_usb {
163 163
     done
164 164
 }
165 165
 
166
+function interactive_gpg_from_remote {
167
+    REMOTE_SERVERS_LIST=/home/$MY_USERNAME/keyshareservers.txt
168
+
169
+    # get a list of remote servers
170
+    ${PROJECT_NAME}-remote -u $MY_USERNAME -l $REMOTE_SERVERS_LIST -t "Remote server"
171
+
172
+    if [ ! -f $REMOTE_SERVERS_LIST ]; then
173
+        dialog --title $"Encryption keys" --msgbox $'Error obtaining server list' 6 70
174
+        return 1
175
+    fi
176
+
177
+    # check the number of entries in the file
178
+    no_of_servers=$(cat $REMOTE_SERVERS_LIST | wc -l)
179
+    if (( no_of_servers < 3 )); then
180
+        dialog --title $"Encryption keys" \
181
+               --msgbox $'There must be at least three servers to recover the key' 6 70
182
+        return 2
183
+    fi
184
+
185
+    # try to recover the key from the servers
186
+    apt-get -yq install libgfshare-bin gnupg
187
+    ${PROJECT_NAME}-recoverkey -u $MY_USERNAME -l $REMOTE_SERVERS_LIST
188
+    if [ ! "$?" = "0" ]; then
189
+        dialog --title $"Encryption keys" --msgbox $'Your key could not be recovered' 6 70
190
+        return 3
191
+    fi
192
+
193
+    dialog --title $"Encryption keys" --msgbox $'Your key has been recovered' 6 70
194
+
195
+    return 0
196
+}
197
+
198
+function interactive_gpg {
199
+    GPG_CONFIGURED="no"
200
+    while [[ $GPG_CONFIGURED != "yes" ]]
201
+    do
202
+        GPG_CONFIGURED="yes"
203
+        data=$(tempfile 2>/dev/null)
204
+        trap "rm -f $data" 0 1 2 5 15
205
+        dialog --backtitle $"Freedombone Configuration" \
206
+               --radiolist $"GPG/PGP keys for your system:" 13 70 3 \
207
+               1 $"Generate new keys (new user)" on \
208
+               2 $"Import keys from USB drive/s" off \
209
+               3 $"Retrieve keys from friends servers" off 2> $data
210
+        sel=$?
211
+        case $sel in
212
+            1) exit 1;;
213
+            255) exit 2;;
214
+        esac
215
+        case $(cat $data) in
216
+            1) if [ -d /home/${MY_USERNAME}/.gnupg ]; then
217
+                   rm -rf /home/${MY_USERNAME}/.gnupg
218
+               fi
219
+               break;;
220
+            2) interactive_gpg_from_usb
221
+               break;;
222
+            3) interactive_gpg_from_remote
223
+               if [ ! "$?" = "0" ]; then
224
+                   GPG_CONFIGURED="no"
225
+               fi;;
226
+        esac
227
+    done
228
+}
229
+
166 230
 # NOTE: deliberately there is no "exit 0"