Polished scripts

This commit is contained in:
Sun Knudsen 2021-03-06 14:39:16 -05:00
parent 09667692cd
commit 4ff43c6f2b
No known key found for this signature in database
GPG Key ID: 1FA767862BBD1305
6 changed files with 19 additions and 16 deletions

View File

@ -11,7 +11,7 @@ while [[ $# -gt 0 ]]; do
"Usage: qr-clone.sh [options]" \
"" \
"Options:" \
" -h, --help display help for command"
" -h, --help display help for command"
exit 0
;;
*)

View File

@ -11,8 +11,8 @@ while [[ $# -gt 0 ]]; do
"Usage: qr-restore.sh [options]" \
"" \
"Options:" \
" --word-list split secret into word list" \
" -h, --help display help for command"
" --word-list split secret into word list" \
" -h, --help display help for command"
exit 0
;;
--word-list)
@ -68,9 +68,13 @@ if [ "$answer" = "y" ]; then
if [ "$word_list" = true ]; then
printf "%s" "Secret: "
array=($secret)
for i in ${!array[@]}; do
position=$(($i + 1))
printf "%d. $bold%s$normal " "$position" "${array[$i]}"
last_index=$(echo "${#array[@]} - 1" | bc)
for index in ${!array[@]}; do
position=$(($index + 1))
printf "%d. $bold%s$normal" "$position" "${array[$index]}"
if [ $index -lt $last_index ]; then
printf " "
fi
done
printf "\n"
else

View File

@ -1,6 +1,6 @@
#! /bin/bash
iterations=3
rounds=3
positional=()
while [[ $# -gt 0 ]]; do
@ -11,13 +11,13 @@ while [[ $# -gt 0 ]]; do
"Usage: secure-erase.sh [options]" \
"" \
"Options:" \
" --iterations overwrite n times (defauls to 3)" \
" --zero overwrite with zeros to hide secure erase" \
" -h, --help display help for command"
" --rounds <rounds> overwrite n times (defauls to 3)" \
" --zero overwrite with zeros obfuscating secure erase" \
" -h, --help display help for command"
exit 0
;;
--iterations)
iterations=$2
--rounds)
rounds=$2
shift
shift
;;
@ -55,13 +55,12 @@ printf "$red%s$normal\n" "Secure erase USB flash drive? (y or n)? "
read -r answer
if [ "$answer" = "y" ]; then
array=($(seq 1 1 $iterations))
for iteration in ${array[@]}; do
printf "%s\n" "Erasing… (iteration $iteration of $iterations)"
for round in $(seq 1 1 $rounds); do
printf "%s\n" "Overwriting with random data… (round $round of $rounds)"
sudo dd bs=1M if=/dev/urandom of=$dev
done
if [ "$zero" = true ]; then
printf "%s\n" "Writing zeros…"
printf "%s\n" "Overwriting with zeros…"
sudo dd bs=1M if=/dev/zero of=$dev
fi
else