Return values

This commit is contained in:
Bob Mottram 2015-07-03 20:18:59 +01:00
parent 2fec0b17ff
commit 315587ea3a
1 changed files with 6 additions and 9 deletions

View File

@ -249,29 +249,26 @@ function interactive_gpg_from_remote {
if [ ! -f $REMOTE_SERVERS_LIST ]; then
dialog --title "Encryption keys" --msgbox 'Error obtaining server list' 6 70
echo "1"
return
return 1
fi
# check the number of entries in the file
no_of_servers=$(cat $REMOTE_SERVERS_LIST | wc -l)
if [[ ${no_of_servers} < 3 ]]; then
dialog --title "Encryption keys" --msgbox 'There must be at least three servers to recover the key' 6 70
echo "2"
return
return 2
fi
# try to recover the key from the servers
freedombone-recoverkey -u $MY_USERNAME -l $REMOTE_SERVERS_LIST
if [ ! "$?" = "0" ]; then
dialog --title "Encryption keys" --msgbox 'Your key could not be recovered' 6 70
echo "3"
return
return 3
fi
dialog --title "Encryption keys" --msgbox 'Your key has been recovered' 6 70
echo '0'
return 0
}
function interactive_gpg_from_usb {
@ -349,8 +346,8 @@ function interactive_gpg {
3 "Retrieve keys from friends servers" off 2> $data
sel=$?
case $sel in
1) exit 123;;
255) exit 234;;
1) exit 1;;
255) exit 2;;
esac
case $(cat $data) in
1) return;;