diff options
author | Timmy Keller <tjk@tjkeller.xyz> | 2022-07-07 15:55:54 -0500 |
---|---|---|
committer | Timmy Keller <tjk@tjkeller.xyz> | 2022-07-07 15:55:54 -0500 |
commit | 38ebf64b07f99de9464905ee5f8aaee1148b6a4f (patch) | |
tree | 1617ef65c4bd54db8f48cf70122ef7b923c623ab /misc | |
parent | 35a2dd3734f1d31060fe28837cf0e1d947c8d6f4 (diff) | |
download | scripts-38ebf64b07f99de9464905ee5f8aaee1148b6a4f.tar.xz scripts-38ebf64b07f99de9464905ee5f8aaee1148b6a4f.zip |
tons of changes from when website was down
Diffstat (limited to 'misc')
-rwxr-xr-x | misc/passwdgen | 2 | ||||
-rwxr-xr-x | misc/seasonalwallpaper | 10 | ||||
-rwxr-xr-x | misc/verify | 45 |
3 files changed, 39 insertions, 18 deletions
diff --git a/misc/passwdgen b/misc/passwdgen index ce67c92..8e20ba7 100755 --- a/misc/passwdgen +++ b/misc/passwdgen @@ -2,7 +2,7 @@ [ -n "`echo $1$2 | tr -d '[:digit:]'`" ] && echo "Usage: $0 [Itterations] [Length] [Character Set]" && exit [ -z "$1" ] && itt=5 || itt=$1 [ -z "$2" ] && len=20 || len=$2 -[ -z "$3" ] && set='[:graph:]' || set=$3 +[ -z "$3" ] && set="[:alnum:],.<>/?\'!@#$%^&*()[]{};:-_=+" || set=$3 genpasswd() { tr -cd "$3" < /dev/urandom | fold -w$1 | head -n$2; } genpasswd $len $itt $set diff --git a/misc/seasonalwallpaper b/misc/seasonalwallpaper index 525bfb0..f816136 100755 --- a/misc/seasonalwallpaper +++ b/misc/seasonalwallpaper @@ -1,12 +1,12 @@ #!/bin/sh case $1 in - spring|summer|fall|winter) dir=~/.local/share/wallpaper/$1/ ; xwallpaper --zoom "$dir`ls $dir | shuf -n1`" ;; + spring|summer|fall|winter) dir=~/.local/share/wallpaper/$1 ; xwallpaper --zoom "$dir/`ls $dir | shuf -n1`" ;; *) case `date +%b` in - Dec|Jan|Feb) $0 winter ;; - Mar|Apr|May) $0 spring ;; - Jun|Jul|Aug) $0 summer ;; - Sep|Oct|Nov) $0 fall ;; + Dec|Jan|Feb) $0 winter ;; + Mar|Apr|May) $0 spring ;; + Jun|Jul|Aug) $0 summer ;; + Sep|Oct|Nov) $0 fall ;; esac ;; esac diff --git a/misc/verify b/misc/verify index 5f0430c..1f0d4ab 100755 --- a/misc/verify +++ b/misc/verify @@ -4,11 +4,18 @@ CYN="\033[0;36m" GRN="\033[0;32m" RED="\033[0;31m" +me="$(basename "$0")" + +concat="pv -EE -F'%r [%b] [%t] [%e] %p'" + printhelp() { cat << HELPDOC -Usage: $(basename "$0") [options] [file/directory]... +Usage: $me [options] [file/directory]... OPTIONS: + -o, --stdout Output checksum to STDOUT + -S, --supress Supress all warnings and progress notes (default with -o) + -n, --no-progress Don't output progress bar (default with -o & -S) -m, --md5 Create/verify md5 checksum -s[mode], --sha[mode] Create/verify sha[mode] checksum -x[mode], --xxh[mode] Create/verify xxh[mode] checksum (default) @@ -21,6 +28,9 @@ HELPDOC crypt=xxh while true; do case "$1" in + -o|--stdout) stdout=1; nowarn=1; concat="cat" ;; + -S|--supress) nowarn=1; concat="cat" ;; + -n|--no-progressbar) concat="cat" ;; -m|--md5) crypt=md5 ;; -s*|--sha*) crypt=sha$(echo "$1" | tr -cd [:digit:]) ;; -x*|--xxh*) crypt=xxh$(echo "$1" | tr -cd [:digit:]) ;; @@ -35,6 +45,13 @@ done hashalg=${crypt}sum command -v $hashalg >/dev/null || (echo "Hashing algorithm '$hashalg' does not exist!" && exit 2) +# Warn user +if [ ! "$nowarn" ]; then + for file in "$@"; do + [ -d "$file" ] && echo "${RED}NOTE:${NORM} getting a checksum from an entire directory is NOT a standard feature in any other checksum-checking program! They can only be checked with this script!" && break + done +fi + while [ -n "$1" ]; do file="$1" [ ! "`echo "$file" | sed "s/.$crypt$//"`" = "$file" ] && shift && continue # Skip hash files @@ -43,20 +60,24 @@ while [ -n "$1" ]; do hashfile="$file.$crypt" [ -n "$verify" ] && [ ! -e "$hashfile" ] && shift && continue # Skip files without a hash in verify mode - echo "Getting $crypt checksum of $type '$file'..." - hash=`find "$file" -type f -print0 | sort -z | xargs -r0 pv -EE -F'%r [%b] [%t] [%e] %p' | $hashalg | cut -d' ' -f1` + [ ! "$nowarn" ] && echo "Getting $crypt checksum of $type '$file'..." + hash=`find "$file" -type f -print0 | sort -z | xargs -r0 $concat | $hashalg | cut -d' ' -f1` - if [ -e "$hashfile" ]; then - phash=`cat "$hashfile"` - [ $phash = $hash ] \ - && echo "${GRN}Success: $type matches saved checksum!" \ - || (echo "${RED}Error: $type does not match saved checksum!\nExpected checksum: $phash\nActual checksum: $hash" && ec=1) + if [ "$stdout" ]; then + echo "$hash ($crypt) $file" else - echo $hash > "$hashfile" \ - && echo "${CYN}$crypt checksum file saved at '$hashfile'!" \ - || (echo "${RED}'$hashfile' could not be created!\n$crypt checksum of $type '$file' is $hash" && ec=1) + if [ -e "$hashfile" ]; then + phash=`cat "$hashfile"` + [ $phash = $hash ] \ + && echo "${GRN}Success: $type matches saved checksum!" \ + || (echo "${RED}Error: $type does not match saved checksum!\nExpected checksum: $phash\nActual checksum: $hash" && ec=1) + else + echo $hash > "$hashfile" \ + && echo "${CYN}$crypt checksum file saved at '$hashfile'!" \ + || (echo "${RED}'$hashfile' could not be created!\n$crypt checksum of $type '$file' is $hash" && ec=1) + fi + printf "$NORM"; [ -n "$2" ] && echo fi - printf "$NORM"; [ -n "$2" ] && echo shift done exit $ec |