2015-04-13 10:47:00 +02:00
|
|
|
#!/bin/bash
|
2015-07-07 14:48:39 +02:00
|
|
|
########################################################################
|
|
|
|
# Copyright (C) 2015 Max Mehl <mail@mehl.mx>
|
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# Creates a graphical list of strong passwords generated by apg.
|
|
|
|
# The user is able to modify the settings in the dialogue
|
|
|
|
#
|
|
|
|
########################################################################
|
|
|
|
|
2016-12-16 11:49:50 +01:00
|
|
|
function checkexit {
|
|
|
|
if [ $1 = 1 ]; then exit 1; fi
|
|
|
|
}
|
2015-04-13 10:47:00 +02:00
|
|
|
|
2018-01-21 13:48:40 +01:00
|
|
|
if [ $(zenity --question --cancel-label "More options" --ok-label "Close" --text "$(apg -m 16 -M NCL -a 0)" --title "Generated Passwords"; echo $?) == 1 ]; then
|
2015-04-13 10:47:00 +02:00
|
|
|
|
|
|
|
# More options requested
|
|
|
|
PLEN=$(zenity --entry --text "Desired length of password(s)" --title "Enter password length")
|
2016-12-16 11:49:50 +01:00
|
|
|
checkexit $?
|
|
|
|
|
|
|
|
PALG=$(zenity --list \
|
|
|
|
--text="Choose between random character or pronouncable passwords" \
|
|
|
|
--title="Choose password algorithm" \
|
|
|
|
--column="Option" --column="Description" \
|
|
|
|
1 "Random character passwords" \
|
|
|
|
0 "Pronouncable password algorithm" \
|
|
|
|
)
|
|
|
|
checkexit $?
|
|
|
|
PALG=$(echo $PALG | sed 's/|//g')
|
|
|
|
|
2015-04-13 10:47:00 +02:00
|
|
|
POPT=$(zenity --list --multiple \
|
2016-12-16 11:49:50 +01:00
|
|
|
--text="Choose one or multiple generator options" \
|
|
|
|
--title="Choose password options" \
|
|
|
|
--column="Option" --column="Description" \
|
2015-04-13 10:47:00 +02:00
|
|
|
N "Numerical" \
|
|
|
|
C "Capital letters" \
|
|
|
|
L "Lower case letters" \
|
|
|
|
)
|
2016-12-16 11:49:50 +01:00
|
|
|
checkexit $?
|
2015-04-13 10:47:00 +02:00
|
|
|
POPT=$(echo $POPT | sed 's/|//g')
|
2016-12-16 11:49:50 +01:00
|
|
|
|
2015-04-13 10:47:00 +02:00
|
|
|
PAMT=$(zenity --entry --text "Desired amount of generated passwords" --title "Enter password amount")
|
2016-12-16 11:49:50 +01:00
|
|
|
checkexit $?
|
2015-04-13 10:47:00 +02:00
|
|
|
|
|
|
|
# Set defaults if no entry was given
|
|
|
|
if [ "$PLEN" == "" ]; then
|
2016-12-16 11:53:10 +01:00
|
|
|
PLEN="16"
|
2015-04-13 10:47:00 +02:00
|
|
|
fi
|
2016-12-16 11:49:50 +01:00
|
|
|
if [ "$PALG" == "" ]; then
|
2016-12-16 11:53:10 +01:00
|
|
|
PALG="1"
|
2016-12-16 11:49:50 +01:00
|
|
|
fi
|
2015-04-13 10:47:00 +02:00
|
|
|
if [ "$POPT" == "" ]; then
|
|
|
|
POPT="NCL"
|
|
|
|
fi
|
|
|
|
if [ "$PAMT" == "" ]; then
|
|
|
|
PAMT="6"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Output desired passwords
|
2016-12-16 11:49:50 +01:00
|
|
|
$(zenity --info --text "$(apg -a $PALG -m $PLEN -M $POPT -n $PAMT)" --title "Generated Passwords")
|
2015-04-13 10:47:00 +02:00
|
|
|
fi
|