56 lines
1007 B
Bash
Raw Permalink Normal View History

#! /bin/bash
set -e
2021-04-15 19:41:12 -04:00
set -o pipefail
2021-03-02 16:44:24 -05:00
positional=()
2021-05-03 07:40:09 -04:00
while [ $# -gt 0 ]; do
2021-03-02 16:44:24 -05:00
argument="$1"
case $argument in
-h|--help)
printf "%s\n" \
"Usage: qr-clone.sh [options]" \
"" \
"Options:" \
2021-04-15 19:41:12 -04:00
" --duplicate duplicate content" \
" --qr-restore-options see \`qr-restore.sh --help\`" \
" --qr-backup-options see \`qr-backup.sh --help\`" \
" -h, --help display help for command"
2021-03-02 16:44:24 -05:00
exit 0
;;
2021-04-15 14:04:08 -04:00
--duplicate)
duplicate=true
shift
;;
2021-04-15 19:41:12 -04:00
--qr-restore-options)
qr_restore_options=$2
shift
shift
;;
--qr-backup-options)
qr_backup_options=$2
shift
shift
;;
2021-03-02 16:44:24 -05:00
*)
positional+=("$1")
shift
;;
esac
done
set -- "${positional[@]}"
2021-04-15 14:04:08 -04:00
bold=$(tput bold)
normal=$(tput sgr0)
2021-02-25 15:00:00 -05:00
tput reset
printf "%s\n" "Restoring…"
2021-04-15 19:41:12 -04:00
eval . qr-restore.sh $qr_restore_options
2021-04-15 14:04:08 -04:00
if [ -n "$secret" ] || [ -n "$encrypted_secret" ]; then
printf "%s\n" "Backing up…"
2021-04-15 19:41:12 -04:00
eval . qr-backup.sh $qr_backup_options
fi