Browse Source

Fixing keydrive creation

Bob Mottram 9 years ago
parent
commit
c11f5ce894
1 changed files with 9 additions and 11 deletions
  1. 9
    11
      src/freedombone-keydrive

+ 9
- 11
src/freedombone-keydrive View File

145
 no_of_usb_shares=$(ls -afq keyshare.asc.* | wc -l)
145
 no_of_usb_shares=$(ls -afq keyshare.asc.* | wc -l)
146
 if [ ! "$?" = "0" ]; then
146
 if [ ! "$?" = "0" ]; then
147
     no_of_usb_shares=0
147
     no_of_usb_shares=0
148
-else
149
-    no_of_usb_shares=$((no_of_usb_shares - 2))
150
 fi
148
 fi
151
 if (( no_of_usb_shares > 0 )); then
149
 if (( no_of_usb_shares > 0 )); then
152
-  echo "A key fragment already exists on the drive for the user $MY_USERNAME"
153
-  umount -f $USB_MOUNT
154
-  rm -rf $USB_MOUNT
155
-  exit 58945
150
+    echo "A key fragment already exists on the drive for the user $MY_USERNAME"
151
+    cd ~/
152
+    umount -f $USB_MOUNT
153
+    rm -rf $USB_MOUNT
154
+    exit 58945
156
 fi
155
 fi
157
 
156
 
158
 # copy a random fragment to the drive
157
 # copy a random fragment to the drive
166
 no_of_local_shares=$(ls -afq keyshare.asc.* | wc -l)
165
 no_of_local_shares=$(ls -afq keyshare.asc.* | wc -l)
167
 if [ ! "$?" = "0" ]; then
166
 if [ ! "$?" = "0" ]; then
168
     no_of_local_shares=0
167
     no_of_local_shares=0
169
-else
170
-    no_of_local_shares=$((no_of_local_shares - 2))
171
 fi
168
 fi
172
 if (( no_of_local_shares < 3 )); then
169
 if (( no_of_local_shares < 3 )); then
173
     freedombone-splitkey -u $MY_USERNAME
170
     freedombone-splitkey -u $MY_USERNAME
175
     no_of_local_shares=$(ls -afq keyshare.asc.* | wc -l)
172
     no_of_local_shares=$(ls -afq keyshare.asc.* | wc -l)
176
     if [ ! "$?" = "0" ]; then
173
     if [ ! "$?" = "0" ]; then
177
         no_of_local_shares=0
174
         no_of_local_shares=0
178
-    else
179
-        no_of_local_shares=$((no_of_local_shares - 2))
180
     fi
175
     fi
181
 fi
176
 fi
182
 
177
 
183
 if (( no_of_local_shares < 3 )); then
178
 if (( no_of_local_shares < 3 )); then
184
     echo "Not enough key fragments available ${no_of_local_shares}"
179
     echo "Not enough key fragments available ${no_of_local_shares}"
180
+    cd ~/
185
     umount -f $USB_MOUNT
181
     umount -f $USB_MOUNT
186
     rm -rf $USB_MOUNT
182
     rm -rf $USB_MOUNT
187
     exit 63386
183
     exit 63386
193
 cp -f $SHARE_FILENAME $FRAGMENTS_DIR
189
 cp -f $SHARE_FILENAME $FRAGMENTS_DIR
194
 cd $FRAGMENTS_DIR
190
 cd $FRAGMENTS_DIR
195
 no_of_usb_shares=$(ls -afq keyshare.asc.* | wc -l)
191
 no_of_usb_shares=$(ls -afq keyshare.asc.* | wc -l)
196
-no_of_usb_shares=$((no_of_usb_shares - 2))
192
+echo "Number of fragments on the drive: ${no_of_usb_shares}"
197
 if (( no_of_usb_shares > 1 )); then
193
 if (( no_of_usb_shares > 1 )); then
198
     echo "Too many key fragments exist in $FRAGMENTS_DIR"
194
     echo "Too many key fragments exist in $FRAGMENTS_DIR"
199
     ls $FRAGMENTS_DIR
195
     ls $FRAGMENTS_DIR
204
 fi
200
 fi
205
 if (( no_of_usb_shares <= 0 )); then
201
 if (( no_of_usb_shares <= 0 )); then
206
     echo "There was a problem copying the key fragment to $USB_DRIVE"
202
     echo "There was a problem copying the key fragment to $USB_DRIVE"
203
+    echo "Files found: ${no_of_usb_shares}"
207
     ls $FRAGMENTS_DIR
204
     ls $FRAGMENTS_DIR
208
     cd ~/
205
     cd ~/
209
     umount -f $USB_MOUNT
206
     umount -f $USB_MOUNT
210
     rm -rf $USB_MOUNT
207
     rm -rf $USB_MOUNT
211
     exit 54292
208
     exit 54292
212
 fi
209
 fi
210
+
213
 cd ~/
211
 cd ~/
214
 umount -f $USB_MOUNT
212
 umount -f $USB_MOUNT
215
 rm -rf $USB_MOUNT
213
 rm -rf $USB_MOUNT