Browse Source

Fixing interactive installer

Bob Mottram 10 years ago
parent
commit
2fec0b17ff
2 changed files with 65 additions and 63 deletions
  1. 55
    58
      src/freedombone-config
  2. 10
    5
      src/freedombone-remote

+ 55
- 58
src/freedombone-config View File

245
   REMOTE_SERVERS_LIST=/home/$MY_USERNAME/keyshareservers.txt
245
   REMOTE_SERVERS_LIST=/home/$MY_USERNAME/keyshareservers.txt
246
 
246
 
247
   # get a list of remote servers
247
   # get a list of remote servers
248
-  freedombone-remote -u $MY_USERNAME -l $REMOTE_SERVERS_LIST
249
-  if [ ! "$?" = "0" ]; then
250
-      echo "1"
251
-      return
252
-  fi
248
+  freedombone-remote -u $MY_USERNAME -l $REMOTE_SERVERS_LIST -t "Remote server"
253
 
249
 
254
   if [ ! -f $REMOTE_SERVERS_LIST ]; then
250
   if [ ! -f $REMOTE_SERVERS_LIST ]; then
255
-      echo "2"
251
+      dialog --title "Encryption keys" --msgbox 'Error obtaining server list' 6 70
252
+      echo "1"
256
       return
253
       return
257
   fi
254
   fi
258
-  
255
+
259
   # check the number of entries in the file
256
   # check the number of entries in the file
260
   no_of_servers=$(cat $REMOTE_SERVERS_LIST | wc -l)
257
   no_of_servers=$(cat $REMOTE_SERVERS_LIST | wc -l)
261
   if [[ ${no_of_servers} < 3 ]]; then
258
   if [[ ${no_of_servers} < 3 ]]; then
262
       dialog --title "Encryption keys" --msgbox 'There must be at least three servers to recover the key' 6 70
259
       dialog --title "Encryption keys" --msgbox 'There must be at least three servers to recover the key' 6 70
263
-      echo "3"
260
+      echo "2"
264
       return
261
       return
265
   fi
262
   fi
266
-  
263
+
267
   # try to recover the key from the servers
264
   # try to recover the key from the servers
268
   freedombone-recoverkey -u $MY_USERNAME -l $REMOTE_SERVERS_LIST
265
   freedombone-recoverkey -u $MY_USERNAME -l $REMOTE_SERVERS_LIST
269
   if [ ! "$?" = "0" ]; then
266
   if [ ! "$?" = "0" ]; then
270
       dialog --title "Encryption keys" --msgbox 'Your key could not be recovered' 6 70
267
       dialog --title "Encryption keys" --msgbox 'Your key could not be recovered' 6 70
271
-      echo "4"
268
+      echo "3"
272
       return
269
       return
273
   fi
270
   fi
274
 
271
 
346
       data=$(tempfile 2>/dev/null)
343
       data=$(tempfile 2>/dev/null)
347
       trap "rm -f $data" 0 1 2 5 15
344
       trap "rm -f $data" 0 1 2 5 15
348
       dialog --backtitle "Freedombone Configuration" \
345
       dialog --backtitle "Freedombone Configuration" \
349
-          --radiolist "GPG/PGP keys for your system:" 17 40 3 \
346
+          --radiolist "GPG/PGP keys for your system:" 13 70 3 \
350
           1 "Generate new keys (new user)" on \
347
           1 "Generate new keys (new user)" on \
351
           2 "Import keys from a USB drive" off \
348
           2 "Import keys from a USB drive" off \
352
           3 "Retrieve keys from friends servers" off 2> $data
349
           3 "Retrieve keys from friends servers" off 2> $data
353
       sel=$?
350
       sel=$?
354
       case $sel in
351
       case $sel in
355
-          1) exit 0;;
356
-          255) exit 0;;
352
+          1) exit 123;;
353
+          255) exit 234;;
357
       esac
354
       esac
358
       case $(cat $data) in
355
       case $(cat $data) in
359
           1) return;;
356
           1) return;;
360
           2) interactive_gpg_from_usb
357
           2) interactive_gpg_from_usb
361
              return;;
358
              return;;
362
-          3) retval=interactive_gpg_from_remote
363
-             if [[ retval != '0' ]]; then
359
+          3) interactive_gpg_from_remote
360
+			 if [ ! "$?" = "0" ]; then
364
                  GPG_CONFIGURED="no"
