Browse Source

cd to directory before search

Bob Mottram 9 years ago
parent
commit
09e555d312
1 changed files with 16 additions and 5 deletions
  1. 16
    5
      src/freedombone-keydrive

+ 16
- 5
src/freedombone-keydrive View File

@@ -140,7 +140,8 @@ if [ ! -d $FRAGMENTS_DIR ]; then
140 140
   exit 6843
141 141
 fi
142 142
 
143
-no_of_usb_shares=$(ls -afq $FRAGMENTS_DIR/keyshare.asc.* | wc -l)
143
+cd $FRAGMENTS_DIR
144
+no_of_usb_shares=$(ls -afq keyshare.asc.* | wc -l)
144 145
 if [ ! "$?" = "0" ]; then
145 146
     no_of_usb_shares=0
146 147
 else
@@ -160,7 +161,8 @@ if [ ! -d $LOCAL_FRAGMENTS_DIR ]; then
160 161
     freedombone-splitkey -u $MY_USERNAME
161 162
 fi
162 163
 
163
-no_of_local_shares=$(ls -afq $LOCAL_FRAGMENTS_DIR/keyshare.asc.* | wc -l)
164
+cd $LOCAL_FRAGMENTS_DIR
165
+no_of_local_shares=$(ls -afq keyshare.asc.* | wc -l)
164 166
 if [ ! "$?" = "0" ]; then
165 167
     no_of_local_shares=0
166 168
 else
@@ -168,7 +170,8 @@ else
168 170
 fi
169 171
 if (( no_of_local_shares < 3 )); then
170 172
     freedombone-splitkey -u $MY_USERNAME
171
-    no_of_local_shares=$(ls -afq $LOCAL_FRAGMENTS_DIR/keyshare.asc.* | wc -l)
173
+	cd $LOCAL_FRAGMENTS_DIR
174
+    no_of_local_shares=$(ls -afq keyshare.asc.* | wc -l)
172 175
     if [ ! "$?" = "0" ]; then
173 176
         no_of_local_shares=0
174 177
     else
@@ -187,9 +190,17 @@ share_files=($LOCAL_FRAGMENTS_DIR/keyshare.asc.*)
187 190
 SHARE_FILENAME=${share_files[RANDOM % ${#share_files[@]}]}
188 191
 
189 192
 cp -f $SHARE_FILENAME $FRAGMENTS_DIR
190
-no_of_usb_shares=$(ls -afq $FRAGMENTS_DIR/keyshare.asc.* | wc -l)
193
+cd $FRAGMENTS_DIR
194
+no_of_usb_shares=$(ls -afq keyshare.asc.* | wc -l)
191 195
 no_of_usb_shares=$((no_of_usb_shares - 2))
192
-if (( no_of_usb_shares != 1 )); then
196
+if (( no_of_usb_shares > 1 )); then
197
+    echo "Too many key fragments exist in $FRAGMENTS_DIR"
198
+    ls $FRAGMENTS_DIR
199
+    umount $USB_MOUNT
200
+    rm -rf $USB_MOUNT
201
+    exit 54292
202
+fi
203
+if (( no_of_usb_shares <= 0 )); then
193 204
     echo "There was a problem copying the key fragment to $USB_DRIVE"
194 205
     ls $FRAGMENTS_DIR
195 206
     umount $USB_MOUNT