Bob Mottram 9 anni fa
parent
commit
da3c0f5eed
1 ha cambiato i file con 56 aggiunte e 28 eliminazioni
  1. 56
    28
      src/freedombone-controlpanel

+ 56
- 28
src/freedombone-controlpanel Vedi File

@@ -53,11 +53,13 @@ function add_user {
53 53
     new_user_username=$(cat $data | sed -n 1p)
54 54
     new_user_ssh_public_key=$(cat $data | sed -n 2p)
55 55
     if [ ${#new_user_username} -lt 2 ]; then
56
-        dialog --title "New username" --msgbox "No username was given" 6 40
56
+        dialog --title "New username" \
57
+               --msgbox "No username was given" 6 40
57 58
         return
58 59
     fi
59 60
     if [[ "$new_user_username" == *" "* ]]; then
60
-        dialog --title "Invalid username" --msgbox "The username should not contain any spaces" 6 40
61
+        dialog --title "Invalid username" \
62
+               --msgbox "The username should not contain any spaces" 6 40
61 63
         return
62 64
     fi
63 65
     if [ ${#new_user_ssh_public_key} -lt 20 ]; then
@@ -70,7 +72,8 @@ function add_user {
70 72
             freedombone-adduser "$new_user_username" "$new_user_ssh_public_key"
71 73
             any_key
72 74
         else
73
-            dialog --title "ssh public key" --msgbox "This does not look like an ssh public key" 6 40
75
+            dialog --title "ssh public key" \
76
+                   --msgbox "This does not look like an ssh public key" 6 40
74 77
         fi
75 78
     fi
76 79
 }
@@ -92,7 +95,8 @@ function select_user {
92 95
         SELECTED_USERNAME=
93 96
     fi
94 97
     if [ ! -d /home/$SELECTED_USERNAME/Maildir ]; then
95
-        dialog --title "User directory check" --msgbox "This does not look like a user directory" 6 40
98
+        dialog --title "User directory check" \
99
+               --msgbox "This does not look like a user directory" 6 40
96 100
         SELECTED_USERNAME=
97 101
     fi
98 102
 }
@@ -103,7 +107,8 @@ function delete_user {
103 107
         return
104 108
     fi
105 109
     if grep -Fxq "Admin user: $SELECTED_USERNAME" $COMPLETION_FILE; then
106
-        dialog --title "Administrator user" --msgbox "You can't delete the administrator user" 6 40
110
+        dialog --title "Administrator user" \
111
+               --msgbox "You can't delete the administrator user" 6 40
107 112
         return
108 113
     fi
109 114
     clear
@@ -147,24 +152,30 @@ function add_to_mailing_list {
147 152
     LIST_EMAIL=$(cat $data | sed -n 3p)
148 153
 
149 154
     if [ ${#LIST_NAME} -lt 2 ]; then
150
-        dialog --title "Add mailing list" --msgbox "No mailing list name was given" 6 40
155
+        dialog --title "Add mailing list" \
156
+               --msgbox "No mailing list name was given" 6 40
151 157
         return
152 158
     fi
153 159
     if [ ${#LIST_SUBJECT} -lt 2 ]; then
154
-        dialog --title "Add mailing list" --msgbox "No mailing list subject was given" 6 40
160
+        dialog --title "Add mailing list" \
161
+               --msgbox "No mailing list subject was given" 6 40
155 162
         return
156 163
     fi
157 164
     if [ ${#LIST_EMAIL} -lt 2 ]; then
158
-        dialog --title "Add mailing list" --msgbox "No mailing list email address was given" 6 40
165
+        dialog --title "Add mailing list" \
166
+               --msgbox "No mailing list email address was given" 6 40
159 167
         return
160 168
     fi
161 169
     if [[ "$LIST_EMAIL" != *"@"* || "$LIST_EMAIL" != *"."* ]]; then
162
-        dialog --title "Add mailing list" --msgbox "Unrecognised email address" 6 40
170
+        dialog --title "Add mailing list" \
171
+               --msgbox "Unrecognised email address" 6 40
163 172
         return
164 173
     fi
165 174
 
166
-    freedombone-addlist -u $SELECTED_USERNAME -l "$LIST_NAME" -s "$LIST_SUBJECT" -e "$LIST_EMAIL"
167
-    dialog --title "Add mailing list" --msgbox "$LIST_NAME list was added" 6 40
175
+    freedombone-addlist -u $SELECTED_USERNAME -l "$LIST_NAME" \
176
+                        -s "$LIST_SUBJECT" -e "$LIST_EMAIL"
177
+    dialog --title "Add mailing list" \
178
+           --msgbox "$LIST_NAME list was added" 6 40
168 179
 }
169 180
 
170 181
 function email_rule {
@@ -189,20 +200,25 @@ function email_rule {
189 200
     RULE_FOLDER=$(cat $data | sed -n 2p)
190 201
 
191 202
     if [ ${#RULE_EMAIL} -lt 2 ]; then
192
-        dialog --title "Add email rule" --msgbox "No email address was given" 6 40
203
+        dialog --title "Add email rule" \
204
+               --msgbox "No email address was given" 6 40
193 205
         return
194 206
     fi
195 207
     if [ ${#RULE_FOLDER} -lt 2 ]; then
196
-        dialog --title "Add email rule" --msgbox "No folder name was given" 6 40
208
+        dialog --title "Add email rule" \
209
+               --msgbox "No folder name was given" 6 40
197 210
         return
198 211
     fi
199 212
     if [[ "$RULE_EMAIL" != *"@"* || "$RULE_EMAIL" != *"."* ]]; then
200
-        dialog --title "Add email rule" --msgbox "Unrecognised email address" 6 40
213
+        dialog --title "Add email rule" \
214
+               --msgbox "Unrecognised email address" 6 40
201 215
         return
202 216
     fi
203 217
 
204
-    freedombone-addemail -u $SELECTED_USERNAME -e "$RULE_EMAIL" -g "$RULE_FOLDER"
205
-    dialog --title "Add email rule" --msgbox "Email rule for $RULE_EMAIL was added" 6 40
218
+    freedombone-addemail -u $SELECTED_USERNAME -e "$RULE_EMAIL" \
219
+                         -g "$RULE_FOLDER"
220
+    dialog --title "Add email rule" \
221
+           --msgbox "Email rule for $RULE_EMAIL was added" 6 40
206 222
 }
207 223
 
208 224
 function block_unblock_email {
@@ -226,19 +242,23 @@ function block_unblock_email {
226 242
     BLOCK_EMAIL=$(cat $data | sed -n 1p)
227 243
     BLOCK=$(cat $data | sed -n 2p)
228 244
     if [ ${#BLOCK_EMAIL} -lt 2 ]; then
229
-        dialog --title "Block/Unblock an email" --msgbox "No email address was given" 6 40
245
+        dialog --title "Block/Unblock an email" \
246
+               --msgbox "No email address was given" 6 40
230 247
         return
231 248
     fi
232 249
     if [[ "$BLOCK_EMAIL" != *"@"* || "$BLOCK_EMAIL" != *"."* ]]; then
233
-        dialog --title "Block/Unblock an email" --msgbox "Unrecognised email address" 6 40
250
+        dialog --title "Block/Unblock an email" \
251
+               --msgbox "Unrecognised email address" 6 40
234 252
         return
235 253
     fi
236 254
     if [[ $BLOCK == "y"* || $BLOCK == "Y"* ]]; then
237 255
         freedombone-ignore -u $SELECTED_USERNAME -e "$BLOCK_EMAIL"
238
-        dialog --title "Block an email" --msgbox "Email from $BLOCK_EMAIL to $SELECTED_USERNAME blocked" 6 40
256
+        dialog --title "Block an email" \
257
+               --msgbox "Email from $BLOCK_EMAIL to $SELECTED_USERNAME blocked" 6 40
239 258
     else
240 259
         freedombone-unignore -u $SELECTED_USERNAME -e "$BLOCK_EMAIL"
241
-        dialog --title "Unblock an email" --msgbox "Email from $BLOCK_EMAIL to $SELECTED_USERNAME unblocked" 6 40
260
+        dialog --title "Unblock an email" \
261
+               --msgbox "Email from $BLOCK_EMAIL to $SELECTED_USERNAME unblocked" 6 40
242 262
     fi
243 263
 }
244 264
 
@@ -263,15 +283,18 @@ function block_unblock_subject {
263 283
     BLOCK_SUBJECT=$(cat $data | sed -n 1p)
264 284
     BLOCK=$(cat $data | sed -n 2p)
265 285
     if [ ${#BLOCK_SUBJECT} -lt 2 ]; then
266
-        dialog --title "Block/Unblock an email" --msgbox "No subject was given" 6 40
286
+        dialog --title "Block/Unblock an email" \
287
+               --msgbox "No subject was given" 6 40
267 288
         return
268 289
     fi
269 290
     if [[ $BLOCK == "y"* || $BLOCK == "Y"* ]]; then
270 291
         freedombone-ignore -u $SELECTED_USERNAME -t "$BLOCK_SUBJECT"
271
-        dialog --title "Block an email" --msgbox "Email with subject $BLOCK_SUBJECT to $SELECTED_USERNAME blocked" 6 40
292
+        dialog --title "Block an email" \
293
+               --msgbox "Email with subject $BLOCK_SUBJECT to $SELECTED_USERNAME blocked" 6 40
272 294
     else
273 295
         freedombone-unignore -u $SELECTED_USERNAME -t "$BLOCK_SUBJECT"
274
-        dialog --title "Unblock an email" --msgbox "Email with subject $BLOCK_SUBJECT to $SELECTED_USERNAME unblocked" 6 40
296
+        dialog --title "Unblock an email" \
297
+               --msgbox "Email with subject $BLOCK_SUBJECT to $SELECTED_USERNAME unblocked" 6 40
275 298
     fi
276 299
 }
277 300
 
@@ -280,7 +303,8 @@ function create_keydrive_master {
280 303
     if [ ! $SELECTED_USERNAME ]; then
281 304
         return
282 305
     fi
283
-    dialog --title "USB Master Keydrive" --msgbox "Plug in a LUKS encrypted USB drive" 6 40
306
+    dialog --title "USB Master Keydrive" \
307
+           --msgbox "Plug in a LUKS encrypted USB drive" 6 40
284 308
     clear
285 309
     freedombone-keydrive -u $SELECTED_USERNAME --master 'yes'
286 310
     any_key
@@ -291,21 +315,24 @@ function create_keydrive_fragment {
291 315
     if [ ! $SELECTED_USERNAME ]; then
292 316
         return
293 317
     fi
294
-    dialog --title "USB Fragment Keydrive" --msgbox "Plug in a LUKS encrypted USB drive" 6 40
318
+    dialog --title "USB Fragment Keydrive" \
319
+           --msgbox "Plug in a LUKS encrypted USB drive" 6 40
295 320
     clear
296 321
     freedombone-keydrive -u $SELECTED_USERNAME
297 322
     any_key
298 323
 }
299 324
 
300 325
 function backup_data {
301
-    dialog --title "Backup data to USB" --msgbox "Plug in a LUKS encrypted USB drive" 6 40
326
+    dialog --title "Backup data to USB" \
327
+           --msgbox "Plug in a LUKS encrypted USB drive" 6 40
302 328
     clear
303 329
     backup
304 330
     any_key
305 331
 }
306 332
 
307 333
 function restore_data {
308
-    dialog --title "Restore data from USB" --msgbox "Plug in your backup USB drive" 6 40
334
+    dialog --title "Restore data from USB" \
335
+           --msgbox "Plug in your backup USB drive" 6 40
309 336
     clear
310 337
     restore
311 338
     any_key
@@ -332,7 +359,8 @@ function restore_gpg_key {
332 359
     if [ ! $SELECTED_USERNAME ]; then
333 360
         return
334 361
     fi
335
-    dialog --title "Restore GPG key for user $SELECTED_USERNAME" --msgbox "Plug in your USB keydrive" 6 40
362
+    dialog --title "Restore GPG key for user $SELECTED_USERNAME" \
363
+           --msgbox "Plug in your USB keydrive" 6 40
336 364
     clear
337 365
     freedombone-recoverkey -u $SELECTED_USERNAME
338 366
     any_key