blob: 5a8535990bbc3930aa492c1cebeff3bc7166c159 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/usr/bin/env sh
######################################################################
# @author : Garhve (garhve@gmail.com)
# @file : encrypt
# @created : Tuesday Jan 09, 2024 22:06:31 CST
#
# @description : encrypt file/directory with gpg
######################################################################
recipient=garhve
for file in $@
do
cfile="${file}.tar.gz" #file.tar.gz
gfile="${cfile}.gpg" #file.tar.gz.gpg
tar zcvf "$cfile" "$file" && gunzip -t "$cfile"
gpg --output "${gfile}" --recipient $recipient --encrypt "${cfile}"
rm "$cfile"
# split file if the size is larger than 1G
size=$(du -sh "${gfile}" | awk -F '\t' '{print $1}')
s_suffix="${size:0-1}"
if [ $s_suffix = 'G' ]; then
split -b 1G "$gfile" "${gfile}."
rm "$gfile"
fi
done
|