dialog can now be black/white, lockfile, cheap password protection
This commit is contained in:
73
start
73
start
@ -1,10 +1,26 @@
|
||||
#!/bin/bash
|
||||
export EVENT=DiVOC
|
||||
|
||||
export DIALOGRC=dialogrc
|
||||
|
||||
LOCKFILE=/tmp/irolock
|
||||
TMP=/tmp/$RANDOM
|
||||
BT="Intergalactic Registration Office - v0.3"
|
||||
|
||||
|
||||
function infoBox() {
|
||||
h=8
|
||||
w=60
|
||||
if [ -n "$3" ]; then
|
||||
h=$3
|
||||
fi
|
||||
if [ -n "$4" ]; then
|
||||
w=$4
|
||||
fi
|
||||
dialog --title "$1" \
|
||||
--backtitle "$BT" \
|
||||
--infobox "$2" $h $w
|
||||
}
|
||||
|
||||
function diaBox() {
|
||||
h=8
|
||||
@ -54,6 +70,24 @@ function askStr() {
|
||||
return $?
|
||||
}
|
||||
|
||||
function askPw() {
|
||||
h=12
|
||||
w=60
|
||||
if [ -n "$5" ]; then
|
||||
h=$5
|
||||
fi
|
||||
if [ -n "$6" ]; then
|
||||
w=$6
|
||||
fi
|
||||
|
||||
dialog --title "$2" \
|
||||
--backtitle "$BT" \
|
||||
--max-input $1 \
|
||||
--insecure \
|
||||
--passwordbox "$3" $h $w "$4" 2> $TMP
|
||||
return $?
|
||||
}
|
||||
|
||||
function confirm() {
|
||||
h=12
|
||||
w=60
|
||||
@ -143,13 +177,23 @@ function enterGPG() {
|
||||
fi
|
||||
}
|
||||
|
||||
function checkLockFile() {
|
||||
while [ -f $LOCKFILE ]; do
|
||||
infoBox "Printer is in use..." "Printer is in use. Please wait."
|
||||
sleep 1
|
||||
done
|
||||
touch $LOCKFILE
|
||||
}
|
||||
|
||||
function printGPG() {
|
||||
askForField "GPG fingerprint" "$1"
|
||||
if [ $? -eq 0 ]; then
|
||||
checkLockFile
|
||||
diaBox "Insert Passport" "Please insert passport (Visas) into the printer."
|
||||
cd "$1"
|
||||
./gpgkey $FIELD $FP
|
||||
cd ..
|
||||
rm $LOCKFILE
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
@ -157,20 +201,24 @@ function printGPG() {
|
||||
}
|
||||
|
||||
function printReg() {
|
||||
checkLockFile
|
||||
diaBox "Insert Passport" "Please insert passport (First page, name, place) into the printer."
|
||||
cd "$1"
|
||||
./reg "$FNAME" "$SNAME" "$PLANET"
|
||||
cd ..
|
||||
rm $LOCKFILE
|
||||
return 0
|
||||
}
|
||||
|
||||
function printIROStamp() {
|
||||
askForField "IRO stamp" "$1"
|
||||
if [ $? -eq 0 ]; then
|
||||
checkLockFile
|
||||
diaBox "Insert Passport" "Please insert passport (Visas) into the printer."
|
||||
cd "$1"
|
||||
./iro $FIELD
|
||||
cd ..
|
||||
rm $LOCKFILE
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
@ -305,13 +353,34 @@ function menuFor() {
|
||||
unset FFP
|
||||
}
|
||||
|
||||
function askForFunnyUserCreds() {
|
||||
askStr 12 "Login" "Username:" ""
|
||||
username=$(cat $TMP)
|
||||
askPw 12 "Login" "Password:" ""
|
||||
password=$(cat $TMP)
|
||||
|
||||
if [ -f .pw/$username ]; then
|
||||
if [ "$password" != $(cat .pw/$username) ]; then
|
||||
clear
|
||||
echo "Wrong credentials."
|
||||
sleep 3
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Wrong credentials."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
askForFunnyUserCreds
|
||||
|
||||
while [ true ]; do
|
||||
|
||||
dialog --backtitle "$BT" \
|
||||
--menu "Select ID type:" 10 40 3 \
|
||||
1 "Junghackerpass" \
|
||||
2 "New Adafruit passport" \
|
||||
9 "Exit" 2> $TMP
|
||||
9 "Logout" 2> $TMP
|
||||
|
||||
if [ $? -eq 9 ]; then
|
||||
break
|
||||
@ -325,7 +394,7 @@ while [ true ]; do
|
||||
;;
|
||||
2) menuFor adafruit
|
||||
;;
|
||||
9) exit 0
|
||||
9) break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
Reference in New Issue
Block a user