Bob Mottram 10 лет назад
Родитель
Сommit
09e555d312
1 измененных файлов: 16 добавлений и 5 удалений
  1. 16
    5
      src/freedombone-keydrive

+ 16
- 5
src/freedombone-keydrive Просмотреть файл

140
   exit 6843
140
   exit 6843
141
 fi
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
 if [ ! "$?" = "0" ]; then
145
 if [ ! "$?" = "0" ]; then
145
     no_of_usb_shares=0
146
     no_of_usb_shares=0
146
 else
147
 else
160
     freedombone-splitkey -u $MY_USERNAME
161
     freedombone-splitkey -u $MY_USERNAME
161
 fi
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
 if [ ! "$?" = "0" ]; then
166
 if [ ! "$?" = "0" ]; then
165
     no_of_local_shares=0
167
     no_of_local_shares=0
166
 else
168
 else
168
 fi
170
 fi
169
 if (( no_of_local_shares < 3 )); then
171
 if (( no_of_local_shares < 3 )); then
170
     freedombone-splitkey -u $MY_USERNAME
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
     if [ ! "$?" = "0" ]; then
175
     if [ ! "$?" = "0" ]; then
173
         no_of_local_shares=0
176
         no_of_local_shares=0
174
     else
177
     else
187
 SHARE_FILENAME=${share_files[RANDOM % ${#share_files[@]}]}
190
 SHARE_FILENAME=${share_files[RANDOM % ${#share_files[@]}]}
188
 
191
 
189
 cp -f $SHARE_FILENAME $FRAGMENTS_DIR
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
 no_of_usb_shares=$((no_of_usb_shares - 2))
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
     echo "There was a problem copying the key fragment to $USB_DRIVE"
204
     echo "There was a problem copying the key fragment to $USB_DRIVE"
194
     ls $FRAGMENTS_DIR
205
     ls $FRAGMENTS_DIR
195
     umount $USB_MOUNT
206
     umount $USB_MOUNT