blob: 6d5b4777360dd179aa0da342cdb3053121b0596b (
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
31
32
33
34
|
#!/usr/bin/env sh
######################################################################
# @author : Garhve (garhve@gmail.com)
# @file : decrypt
# @created : Wednesday Jan 10, 2024 01:09:07 CST
#
# @description : decrypt files that encrypt by gpg
######################################################################
for file in $@
do
# get suffix
suffix=$(echo "$file" | rev | cut -d '.' -f1 | rev)
# get no suffix name
f_no_suffix="${file%.*}"
# check either name is ending with gpg or a*
if [ $suffix = "gpg" ]; then
# if end with gpg, decrypt directly
gpg --output "${f_no_suffix}" --decrypt "$file"
tar zxvf "${f_no_suffix}" && rm $f_no_suffix
else
# else join the parts before decrypt
cat ${f_no_suffix}.* > "$f_no_suffix"
# get name without gpg suffix
f_no_gpg="${f_no_suffix%.*}"
gpg --output "${f_no_gpg}" --decrypt "$f_no_suffix"
tar zxvf "$f_no_gpg" && rm $f_no_gpg $f_no_suffix
fi
done
|