diff --git a/src/freedombone-keydrive b/src/freedombone-keydrive index 3a86b375..7777edf3 100755 --- a/src/freedombone-keydrive +++ b/src/freedombone-keydrive @@ -141,7 +141,11 @@ if [ ! -d $FRAGMENTS_DIR ]; then fi 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 echo "A key fragment already exists on the drive for the user $MY_USERNAME" umount $USB_MOUNT @@ -158,10 +162,19 @@ if [ ! -d $LOCAL_FRAGMENTS_DIR ]; then fi 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 freedombone-splitkey -u $MY_USERNAME 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)) fi