forked from simoniz0r/gpgpassman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpgpassman.sh
executable file
·641 lines (632 loc) · 27.2 KB
/
gpgpassman.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
#!/bin/bash
# A script that uses 'gpg' to encrypt and decrypt passwords stored in '~/.gpgpassman'.
# Dependencies: 'gpg', 'xclip', 'wget' (optional; for auto-updating gpgpassman), 'apg' (optional; for generationg passwords), 'zenity' (optional; for GUI)
# If you have 'zenity' installed, executing 'gpgpassman gui' will show a full GUI for all of the scripts options.
# Also with 'zenity', you can execuite 'gpgpassman dec' for direct access to decrypting passwords; can be used with a keybind.
# Written by simonizor 3/22/2017 - http://www.simonizor.gq/linuxapps
GPMVER="1.3.5"
X="v1.3.5 - Cleaned up quite a few things."
# ^^Remember to update this every release and do not move their position!
SCRIPTNAME="$0"
GPMDIR="$(< ~/.config/gpgpassman/gpgpassman.conf)"
GPMINITDIR=~/.gpgpassman
GPMCONFDIR=~/.config/gpgpassman
SERVNAME="$2"
bold=$(tput bold)
normal=$(tput sgr0)
updatescript () {
cat >/tmp/updatescript.sh <<EOL
runupdate () {
if [ "$SCRIPTNAME" = "/usr/bin/gpgpassman" ]; then
wget -O /tmp/gpgpassman.sh "https://raw.githubusercontent.com/jmfgdev/gpgpassman/master/gpgpassman.sh"
if [ -f "/tmp/gpgpassman.sh" ]; then
sudo rm -f /usr/bin/gpgpassman
sudo mv /tmp/gpgpassman.sh /usr/bin/gpgpassman
sudo chmod +x /usr/bin/gpgpassman
else
read -p "Update Failed! Try again? Y/N " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
runupdate
else
echo "gpgpassman was not updated!"
exit 0
fi
fi
else
wget -O /tmp/gpgpassman.sh "https://raw.githubusercontent.com/jmfgdev/gpgpassman/master/gpgpassman.sh"
if [ -f "/tmp/gpgpassman.sh" ]; then
rm -f $SCRIPTNAME
mv /tmp/gpgpassman.sh $SCRIPTNAME
chmod +x $SCRIPTNAME
else
read -p "Update Failed! Try again? Y/N " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
runupdate
else
echo "gpgpassman was not updated!"
exit 0
fi
fi
fi
if [ -f $SCRIPTNAME ]; then
echo "Update finished!"
rm -f /tmp/updatescript.sh
if type zenity >/dev/null 2>&1; then
read -p "Press ENTER to continue"
nohup $SCRIPTNAME gui
exit 0
else
exec $SCRIPTNAME
fi
else
read -p "Update Failed! Try again? Y/N " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
runupdate
else
echo "gpgpassman was not updated!"
exit 0
fi
fi
}
runupdate
EOL
}
updatecheck () {
echo "Checking for new version..."
UPNOTES="$(wget -q "https://raw.githubusercontent.com/jmfgdev/gpgpassman/master/gpgpassman.sh" -O - | sed -n '9p' | tr -d 'X="')"
VERTEST="$(wget -q "https://raw.githubusercontent.com/jmfgdev/gpgpassman/master/gpgpassman.sh" -O - | sed -n '8p' | tr -d 'GPMVER="')"
if [[ $GPMVER < $VERTEST ]]; then
echo "Installed version: $GPMVER -- Current version: $VERTEST"
echo "A new version is available!"
echo $UPNOTES
read -p "Would you like to update? Y/N " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo
echo "Creating update script..."
updatescript
chmod +x /tmp/updatescript.sh
echo "Running update script..."
exec /tmp/updatescript.sh
exit 0
else
if [ "$ZHEADLESS" = "1" ]; then
echo
read -p "Press ENTER to continue"
nohup $SCRIPTNAME gui
exit 0
elif [ "$ZHEADLESS" = "0" ];then
noguimain
exit 0
else
echo
echo "gpgpassman was not updated."
fi
fi
else
if [ "$ZHEADLESS" = "1" ]; then
echo "Installed version: $GPMVER -- Current version: $VERTEST"
echo $UPNOTES
echo "gpgpassman is up to date."
echo
read -p "Press ENTER to continue"
nohup $SCRIPTNAME gui
exit 0
elif [ "$ZHEADLESS" = "0" ];then
echo "Installed version: $GPMVER -- Current version: $VERTEST"
echo $UPNOTES
echo "gpgpassman is up to date."
echo
noguimain
exit 0
else
echo "Installed version: $GPMVER -- Current version: $VERTEST"
echo $UPNOTES
echo "gpgpassman is up to date."
fi
fi
}
programisinstalled () {
# set to 1 initially
return=1
# set to 0 if not found
type "$1" >/dev/null 2>&1 || { return=0; }
# return value
}
helpfunc () {
echo "Currently managed services: $(dir $GPMDIR)"
echo "Current password storage directory: $GPMDIR"
echo
echo "${bold}Usage:"
echo "${bold}add${normal} - Add encrypted password file."
echo "- Ex: 'gpgpassman add servicename'"
echo "${bold}dec${normal} - Decrypt a stored password file using the service name and copy to clipboard for 45 seconds."
echo "- Ex: 'gpgpassman dec servicename'"
echo "${bold}bac${normal} - Backup your passwords to a new directory."
echo "- Ex: 'gpgpassman bac /home/simonizor/passwordbackup'"
echo "- Can also be executed as 'gpgpassman dec' to launch a zenity window to input service or launch terminal if zenity is not installed."
echo "${bold}rem${normal} - Remove a stored password file using the service name."
echo "- Ex: 'gpgpassman rem servicename'"
echo "${bold}dir${normal} - Change default directory used by gpgpassman. Only passwords in the currently configured directory will be able to be managed."
echo "- Ex: 'gpgpassman dir /path/to/directory'."
echo "${bold}gen${normal} - Generate new passwords using 'apg'."
echo "- Ex: 'gpgpassman gen'"
echo "${bold}gui${normal} - If 'zenity' is installed, gpgpassman's GUI will be launched."
echo "- Ex: 'gpgpassman gui'"
}
zenitymain () {
TERMPID=$(pgrep -l x-term)
ZMAINCASE=$(kill -9 $TERMPID; zenity --list --cancel-label=Exit --width=540 --height=460 --title=gpgpassman --text="Welcome to gpgpassman v$GPMVER\n\ngpgpassman is a password manager that uses 'gpg' for encryption.\n\nPassword storage directory:\n$GPMDIR\n\nManaged passwords:\n$(dir $GPMDIR)\n\nWhat would you like to do?" --column="Cases" --hide-header "Add a new encrypted password" "Decrypt a stored password" "Backup your stored passwords" "Remove a stored password" "Change password storage directory" "Generate passwords using 'apg'" "Check for gpgpassman update")
if [[ $? -eq 1 ]]; then
exit 0
fi
ZHEADLESS="1"
main "$ZMAINCASE"
}
noguimain () {
echo "What would you like to do?"
echo "${bold}Add${normal} an encrypted password."
echo "${bold}Decrypt${normal} a stored password."
echo "${bold}Backup${normal} your passwords."
echo "${bold}Remove${normal} a stored password."
echo "${bold}Change${normal} the default password storage directory."
echo "${bold}Generate${normal} new passwords using 'apg'."
echo "${bold}Help${normal}"
echo "${bold}Exit${normal}"
read -p "Choice? " -r
echo
main "$REPLY"
exit 0
}
main () {
case $1 in
add*|Add*)
if [ -z $SERVNAME ]; then
if [ "$ZHEADLESS" = "1" ]; then
SERVNAME=$(zenity --entry --title=gpgpassman --cancel-label="Main menu" --width=540 --height=460 --text="Add a new encrypted password.\n\nYou will be prompted for two different password inputs.\nThe first is the password that you use to login to the service.\nThe second is the password used for gpg encryption.\n\nYou will be prompted to overwrite already managed services.\n\n\n\n\n\n\n\n\n\n\nEnter the service name to encrypt a password for:")
if [[ $? -eq 1 ]]; then
SERVNAME=""
zenitymain
exit 0
fi
else
read -p "Input the service name to encrypt a password for: " SERVNAME
fi
fi
if [ -f "$GPMDIR/$SERVNAME/$SERVNAME.gpg" ];then
if [ "$ZHEADLESS" = "1" ]; then
zenity --question --text="Password for $SERVNAME is already stored; overwrite (clipboard will also be cleared)?" --cancel-label=No --ok-label=Yes
if [[ $? -eq 1 ]]; then
zenity --warning --text="Password for $SERVNAME was not overwritten."
SERVNAME=""
zenitymain
exit 0
else
echo -n "$(gpg -d $GPMDIR/$SERVNAME/$SERVNAME.gpg)" | xclip -selection c -i
if [ "$(xclip -selection c -o)" = "" ]; then
zenity --error --text="Wrong password or gpg failure!"
SERVNAME=""
main "add"
exit 0
fi
zenity --warning --text="Stored password for $SERVNAME removed"
rm -f $GPMDIR/$SERVNAME/$SERVNAME.gpg
fi
else
read -p "Password for $SERVNAME is already stored; overwrite (clipboard will also be cleared)? Y/N"
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo "Password for $SERVNAME was not overwritten."
exit 0
else
echo -n "$(gpg -d $GPMDIR/$SERVNAME/$SERVNAME.gpg)" | xclip -selection c -i
if [ "$(xclip -selection c -o)" = "" ]; then
echo "Wrong password or gpg failure!"
exit 0
fi
echo -n "Password cleared from clipboard" | xclip -selection c -i
fi
fi
fi
if [ -z $SERVNAME ]; then
if [ "$ZHEADLESS" = "1" ]; then
zenity --error --timeout=5 --text="No service name entered; try again."
SERVNAME=""
main "add"
exit 0
else
echo "No service name entered; try again."
SERVNAME=""
main "add"
exit 0
fi
fi
if [ "$ZHEADLESS" = "1" ]; then
PASSINPUT=$(zenity --entry --hide-text --text="Enter your password for $SERVNAME:")
if [[ $? -eq 1 ]]; then
SERVNAME=""
zenitymain
exit 0
fi
PASSINPUT2=$(zenity --entry --hide-text --text="Input password again for $SERVNAME:")
if [[ $? -eq 1 ]]; then
SERVNAME=""
zenitymain
exit 0
fi
else
echo "Input your password for $SERVNAME:"
read -s PASSINPUT
echo
echo "Input password again for $SERVNAME:"
read -s PASSINPUT2
echo
fi
if [ "$PASSINPUT" != "$PASSINPUT2" ]; then
if [ "$ZHEADLESS" = "1" ]; then
zenity --error --text="Passwords to not match; try again!"
SERVNAME=""
main "add"
exit 0
else
echo "Passwords do not match; try again!"
SERVNAME=""
main "add"
exit 0
fi
fi
if [ ! -d "$GPMDIR" ]; then
mkdir $GPMDIR
fi
if [ ! -d "$GPMDIR/$SERVNAME" ]; then
mkdir $GPMDIR/$SERVNAME
fi
if [ "$ZHEADLESS" = "1" ]; then
zenity --warning --timeout=5 --text="Enter the password to be used for encryption/decryption:"
fi
echo $PASSINPUT | gpg -c -o $GPMDIR/$SERVNAME/$SERVNAME.gpg
if [ -f "$GPMDIR/$SERVNAME/$SERVNAME.gpg" ]; then
if [ "$ZHEADLESS" = "1" ]; then
zenity --warning --text="Password for $SERVNAME encrypted in $GPMDIR/$SERVNAME/$SERVNAME.gpg"
SERVNAME=""
zenitymain
exit 0
else
echo "Password for $SERVNAME encrypted in $GPMDIR/$SERVNAME/$SERVNAME.gpg"
fi
else
if [ "$ZHEADLESS" = "1" ]; then
zenity --error --text="Failed to write encrypted file for $SERVNAME in $GPMDIR/$SERVNAME/$SERVNAME.gpg"
SERVNAME=""
zenitymain
exit 0
else
echo "Failed to write encrypted file for $SERVNAME in $GPMDIR/$SERVNAME/$SERVNAME.gpg"
fi
fi
;;
dec*|Dec*)
if [ -z "$SERVNAME" ]; then
if [ $ZHEADLESS = "0" ]; then
read -p "Input the service name to decrypt a password for: " SERVNAME
else
programisinstalled "zenity"
if [ $return = "1" ];then
ZHEADLESS="1"
SERVNAME=$(zenity --file-selection --file-filter=*.gpg --title="gpgpassman -- Select the gpg file to decrypt" --filename=$GPMDIR/)
if [[ $? -eq 1 ]]; then
SERVNAME=""
zenitymain
exit 0
fi
ZHEADLESS="1"
else
read -p "Enter the service name to decrypt password for: " SERVNAME
fi
fi
fi
if [ -f "$GPMDIR/$SERVNAME/$SERVNAME.gpg" ];then
echo "Decrypting password for $SERVNAME"
sleep 0.5
echo -n "$(gpg -d $GPMDIR/$SERVNAME/$SERVNAME.gpg)" | xclip -selection c -i
if [ "$(xclip -selection c -o)" = "" ]; then
echo "Wrong password or gpg failure!"
exit 0
fi
echo "$SERVNAME password copied to clipboard; clipboard will be cleared after 45 seconds..."
trap '{ echo ; echo "Keyboard interruppt; clearing password..." ; echo -n "Password cleared from clipboard" | xclip -selection c -i ; echo "Password cleard from clipboard." ; exit 0 ; }' INT
sleep 45
echo -n "Password cleared from clipboard" | xclip -selection c -i
echo "Password cleard from clipboard."
elif [ "$ZHEADLESS" = "1" ]; then
echo -n "$(gpg -d $SERVNAME)" | xclip -selection c -i
if [ "$(xclip -selection c -o)" = "" ]; then
zenity --error --text="Wrong password or gpg failure!"
SERVNAME=""
main "dec"
exit 0
fi
zenity --forms --timeout=45 --text="Copied password to clipboard; clipboard will be cleared after 45 seconds..." --cancel-label="Clear now and return to main" --ok-label="Clear now and close"
if [[ $? -eq 1 ]]; then
echo -n "Password cleared from clipboard" | xclip -selection c -i
SERVNAME=""
zenitymain
exit 0
else
echo -n "Password cleared from clipboard" | xclip -selection c -i
fi
else
if [ "$ZHEADLESS" = "1" ]; then
zenity --error --timeout=5 --text="No password found for $SERVNAME"
SERVNAME=""
main "dec"
exit 0
fi
echo "No password found for $SERVNAME"
fi
;;
bac*|Bac*)
if [ -z $SERVNAME ]; then
if [ "$ZHEADLESS" = "1" ]; then
SERVNAME=$(zenity --file-selection --directory --title="gpgpassman -- Select a location to back up your passwords")
if [[ $? -eq 1 ]]; then
SERVNAME=""
zenitymain
exit 0
fi
else
read -p "Input the full directory to backup your passwords to. Ex: '/home/simonizor/passwordbackup': " SERVNAME
fi
fi
if [ "${SERVNAME: -1}" = "/" ]; then
SERVNAME="${SERVNAME::-1}"
fi
if [[ "$SERVNAME" == /* ]]; then
if [ ! -d $SERVNAME ]; then
mkdir $SERVNAME
if [ "$ZHEADLESS" = "1" ]; then
zenity --warning --timeout=5 --text="$SERVNAME directory created for password backup."
else
echo "$SERVNAME directory created for password backup."
fi
fi
cp -r $GPMDIR/* $SERVNAME/
if [ "$ZHEADLESS" = "1" ]; then
zenity --warning --timeout=5 --text="Passwords have been backed up to $SERVNAME."
SERVNAME=""
zenitymain
exit 0
else
echo "Passwords have been backed up to $SERVNAME."
fi
else
if [ "$ZHEADLESS" = "1" ]; then
zenity --error --timeout=5 --text="$SERVNAME is not a valid directory; use full directory path. Ex: '/home/simonizor/passwordbackup'"
SERVNAME=""
main "dir"
exit 0
else
echo "$SERVNAME is not a valid directory; use full directory path. Ex: 'gpgpassman bac /home/simonizor/passwordbackup'"
helpfunc
fi
fi
;;
rem*|Rem*)
if [ -z "$SERVNAME" ]; then
if [ "$ZHEADLESS" = "1" ]; then
SERVNAME=$(zenity --entry --cancel-label="Main menu" --width=540 --height=460 --title=gpgpassman --text="Remove an encrypted password.\n\nThe password for the service name you enter will be deleted permanently!\nYou will be asked for the gpg encryption password before removal.\n\nPassword storage directory:\n$GPMDIR\n\nManaged services:\n$(dir $GPMDIR)\n\n\n\n\n\nEnter the service name to remove:")
if [[ $? -eq 1 ]]; then
SERVNAME=""
zenitymain
exit 0
fi
else
read -p "Input the service name for the password you want to remove: " SERVNAME
fi
fi
if [ -f "$GPMDIR/$SERVNAME/$SERVNAME.gpg" ];then
if [ "$ZHEADLESS" = "1" ]; then
zenity --question --text="Passwords cannot be recovered; are you sure you want to remove password for $SERVNAME?" --ok-label="Yes"
if [[ $? -eq 1 ]]; then
zenity --warning --text="Password for $SERVNAME was not removed."
SERVNAME=""
zenitymain
exit 0
else
echo -n "$(gpg -d $GPMDIR/$SERVNAME/$SERVNAME.gpg)" | xclip -selection c -i
if [ "$(xclip -selection c -o)" = "" ]; then
zenity --error --text="Wrong password or gpg failure!"
SERVNAME=""
main "rem"
exit 0
fi
echo -n "Password cleared from clipboard" | xclip -selection c -i
rm -rf $GPMDIR/$SERVNAME
zenity --warning --text="Password for $SERVNAME was removed!"
SERVNAME=""
zenitymain
exit 0
fi
else
read -p "Passwords cannot be recovered; are you sure you want to remove the encrypted password for $SERVNAME? Y/N " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo -n "$(gpg -d $GPMDIR/$SERVNAME/$SERVNAME.gpg)" | xclip -selection c -i
if [ "$(xclip -selection c -o)" = "" ]; then
echo "Wrong password or gpg failure!"
exit 0
fi
echo -n "Password cleared from clipboard" | xclip -selection c -i
rm -rf $GPMDIR/$SERVNAME
echo "Password for $SERVNAME removed!"
else
echo "Password for $SERVNAME was not removed."
fi
fi
else
if [ "$ZHEADLESS" = "1" ]; then
zenity --error --timeout=5 --text="No password found for $SERVNAME"
SERVNAME=""
zenitymain
exit 0
else
echo "No password found for $SERVNAME"
fi
fi
;;
dir*|Change*|change*)
if [ -z $SERVNAME ]; then
if [ "$ZHEADLESS" = "1" ]; then
SERVNAME=$(zenity --file-selection --directory --title="gpgpassman -- Select a new password storage directory")
if [[ $? -eq 1 ]]; then
SERVNAME=""
zenitymain
exit 0
fi
zenity --question --text="Only one directory can be managed by gpgpassman at a time; change password storage directory to $SERVNAME?" --ok-label="Yes"
if [[ $? -eq 1 ]]; then
SERVNAME=""
zenitymain
exit 0
fi
else
read -p "Input the full directory to change password storage to. Ex: '/home/simonizor/mypasswords': " SERVNAME
fi
fi
if [ "${SERVNAME: -1}" = "/" ]; then
SERVNAME="${SERVNAME::-1}"
fi
if [[ "$SERVNAME" == /* ]]; then
echo "$SERVNAME" > $GPMCONFDIR/gpgpassman.conf
if [ ! -d $SERVNAME ]; then
mkdir $SERVNAME
if [ "$ZHEADLESS" = "1" ]; then
zenity --warning --timeout=5 --text="$SERVNAME directory created for gpgpassman storage."
else
echo "$SERVNAME directory created for gpgpassman storage."
fi
fi
if [ "$ZHEADLESS" = "1" ]; then
zenity --warning --timeout=5 --text="gpgpassman storage directory changed to $(< ~/.config/gpgpassman/gpgpassman.conf)"
SERVNAME=""
zenitymain
exit 0
else
echo "gpgpassman storage directory changed to $(< ~/.config/gpgpassman/gpgpassman.conf)"
fi
else
if [ "$ZHEADLESS" = "1" ]; then
zenity --error --timeout=5 --text="$SERVNAME is not a valid directory; use full directory path. Ex: '/home/simonizor/mypasswords'"
SERVNAME=""
main "dir"
exit 0
else
echo "$SERVNAME is not a valid directory; use full directory path. Ex: 'gpgpassman dir /home/simonizor/mypasswords'"
helpfunc
fi
fi
;;
gen*|Gen*)
programisinstalled "apg"
if [ "$return" = "1" ]; then
if [ "$ZHEADLESS" = "1" ]; then
{ echo "Passwords generated using 'apg -a 1 -m 30 -n 4':" ; apg -a 1 -m 30 -n 4 ; } | zenity --text-info --cancel-label=Exit --width=540 --height=460 --title=gpgpassman
if [[ $? -eq 1 ]]; then
exit 0
fi
zenitymain
exit 0
else
echo "Passwords generated using 'apg -a 1 -m 30 -n 4':"
apg -a 1 -m 30 -n 4
echo
read -p "Press ENTER to continue; terminal window will be cleared"
tput reset
fi
else
if [ "$ZHEADLESS" = "1" ]; then
zenity --error --title=gpgpassman --text="apg is not installed; cannot generate passwords!"
zenitymain
exit 0
else
echo "apg is not installed!"
fi
fi
;;
h*)
echo "gpgpassman - http://www.simonizor.gq/linuxapps"
echo "A script that uses 'gpg' to encrypt and decrypt passwords."
helpfunc
echo
programisinstalled "wget"
if [ $return = "1" ]; then
updatecheck
fi
;;
Check*)
programisinstalled "wget"
if [ "$return" = "1" ]; then
x-terminal-emulator -e $SCRIPTNAME UPD
exit 0
else
zenity --error --text="'wget' is not installed; cannot check for updates!"
SERVNAME=""
zenitymain
exit 0
fi
;;
UPD)
ZHEADLESS="1"
updatecheck
;;
gui)
programisinstalled "zenity"
if [ $return = "1" ]; then
zenitymain
else
echo "gpgpassman - http://www.simonizor.gq/linuxapps"
echo "A script that uses 'gpg' to encrypt and decrypt passwords."
echo "gpgpassman now has a GUI; install 'zenity' to check it out!"
echo
programisinstalled "wget"
if [ $return = "1" ]; then
updatecheck
fi
echo
noguimain
fi
;;
exit*|Exit*)
exit 0
;;
*)
echo "gpgpassman - http://www.simonizor.gq/linuxapps"
echo "A script that uses 'gpg' to encrypt and decrypt passwords."
helpfunc
echo
programisinstalled "wget"
if [ $return = "1" ]; then
updatecheck
fi
;;
esac
}
if [ ! -f "$GPMCONFDIR/gpgpassman.conf" ]; then
echo "$GPMCONFDIR does not exist; creating..."
mkdir $GPMCONFDIR
mkdir $GPMINITDIR
echo "$GPMINITDIR" > $GPMCONFDIR/gpgpassman.conf
zenity --error --text="$GPMCONFDIR created and config file written; rung gpgpassman again." || echo "$GPMCONFDIR created and config file written; run gpgpassman again."
exit 0
fi
programisinstalled "gpg"
if [ $return = "1" ]; then
programisinstalled "xclip"
if [ $return = "1" ]; then
main "$1"
else
zenity --error --text="xclip is not installed!" || echo "xclip is not installed!"
exit 1
fi
else
zenity --error --text="gpg is not installed!" || echo "gpg is not installed!"
exit 1
fi