Преглед на файлове

Optionally recover keys from a master keydrive during interactive install

Bob Mottram преди 8 години
родител
ревизия
f57f273519
променени са 2 файла, в които са добавени 30 реда и са изтрити 4 реда
  1. 1
    0
      src/freedombone-config
  2. 29
    4
      src/freedombone-utils-keys

+ 1
- 0
src/freedombone-config Целия файл

1067
     choose_dynamic_dns
1067
     choose_dynamic_dns
1068
     choose_default_domain_name
1068
     choose_default_domain_name
1069
     choose_email_address
1069
     choose_email_address
1070
+    interactive_key_recovery
1070
 
1071
 
1071
     # delete the temporary configuration file
1072
     # delete the temporary configuration file
1072
     if [ -f temp.cfg ]; then
1073
     if [ -f temp.cfg ]; then

+ 29
- 4
src/freedombone-utils-keys Целия файл

126
             fi
126
             fi
127
         fi
127
         fi
128
 
128
 
129
+        if [ -d $GPG_USB_MOUNT/letsencrypt ]; then
130
+            if [ ! -d /etc/letsencrypt ]; then
131
+                mkdir /etc/letsencrypt
132
+            fi
133
+            echo $'Recovering LetsEncrypt keys'
134
+            cp -r $GPG_USB_MOUNT/letsencrypt/* /etc/letsencrypt
135
+        fi
136
+
129
         if [ -d $GPG_USB_MOUNT/.gnupg ]; then
137
         if [ -d $GPG_USB_MOUNT/.gnupg ]; then
130
             if [ ! -d $HOME_DIR/.gnupg ]; then
138
             if [ ! -d $HOME_DIR/.gnupg ]; then
131
                 mkdir $HOME_DIR/.gnupg
139
                 mkdir $HOME_DIR/.gnupg
132
             fi
140
             fi
141
+            echo $'Recovering GPG keys'
133
             cp -r $GPG_USB_MOUNT/.gnupg/* $HOME_DIR/.gnupg
142
             cp -r $GPG_USB_MOUNT/.gnupg/* $HOME_DIR/.gnupg
134
             GPG_LOADING="no"
143
             GPG_LOADING="no"
135
             dialog --title $"Recover Encryption Keys" \
144
             dialog --title $"Recover Encryption Keys" \
170
     ${PROJECT_NAME}-remote -u $MY_USERNAME -l $REMOTE_SERVERS_LIST -t "Remote server"
179
     ${PROJECT_NAME}-remote -u $MY_USERNAME -l $REMOTE_SERVERS_LIST -t "Remote server"
171
 
180
 
172
     if [ ! -f $REMOTE_SERVERS_LIST ]; then
181
     if [ ! -f $REMOTE_SERVERS_LIST ]; then
173
-        dialog --title $"Encryption keys" --msgbox $'Error obtaining server list' 6 70
182
+        dialog --title $"Encryption Keys Recovery" --msgbox $'Error obtaining server list' 6 70
174
         return 1
183
         return 1
175
     fi
184
     fi
176
 
185
 
177
     # check the number of entries in the file
186
     # check the number of entries in the file
178
     no_of_servers=$(cat $REMOTE_SERVERS_LIST | wc -l)
187
     no_of_servers=$(cat $REMOTE_SERVERS_LIST | wc -l)
179
     if (( no_of_servers < 3 )); then
188
     if (( no_of_servers < 3 )); then
180
-        dialog --title $"Encryption keys" \
189
+        dialog --title $"Encryption Keys Recovery" \
181
                --msgbox $'There must be at least three servers to recover the key' 6 70
190
                --msgbox $'There must be at least three servers to recover the key' 6 70
182
         return 2
191
         return 2
183
     fi
192
     fi
186
     apt-get -yq install libgfshare-bin gnupg
195
     apt-get -yq install libgfshare-bin gnupg
187
     ${PROJECT_NAME}-recoverkey -u $MY_USERNAME -l $REMOTE_SERVERS_LIST
196
     ${PROJECT_NAME}-recoverkey -u $MY_USERNAME -l $REMOTE_SERVERS_LIST
188
     if [ ! "$?" = "0" ]; then
197
     if [ ! "$?" = "0" ]; then
189
-        dialog --title $"Encryption keys" --msgbox $'Your key could not be recovered' 6 70
198
+        dialog --title $"Encryption Keys Recovery" --msgbox $'Your key could not be recovered' 6 70
190
         return 3
199
         return 3
191
     fi
200
     fi
192
 
201
 
193
-    dialog --title $"Encryption keys" --msgbox $'Your key has been recovered' 6 70
202
+    dialog --title $"Encryption Keys Recovery" --msgbox $'Your key has been recovered' 6 70
194
 
203
 
195
     return 0
204
     return 0
196
 }
205
 }
227
     done
236
     done
228
 }
237
 }
229
 
238
 
239
+function interactive_key_recovery {
240
+    data=$(tempfile 2>/dev/null)
241
+    trap "rm -f $data" 0 1 2 5 15
242
+
243
+    dialog --title $"Encryption Keys Recovery" \
244
+           --backtitle $"Freedombone Configuration" \
245
+           --defaultno \
246
+           --yesno $"Do you wish to recover your previous encryption keys from a USB master keydrive?" 7 60
247
+    sel=$?
248
+    case $sel in
249
+        1) return;;
250
+        255) return;;
251
+    esac
252
+    ${PROJECT_NAME}-recoverkey -u $MY_USERNAME
253
+}
254
+
230
 # NOTE: deliberately there is no "exit 0"
255
 # NOTE: deliberately there is no "exit 0"