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