浏览代码

Fixing interactive installer

Bob Mottram 9 年前
父节点
当前提交
2fec0b17ff
共有 2 个文件被更改,包括 65 次插入63 次删除
  1. 55
    58
      src/freedombone-config
  2. 10
    5
      src/freedombone-remote

+ 55
- 58
src/freedombone-config 查看文件

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

+ 10
- 5
src/freedombone-remote 查看文件

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