diff --git a/src/freedombone-keydrive b/src/freedombone-keydrive index 6baea3d6..4eeb022c 100755 --- a/src/freedombone-keydrive +++ b/src/freedombone-keydrive @@ -140,7 +140,8 @@ if [ ! -d $FRAGMENTS_DIR ]; then exit 6843 fi -no_of_usb_shares=$(ls -afq $FRAGMENTS_DIR/keyshare.asc.* | wc -l) +cd $FRAGMENTS_DIR +no_of_usb_shares=$(ls -afq keyshare.asc.* | wc -l) if [ ! "$?" = "0" ]; then no_of_usb_shares=0 else @@ -160,7 +161,8 @@ if [ ! -d $LOCAL_FRAGMENTS_DIR ]; then freedombone-splitkey -u $MY_USERNAME fi -no_of_local_shares=$(ls -afq $LOCAL_FRAGMENTS_DIR/keyshare.asc.* | wc -l) +cd $LOCAL_FRAGMENTS_DIR +no_of_local_shares=$(ls -afq keyshare.asc.* | wc -l) if [ ! "$?" = "0" ]; then no_of_local_shares=0 else @@ -168,7 +170,8 @@ else 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) + cd $LOCAL_FRAGMENTS_DIR + no_of_local_shares=$(ls -afq keyshare.asc.* | wc -l) if [ ! "$?" = "0" ]; then no_of_local_shares=0 else @@ -187,9 +190,17 @@ share_files=($LOCAL_FRAGMENTS_DIR/keyshare.asc.*) SHARE_FILENAME=${share_files[RANDOM % ${#share_files[@]}]} cp -f $SHARE_FILENAME $FRAGMENTS_DIR -no_of_usb_shares=$(ls -afq $FRAGMENTS_DIR/keyshare.asc.* | wc -l) +cd $FRAGMENTS_DIR +no_of_usb_shares=$(ls -afq keyshare.asc.* | wc -l) no_of_usb_shares=$((no_of_usb_shares - 2)) -if (( no_of_usb_shares != 1 )); then +if (( no_of_usb_shares > 1 )); then + echo "Too many key fragments exist in $FRAGMENTS_DIR" + ls $FRAGMENTS_DIR + umount $USB_MOUNT + rm -rf $USB_MOUNT + exit 54292 +fi +if (( no_of_usb_shares <= 0 )); then echo "There was a problem copying the key fragment to $USB_DRIVE" ls $FRAGMENTS_DIR umount $USB_MOUNT