diff options
author | Giusto <giusto@Macbook-M1-Max.local> | 2024-07-25 09:33:12 +0800 |
---|---|---|
committer | Giusto <giusto@Macbook-M1-Max.local> | 2024-07-25 09:33:12 +0800 |
commit | 421f0b1693d668a2d450b909db18eeb67328db7a (patch) | |
tree | f5ee27157b6d8c40eeacd8820b7275e9d5b999bd /data_encrypt.sh |
create a directory to contain only script that fill my own needs
Diffstat (limited to 'data_encrypt.sh')
-rwxr-xr-x | data_encrypt.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/data_encrypt.sh b/data_encrypt.sh new file mode 100755 index 0000000..5a85359 --- /dev/null +++ b/data_encrypt.sh @@ -0,0 +1,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 |