Commit 8740e66f authored by Cédric Marie's avatar Cédric Marie

myzip: Change option -c to -e (encrypt)

Signed-off-by: default avatarCédric Marie <cedric@hjuvi.lautre.net>
parent 7cfcf08f
......@@ -20,19 +20,19 @@ print_usage()
printf "Zip a directory.\n\n"
printf "Options:\n"
printf " -h display this message\n"
printf " -c encrypt output file with password\n"
printf " -t timestamp output file\n"
printf " -e encrypt output file with password\n"
}
option_crypt=0
option_timestamp=0
option_encrypt=0
# Get options from command line
while getopts hct OPT
while getopts hte OPT
do
case $OPT in
h) print_usage; exit 0;;
c) option_crypt=1;;
t) option_timestamp=1;;
e) option_encrypt=1;;
*) print_usage; exit 1;;
esac
done
......@@ -46,21 +46,21 @@ else
file=$dir.tar.xz
fi
[ -e "$file" ] && printf "$file already exists\n" && exit 1
if [ $option_crypt -eq 1 ]; then
if [ $option_encrypt -eq 1 ]; then
output_file=${file}.enc
[ -e "$output_file" ] && printf "$output_file already exists\n" && exit 1
else
output_file=$file
fi
tar -Jcvf $file $dir
if [ $option_crypt -eq 1 ]; then
if [ $option_encrypt -eq 1 ]; then
openssl aes-256-cbc -pbkdf2 -e -a -salt -in $file -out $output_file
rm -f $file
[ -f $output_file ] || exit 1
fi
chmod 444 $output_file
printf "\033[1mOutput file:\033[0m $output_file\n"
if [ $option_crypt -eq 1 ]; then
if [ $option_encrypt -eq 1 ]; then
printf "\n$output_file was successfully created:\n"
ls -l $output_file
printf "Do you want to delete $dir directory (y/N)? "
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment