Ver código fonte

Fixing keydrive creation

Bob Mottram 9 anos atrás
pai
commit
c11f5ce894
1 arquivos alterados com 9 adições e 11 exclusões
  1. 9
    11
      src/freedombone-keydrive

+ 9
- 11
src/freedombone-keydrive Ver arquivo

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