361
                  GPG_CONFIGURED="no"
365
              fi;;
362
              fi;;
366
       esac
363
       esac
393
       9 Developer off 2> $data
390
       9 Developer off 2> $data
394
   sel=$?
391
   sel=$?
395
   case $sel in
392
   case $sel in
396
-      1) exit 0;;
397
-      255) exit 0;;
393
+      1) exit 1;;
394
+      255) exit 1;;
398
   esac
395
   esac
399
   case $(cat $data) in
396
   case $(cat $data) in
400
       1) SYSTEM_TYPE=$VARIANT_FULL;;
397
       1) SYSTEM_TYPE=$VARIANT_FULL;;
417
   sel=$?
414
   sel=$?
418
   case $sel in
415
   case $sel in
419
       0) MY_USERNAME=$(cat $data | awk -F '/' '{print $3}');;
416
       0) MY_USERNAME=$(cat $data | awk -F '/' '{print $3}');;
420
-      1) exit 0;;
421
-      255) exit 0;;
417
+      1) exit 1;;
418
+      255) exit 1;;
422
   esac
419
   esac
423
   if [ ! $MY_USERNAME ]; then
420
   if [ ! $MY_USERNAME ]; then
424
       echo 'No user account was selected'
421
       echo 'No user account was selected'
452
   case $sel in
449
   case $sel in
453
       0) INSTALLING_ON_BBB="yes";;
450
       0) INSTALLING_ON_BBB="yes";;
454
       1) INSTALLING_ON_BBB="no";;
451
       1) INSTALLING_ON_BBB="no";;
455
-      255) exit 0;;
452
+      255) exit 1;;
456
   esac
453
   esac
457
   if [[ $INSTALLING_ON_BBB == "yes" ]]; then
454
   if [[ $INSTALLING_ON_BBB == "yes" ]]; then
458
       USB_DRIVE=/dev/sda1
455
       USB_DRIVE=/dev/sda1
478
   fi
475
   fi
479
   sel=$?
476
   sel=$?
480
   case $sel in
477
   case $sel in
481
-      1) exit 0;;
482
-      255) exit 0;;
478
+      1) exit 1;;
479
+      255) exit 1;;
483
   esac
480
   esac
484
   case $(cat $data) in
481
   case $(cat $data) in
485
       2) HWRNG_TYPE="beaglebone";;
482
       2) HWRNG_TYPE="beaglebone";;
486
       3) HWRNG_TYPE="onerng";;
483
       3) HWRNG_TYPE="onerng";;
487
-      255) exit 0;;
484
+      255) exit 1;;
488
   esac
485
   esac
489
   save_configuration_file
486
   save_configuration_file
490
 
487
 
543
       49 "United States" on 2> $data
540
       49 "United States" on 2> $data
544
   sel=$?
541
   sel=$?
545
   case $sel in
542
   case $sel in
546
-      1) exit 0;;
547
-      255) exit 0;;
543
+      1) exit 1;;
544
+      255) exit 1;;
548
   esac
545
   esac
549
   case $(cat $data) in
546
   case $(cat $data) in
550
       1) DEBIAN_REPO='ftp.au.debian.org';;
547
       1) DEBIAN_REPO='ftp.au.debian.org';;
596
       47) DEBIAN_REPO='ftp.ua.debian.org';;
593
       47) DEBIAN_REPO='ftp.ua.debian.org';;
597
       48) DEBIAN_REPO='ftp.uk.debian.org';;
594
       48) DEBIAN_REPO='ftp.uk.debian.org';;
598
       49) DEBIAN_REPO='ftp.us.debian.org';;
595
       49) DEBIAN_REPO='ftp.us.debian.org';;
599
-      255) exit 0;;
596
+      255) exit 1;;
600
   esac
597
   esac
601
   save_configuration_file
598
   save_configuration_file
602
 
599
 
622
       16 "Google" off 2> $data
619
       16 "Google" off 2> $data
623
   sel=$?
620
   sel=$?
624
   case $sel in
621
   case $sel in
625
-      1) exit 0;;
626
-      255) exit 0;;
622
+      1) exit 1;;
623
+      255) exit 1;;
627
   esac
624
   esac
628
   case $(cat $data) in
625
   case $(cat $data) in
629
       1) NAMESERVER1='85.214.73.63'
