Fixing keydrive creation

This commit is contained in:
Bob Mottram 2015-07-05 10:45:00 +01:00
parent b31a107de6
commit c11f5ce894
1 changed files with 9 additions and 11 deletions

View File

@ -145,14 +145,13 @@ cd $FRAGMENTS_DIR
no_of_usb_shares=$(ls -afq keyshare.asc.* | wc -l) no_of_usb_shares=$(ls -afq keyshare.asc.* | wc -l)
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
no_of_usb_shares=0 no_of_usb_shares=0
else
no_of_usb_shares=$((no_of_usb_shares - 2))
fi 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 -f $USB_MOUNT cd ~/
rm -rf $USB_MOUNT umount -f $USB_MOUNT
exit 58945 rm -rf $USB_MOUNT
exit 58945
fi fi
# copy a random fragment to the drive # copy a random fragment to the drive
@ -166,8 +165,6 @@ cd $LOCAL_FRAGMENTS_DIR
no_of_local_shares=$(ls -afq keyshare.asc.* | wc -l) no_of_local_shares=$(ls -afq keyshare.asc.* | wc -l)
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
no_of_local_shares=0 no_of_local_shares=0
else
no_of_local_shares=$((no_of_local_shares - 2))
fi 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
@ -175,13 +172,12 @@ if (( no_of_local_shares < 3 )); then
no_of_local_shares=$(ls -afq keyshare.asc.* | wc -l) no_of_local_shares=$(ls -afq keyshare.asc.* | wc -l)
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
no_of_local_shares=0 no_of_local_shares=0
else
no_of_local_shares=$((no_of_local_shares - 2))
fi fi
fi fi
if (( no_of_local_shares < 3 )); then if (( no_of_local_shares < 3 )); then
echo "Not enough key fragments available ${no_of_local_shares}" echo "Not enough key fragments available ${no_of_local_shares}"
cd ~/
umount -f $USB_MOUNT umount -f $USB_MOUNT
rm -rf $USB_MOUNT rm -rf $USB_MOUNT
exit 63386 exit 63386
@ -193,7 +189,7 @@ SHARE_FILENAME=${share_files[RANDOM % ${#share_files[@]}]}
cp -f $SHARE_FILENAME $FRAGMENTS_DIR cp -f $SHARE_FILENAME $FRAGMENTS_DIR
cd $FRAGMENTS_DIR cd $FRAGMENTS_DIR
no_of_usb_shares=$(ls -afq keyshare.asc.* | wc -l) no_of_usb_shares=$(ls -afq keyshare.asc.* | wc -l)
no_of_usb_shares=$((no_of_usb_shares - 2)) echo "Number of fragments on the drive: ${no_of_usb_shares}"
if (( no_of_usb_shares > 1 )); then if (( no_of_usb_shares > 1 )); then
echo "Too many key fragments exist in $FRAGMENTS_DIR" echo "Too many key fragments exist in $FRAGMENTS_DIR"
ls $FRAGMENTS_DIR ls $FRAGMENTS_DIR
@ -204,12 +200,14 @@ if (( no_of_usb_shares > 1 )); then
fi fi
if (( no_of_usb_shares <= 0 )); then if (( no_of_usb_shares <= 0 )); then
echo "There was a problem copying the key fragment to $USB_DRIVE" echo "There was a problem copying the key fragment to $USB_DRIVE"
echo "Files found: ${no_of_usb_shares}"
ls $FRAGMENTS_DIR ls $FRAGMENTS_DIR
cd ~/ cd ~/
umount -f $USB_MOUNT umount -f $USB_MOUNT
rm -rf $USB_MOUNT rm -rf $USB_MOUNT
exit 54292 exit 54292
fi fi
cd ~/ cd ~/
umount -f $USB_MOUNT umount -f $USB_MOUNT
rm -rf $USB_MOUNT rm -rf $USB_MOUNT