Commit 2e5d65f3 authored by Cédric Marie's avatar Cédric Marie

myzip/myunzip: Add an option for SHA256 sum

myzip: Add an option (-s) to create a .sha256sum file.
myunzip: Check the SHA256 sum if a .sha256sum file exists.

Update the email address.
Signed-off-by: Cédric Marie's avatarCédric Marie <cedric@hjuvi.fr.eu.org>
parent 94cfbf38
Painted Shell: A collection of colorful settings and scripts for Bash shell. Painted Shell: A collection of colorful settings and scripts for Bash shell.
Written in 2013-2019 by Cédric Marie <cedric@hjuvi.lautre.net> Written in 2013-2019 by Cédric Marie <cedric@hjuvi.fr.eu.org>
To the extent possible under law, the author(s) have dedicated all copyright To the extent possible under law, the author(s) have dedicated all copyright
and related and neighboring rights to this software to the public domain and related and neighboring rights to this software to the public domain
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# myunzip - Uncompress a .tar.xz[.enc] file # myunzip - Uncompress a .tar.xz[.enc] file
# This file is part of Painted Shell - Shell configuration and scripts. # This file is part of Painted Shell - Shell configuration and scripts.
# #
# Written in 2013-2018 by Cédric Marie # Written in 2013-2019 by Cédric Marie
# #
# To the extent possible under law, the author(s) have dedicated all copyright # To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain # and related and neighboring rights to this software to the public domain
...@@ -35,6 +35,9 @@ shift $(($OPTIND - 1)) ...@@ -35,6 +35,9 @@ shift $(($OPTIND - 1))
option_crypt=0 option_crypt=0
if [ "$1" = "" -o ! -f "$1" ]; then print_usage; exit 1; fi if [ "$1" = "" -o ! -f "$1" ]; then print_usage; exit 1; fi
if [ -f "${1}.sha256sum" ]; then
sha256sum -c ${1}.sha256sum || exit 1;
fi
file=${1%.enc} file=${1%.enc}
if [ "$file" != "$1" ]; then if [ "$file" != "$1" ]; then
option_crypt=1 option_crypt=1
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# myzip - Compress a directory to .tar.xz[.enc] file # myzip - Compress a directory to .tar.xz[.enc] file
# This file is part of Painted Shell - Shell configuration and scripts. # This file is part of Painted Shell - Shell configuration and scripts.
# #
# Written in 2013-2018 by Cédric Marie # Written in 2013-2019 by Cédric Marie
# #
# To the extent possible under law, the author(s) have dedicated all copyright # To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain # and related and neighboring rights to this software to the public domain
...@@ -22,17 +22,20 @@ print_usage() ...@@ -22,17 +22,20 @@ print_usage()
printf " -h display this message\n" printf " -h display this message\n"
printf " -t timestamp output file\n" printf " -t timestamp output file\n"
printf " -e encrypt output file with password\n" printf " -e encrypt output file with password\n"
printf " -s create a .sha256sum file\n"
} }
option_timestamp=0 option_timestamp=0
option_encrypt=0 option_encrypt=0
option_sha256sum=0
# Get options from command line # Get options from command line
while getopts hte OPT while getopts htes OPT
do do
case $OPT in case $OPT in
h) print_usage; exit 0;; h) print_usage; exit 0;;
t) option_timestamp=1;; t) option_timestamp=1;;
e) option_encrypt=1;; e) option_encrypt=1;;
s) option_sha256sum=1;;
*) print_usage; exit 1;; *) print_usage; exit 1;;
esac esac
done done
...@@ -60,3 +63,7 @@ if [ $option_encrypt -eq 1 ]; then ...@@ -60,3 +63,7 @@ if [ $option_encrypt -eq 1 ]; then
fi fi
chmod 444 $output_file chmod 444 $output_file
printf "\033[1mOutput file:\033[0m $output_file\n" printf "\033[1mOutput file:\033[0m $output_file\n"
if [ $option_sha256sum -eq 1 ]; then
sha256sum $output_file > $output_file.sha256sum
printf " + $output_file.sha256sum\n"
fi
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