626
       1) NAMESERVER1='85.214.73.63'
674
       16) NAMESERVER1='8.8.8.8'
671
       16) NAMESERVER1='8.8.8.8'
675
           NAMESERVER2='4.4.4.4'
672
           NAMESERVER2='4.4.4.4'
676
           ;;
673
           ;;
677
-      255) exit 0;;
674
+      255) exit 1;;
678
   esac
675
   esac
679
   save_configuration_file
676
   save_configuration_file
680
 
677
 
698
       14 changeip off 2> $data
695
       14 changeip off 2> $data
699
   sel=$?
696
   sel=$?
700
   case $sel in
697
   case $sel in
701
-      1) exit 0;;
702
-      255) exit 0;;
698
+      1) exit 1;;
699
+      255) exit 1;;
703
   esac
700
   esac
704
   case $(cat $data) in
701
   case $(cat $data) in
705
       1) DDNS_PROVIDER="default@dyndns.org";;
702
       1) DDNS_PROVIDER="default@dyndns.org";;
716
       12) DDNS_PROVIDER="default@sitelutions.com";;
713
       12) DDNS_PROVIDER="default@sitelutions.com";;
717
       13) DDNS_PROVIDER="default@dnsexit.com";;
714
       13) DDNS_PROVIDER="default@dnsexit.com";;
718
       14) DDNS_PROVIDER="default@changeip.com";;
715
       14) DDNS_PROVIDER="default@changeip.com";;
719
-      255) exit 0;;
716
+      255) exit 1;;
720
   esac
717
   esac
721
   save_configuration_file
718
   save_configuration_file
722
 
719
 
729
       sel=$?
726
       sel=$?
730
       case $sel in
727
       case $sel in
731
           0) DDNS_USERNAME=$(cat $data);;
728
           0) DDNS_USERNAME=$(cat $data);;
732
-          1) exit 0;;
733
-          255) exit 0;;
729
+          1) exit 1;;
730
+          255) exit 1;;
734
       esac
731
       esac
735
   done
732
   done
736
   save_configuration_file
733
   save_configuration_file
746
       sel=$?
743
       sel=$?
747
       case $sel in
744
       case $sel in
748
           0) DDNS_PASSWORD=$(cat $data);;
745
           0) DDNS_PASSWORD=$(cat $data);;
749
-          1) exit 0;;
750
-          255) exit 0;;
746
+          1) exit 1;;
747
+          255) exit 1;;
751
       esac
748
       esac
752
       if [ ${#DDNS_PASSWORD} -lt $MINIMUM_PASSWORD_LENGTH ]; then
749
       if [ ${#DDNS_PASSWORD} -lt $MINIMUM_PASSWORD_LENGTH ]; then
753
           dialog --title "Password quality check" --msgbox "The password given was too short. It must be at least $MINIMUM_PASSWORD_LENGTH characters. You may need to change your password on the dynamic DNS provider's web site." 10 40
750
           dialog --title "Password quality check" --msgbox "The password given was too short. It must be at least $MINIMUM_PASSWORD_LENGTH characters. You may need to change your password on the dynamic DNS provider's web site." 10 40
765
       sel=$?
762
       sel=$?
766
       case $sel in
763
       case $sel in
767
           0) MY_NAME=$(cat $data);;
764
           0) MY_NAME=$(cat $data);;
768
-          1) exit 0;;
769
-          255) exit 0;;
765
+          1) exit 1;;
766
+          255) exit 1;;
770
       esac
767
       esac
771
   done
768
   done
772
   save_configuration_file
769
   save_configuration_file
793
       2> $data
790
       2> $data
794
   sel=$?
791
   sel=$?
795
   case $sel in
792
   case $sel in
796
-      1) exit 0;;
797
-      255) exit 0;;
793
+      1) exit 1;;
794
+      255) exit 1;;
798
   esac
795
   esac
799
   LOCAL_NETWORK_STATIC_IP_ADDRESS=$(cat $data | sed -n 1p)
796
   LOCAL_NETWORK_STATIC_IP_ADDRESS=$(cat $data | sed -n 1p)
800
   ROUTER_IP_ADDRESS=$(cat $data | sed -n 2p)
797
   ROUTER_IP_ADDRESS=$(cat $data | sed -n 2p)
825
           fi
822
           fi
826
           sel=$?
