Handle error when searching for files

This commit is contained in:
Bob Mottram 2015-07-04 16:49:22 +01:00
parent 731d5cab86
commit 2f431f77da
1 changed files with 15 additions and 2 deletions

View File

@ -141,7 +141,11 @@ if [ ! -d $FRAGMENTS_DIR ]; then
fi fi
no_of_usb_shares=$(ls -afq $FRAGMENTS_DIR/keyshare.asc.* | wc -l) no_of_usb_shares=$(ls -afq $FRAGMENTS_DIR/keyshare.asc.* | wc -l)
no_of_usb_shares=$((no_of_usb_shares - 2)) if [ ! "$?" = "0" ]; then
no_of_usb_shares=0
else
no_of_usb_shares=$((no_of_usb_shares - 2))
fi
if [[ ${no_of_usb_shares} > 0 ]]; then if [[ ${no_of_usb_shares} > 0 ]]; then
echo "A key fragment already exists on the drive for the user $MY_USERNAME" echo "A key fragment already exists on the drive for the user $MY_USERNAME"
umount $USB_MOUNT umount $USB_MOUNT
@ -158,10 +162,19 @@ if [ ! -d $LOCAL_FRAGMENTS_DIR ]; then
fi fi
no_of_local_shares=$(ls -afq $LOCAL_FRAGMENTS_DIR/keyshare.asc.* | wc -l) no_of_local_shares=$(ls -afq $LOCAL_FRAGMENTS_DIR/keyshare.asc.* | wc -l)
no_of_local_shares=$((no_of_shares - 2)) if [ ! "$?" = "0" ]; then
no_of_local_shares=0
else
no_of_local_shares=$((no_of_local_shares - 2))
fi
if [[ ${no_of_local_shares} < 3 ]]; then if [[ ${no_of_local_shares} < 3 ]]; then
freedombone-splitkey -u $MY_USERNAME freedombone-splitkey -u $MY_USERNAME
no_of_local_shares=$(ls -afq $LOCAL_FRAGMENTS_DIR/keyshare.asc.* | wc -l) no_of_local_shares=$(ls -afq $LOCAL_FRAGMENTS_DIR/keyshare.asc.* | wc -l)
if [ ! "$?" = "0" ]; then
no_of_local_shares=0
else
no_of_local_shares=$((no_of_local_shares - 2))
fi
no_of_local_shares=$((no_of_shares - 2)) no_of_local_shares=$((no_of_shares - 2))
fi fi