@@ -26,10 +26,16 @@ JOURNALDIR="${JOURNALDIR:-$DIRFORDIARY}"
26
26
GPGKEY=' '
27
27
GPG_OPTS=" --quiet --yes --compress-algo=none --no-encrypt-to"
28
28
GPG=" gpg"
29
- SHREDCMD=" rm"
30
29
EDITOR=" ${EDITOR:- nano} "
31
30
PAGER=" ${PAGER:- more} "
32
- # SHREDCMD="shred"
31
+
32
+ # Use shred if available
33
+ SHRED=" ` which shred` "
34
+ if [ $? = 0 ]; then
35
+ SHREDCMD=" ${SHRED} --remove=wipe"
36
+ else
37
+ SHREDCMD=" rm"
38
+ fi
33
39
34
40
#
35
41
# initialise notes system
@@ -122,7 +128,7 @@ validate_gpg_keyid () {
122
128
echo Invalid GPG keyid
123
129
cat $keyids
124
130
echo \n\n Type ' gpg -k <keyid> to find out more about key'
125
- rm $keyids
131
+ ${SHREDCMD} $keyids
126
132
exit 1
127
133
else
128
134
echo Valid key $testkey
@@ -133,7 +139,7 @@ validate_gpg_keyid () {
133
139
echo Valid keys are ...
134
140
cat $keyids
135
141
echo \n\n Type ' gpg -k <keyid> to find out more about key'
136
- rm $keyids
142
+ ${SHREDCMD} $keyids
137
143
exit 1;;
138
144
esac
139
145
}
@@ -147,7 +153,7 @@ note_add () {
147
153
filen=" $@ "
148
154
notefile=" ${USE_POINTER} /` echo ${filen} | tr ' ' ' _' ` "
149
155
150
- if [ -f " $notefile .gpg " ] ; then
156
+ if [ -f " $notefile .asc " ] ; then
151
157
echo File exists ... cannot create. Try ' notes edit' instead.
152
158
exit 1
153
159
else
@@ -163,7 +169,7 @@ note_add () {
163
169
# encrypt note file
164
170
$GPG -ear $KEY $GPG_OPTS " $notefile "
165
171
166
- rm " $notefile "
172
+ ${SHREDCMD} " $notefile "
167
173
fi
168
174
}
169
175
@@ -176,7 +182,7 @@ note_import () {
176
182
get_recipient
177
183
178
184
if [ -f " ${toimport} " ] ; then
179
- $GPG -ear $KEY $GPG_OPTS -o " ${USE_POINTER} /${target} .gpg " " ${toimport} "
185
+ $GPG -ear $KEY $GPG_OPTS -o " ${USE_POINTER} /${target} .asc " " ${toimport} "
180
186
fi
181
187
}
182
188
@@ -188,8 +194,8 @@ note_view () {
188
194
189
195
if [ -f " ${notefile} " ]; then
190
196
gpg -d " ${notefile} "
191
- elif [ -f " ${notefile} .gpg " ]; then
192
- gpg -d " ${notefile} .gpg "
197
+ elif [ -f " ${notefile} .asc " ]; then
198
+ gpg -d " ${notefile} .asc "
193
199
else
194
200
echo Note file does not exist
195
201
exit 1
@@ -199,20 +205,20 @@ note_view () {
199
205
note_edit () {
200
206
notefile=" ` echo $@ | tr ' ' ' _' ` "
201
207
notefile=" ${USE_POINTER} /${notefile} "
202
- decrypted=" ` echo ${notefile} | sed s/.gpg //` "
208
+ decrypted=" ` echo ${notefile} | sed s/.asc //` "
203
209
204
210
get_recipient
205
211
206
212
if [ -f " $notefile " ]; then
207
213
gpg -d -o " ${decrypted} " " ${notefile} "
208
214
${EDITOR} " ${decrypted} "
209
215
$GPG -ear $KEY $GPG_OPTS " ${decrypted} "
210
- rm ${decrypted}
211
- elif [ -f " ${notefile} .gpg " ]; then
212
- gpg -d -o " ${decrypted} " " ${notefile} .gpg "
216
+ ${SHREDCMD} ${decrypted}
217
+ elif [ -f " ${notefile} .asc " ]; then
218
+ gpg -d -o " ${decrypted} " " ${notefile} .asc "
213
219
${EDITOR} " ${decrypted} "
214
220
$GPG -ear $KEY $GPG_OPTS " ${decrypted} "
215
- rm ${decrypted}
221
+ ${SHREDCMD} ${decrypted}
216
222
else
217
223
echo Note file does not exist
218
224
exit 1
@@ -228,9 +234,9 @@ note_delete () {
228
234
notefile=" ${USE_POINTER} /${notefile} "
229
235
230
236
if [ -f " $notefile " ]; then
231
- rm -i " $notefile "
232
- elif [ -f " ${notefile} .gpg " ]; then
233
- rm -i " ${notefile} .gpg "
237
+ ${SHREDCMD} " $notefile "
238
+ elif [ -f " ${notefile} .asc " ]; then
239
+ ${SHREDCMD} " ${notefile} .asc "
234
240
else
235
241
echo Note file does not exist
236
242
fi
@@ -247,13 +253,13 @@ note_rename () {
247
253
248
254
case $notefile in
249
255
* gpg) skip;;
250
- * ) notefile=" ${notefile} .gpg "
256
+ * ) notefile=" ${notefile} .asc "
251
257
esac
252
258
253
259
newnotefile=" ${USE_POINTER} /${newname} "
254
260
case $newnotefile in
255
261
* gpg) skip;;
256
- * ) newnotefile=" ${newnotefile} .gpg "
262
+ * ) newnotefile=" ${newnotefile} .asc "
257
263
esac
258
264
259
265
case $MVCP in
@@ -264,7 +270,7 @@ note_rename () {
264
270
if [ -f " $notefile " ] ; then
265
271
echo $notefile exists .... $processing
266
272
$MVCP " $notefile " " $newnotefile "
267
- elif [ -f " ${notefile} .gpg " ] ; then
273
+ elif [ -f " ${notefile} .asc " ] ; then
268
274
echo $notefile exists .... $processing
269
275
$MVCP " $notefile " " $newnotefile "
270
276
else
@@ -297,7 +303,7 @@ notebook_delete () {
297
303
exit 1
298
304
else
299
305
echo Deleting files from $notebook
300
- rm -if ${notebook} /* .gpg
306
+ ${SHREDCMD} ${notebook} /* .asc
301
307
302
308
if [ $? = 0 ] ; then
303
309
rmdir " $notebook "
@@ -456,7 +462,7 @@ cmd_show () {
456
462
cmd_find () {
457
463
searchterm=" $@ "
458
464
459
- for file in ${USE_POINTER} /* .gpg
465
+ for file in ${USE_POINTER} /* .asc
460
466
do
461
467
gpg -d $file 2> /dev/null | grep -H --label ${file} " $searchterm "
462
468
done
@@ -562,12 +568,12 @@ cmd_newkey () {
562
568
get_gpg_keyid $mynewkey
563
569
564
570
# now recrypt files
565
- find ~ /.notes -name \* .gpg | sed s/.gpg // | \
571
+ find ~ /.notes -name \* .asc | sed s/.asc // | \
566
572
567
573
while read filen ;
568
574
do
569
575
echo $filen ;
570
- gpg -o " ${filen} " --yes -d " ${filen} .gpg "
576
+ gpg -o " ${filen} " --yes -d " ${filen} .asc "
571
577
gpg -r ${mynewkey} --yes -ea " ${filen} " && ${SHREDCMD} " ${filen} "
572
578
573
579
done
0 commit comments