823
           sel=$?
827
           case $sel in
824
           case $sel in
828
-              1) exit 0;;
829
-              255) exit 0;;
825
+              1) exit 1;;
826
+              255) exit 1;;
830
           esac
827
           esac
831
           WIKI_TITLE=$(cat $data | sed -n 1p)
828
           WIKI_TITLE=$(cat $data | sed -n 1p)
832
           WIKI_DOMAIN_NAME=$(cat $data | sed -n 2p)
829
           WIKI_DOMAIN_NAME=$(cat $data | sed -n 2p)
877
           fi
874
           fi
878
           sel=$?
875
           sel=$?
879
           case $sel in
876
           case $sel in
880
-              1) exit 0;;
881
-              255) exit 0;;
877
+              1) exit 1;;
878
+              255) exit 1;;
882
           esac
879
           esac
883
           MY_BLOG_TITLE=$(cat $data | sed -n 1p)
880
           MY_BLOG_TITLE=$(cat $data | sed -n 1p)
884
           FULLBLOG_DOMAIN_NAME=$(cat $data | sed -n 2p)
881
           FULLBLOG_DOMAIN_NAME=$(cat $data | sed -n 2p)
930
           fi
927
           fi
931
           sel=$?
928
           sel=$?
932
           case $sel in
929
           case $sel in
933
-              1) exit 0;;
934
-              255) exit 0;;
930
+              1) exit 1;;
931
+              255) exit 1;;
935
           esac
932
           esac
936
           OWNCLOUD_DOMAIN_NAME=$(cat $data | sed -n 1p)
933
           OWNCLOUD_DOMAIN_NAME=$(cat $data | sed -n 1p)
937
           if [ $OWNCLOUD_DOMAIN_NAME ]; then
934
           if [ $OWNCLOUD_DOMAIN_NAME ]; then
979
           fi
976
           fi
980
           sel=$?
977
           sel=$?
981
           case $sel in
978
           case $sel in
982
-              1) exit 0;;
983
-              255) exit 0;;
979
+              1) exit 1;;
980
+              255) exit 1;;
984
           esac
981
           esac
985
           REDMATRIX_DOMAIN_NAME=$(cat $data | sed -n 1p)
982
           REDMATRIX_DOMAIN_NAME=$(cat $data | sed -n 1p)
986
           if [ $REDMATRIX_DOMAIN_NAME ]; then
983
           if [ $REDMATRIX_DOMAIN_NAME ]; then
1028
           fi
1025
           fi
1029
           sel=$?
1026
           sel=$?
1030
           case $sel in
1027
           case $sel in
1031
-              1) exit 0;;
1032
-              255) exit 0;;
1028
+              1) exit 1;;
1029
+              255) exit 1;;
1033
           esac
1030
           esac
1034
           MICROBLOG_DOMAIN_NAME=$(cat $data | sed -n 1p)
1031
           MICROBLOG_DOMAIN_NAME=$(cat $data | sed -n 1p)
1035
           if [ $MICROBLOG_DOMAIN_NAME ]; then
1032
           if [ $MICROBLOG_DOMAIN_NAME ]; then
1081
           fi
1078
           fi
1082
           sel=$?
1079
           sel=$?
1083
           case $sel in
1080
           case $sel in
1084
-              1) exit 0;;
1085
-              255) exit 0;;
1081
+              1) exit 1;;
1082
+              255) exit 1;;
1086
           esac
1083
           esac
1087
           GIT_DOMAIN_NAME=$(cat $data | sed -n 1p)
1084
           GIT_DOMAIN_NAME=$(cat $data | sed -n 1p)
1088
           if [ $GIT_DOMAIN_NAME ]; then
1085
           if [ $GIT_DOMAIN_NAME ]; then
1124
                  2> $data
1121
                  2> $data
1125
           sel=$?
1122
           sel=$?
1126
           case $sel in
1123
           case $sel in
1127
-              1) exit 0;;
1128
-              255) exit 0;;
1124
+              1) exit 1;;
1125
+              255) exit 1;;
1129
           esac
1126
           esac
1130
           DEFAULT_DOMAIN_NAME=$(cat $data | sed -n 1p)
1127
           DEFAULT_DOMAIN_NAME=$(cat $data | sed -n 1p)
1131
           DEFAULT_DOMAIN_CODE=$(cat $data | sed -n 2p)
1128
           DEFAULT_DOMAIN_CODE=$(cat $data | sed -n 2p)
1142
           sel=$?
1139
           sel=$?
1143
           case $sel in
1140
           case $sel in
1144
               0) DEFAULT_DOMAIN_NAME=$(cat $data);;
1141
               0) DEFAULT_DOMAIN_NAME=$(cat $data);;
1145
-              1) exit 0;;
1146
-              255) exit 0;;
1142
+              1) exit 1;;
1143
+              255) exit 1;;
1147
           esac
1144
           esac
1148
       fi
1145
       fi
1149
       if [ $DEFAULT_DOMAIN_NAME ]; then
1146
       if [ $DEFAULT_DOMAIN_NAME ]; then
1176
       sel=$?
1173
       sel=$?
1177
       case $sel in
1174
       case $sel in
1178
           0) MY_EMAIL_ADDRESS=$(cat $data);;
1175
           0) MY_EMAIL_ADDRESS=$(cat $data);;
1179
-          1) exit 0;;
1180
-          255) exit 0;;
1176
+          1) exit 1;;
1177
+          255) exit 1;;
1181
       esac
1178
       esac
1182
   done
1179
   done
1183
 
1180
 

+ 10
- 5
src/freedombone-remote View File

42
 # How many remote locations were specified
42
 # How many remote locations were specified
43
 entering_remote_backups_ctr=0
43
 entering_remote_backups_ctr=0
44
 
44
 
45
+# Title shown
46
+TITLE='Remote Backup'
47
+
45
 function show_help {
48
 function show_help {
46
   echo ''
49
   echo ''
47
   echo 'freedombone-remote -u [username] -l [backup list filename] -m [min password length]'
50
   echo 'freedombone-remote -u [username] -l [backup list filename] -m [min password length]'
53
   echo '  -u --username         User to create the backups.list file for'
56
   echo '  -u --username         User to create the backups.list file for'
54
   echo '  -l --list             Remote backup list (usually /home/$USER/backup.list)'
57
   echo '  -l --list             Remote backup list (usually /home/$USER/backup.list)'
55
   echo '  -m --min              Minimum password length (characters)'
58
   echo '  -m --min              Minimum password length (characters)'
59
+  echo '  -t --title            Title shown'
56
   echo ''
60
   echo ''
57
   exit 0
61
   exit 0
58
 }
62
 }
82
     shift
86
     shift
83
     MINIMUM_PASSWORD_LENGTH="$1"
87
     MINIMUM_PASSWORD_LENGTH="$1"
84
     ;;
88
     ;;
89
+    # Title shown
90
+    -t|--title)
91
+    shift
92
+    TITLE="$1"
93
+    ;;
85
     *)
94
     *)
86
     # unknown option
95
     # unknown option
87
     ;;
96
     ;;
119
       data=$(tempfile 2>/dev/null)
128
       data=$(tempfile 2>/dev/null)
120
       trap "rm -f $data" 0 1 2 5 15
129
       trap "rm -f $data" 0 1 2 5 15
121
       dialog --backtitle "Freedombone Configuration" \
130
       dialog --backtitle "Freedombone Configuration" \
122
-          --title "Remote Backup ${entering_remote_backups_ctr}" \
131
+          --title "$TITLE ${entering_remote_backups_ctr}" \
123
           --form "\nPlease specify the SSH login details:" 11 55 4 \
132
           --form "\nPlease specify the SSH login details:" 11 55 4 \
124
           "Username:" 1 1 "" 1 16 16 15 \
133
           "Username:" 1 1 "" 1 16 16 15 \
125
           "Domain:" 2 1 "" 2 16 16 15 \
134
           "Domain:" 2 1 "" 2 16 16 15 \
153
   if [ -f $FRIENDS_SERVERS_LIST ]; then
162
   if [ -f $FRIENDS_SERVERS_LIST ]; then
154
       chown $MY_USERNAME:$MY_USERNAME $FRIENDS_SERVERS_LIST
163
       chown $MY_USERNAME:$MY_USERNAME $FRIENDS_SERVERS_LIST
155
   fi
164
   fi
156
-
157
-  if [[ ${entering_remote_backups_ctr} > 3 ]]; then
158
-
159
-  fi
160
 }
165
 }
161
 
166
 
162
 function show_result {
167
 function show_result {