mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
Delete scripts/restore.sh
Signed-off-by: wpa-2 <9049886+wpa-2@users.noreply.github.com>
This commit is contained in:
@ -1,60 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
echo "Usage: restore.sh [-bhnu] [-h] [-b backup name] [-n host name] [-u user name]"
|
|
||||||
}
|
|
||||||
|
|
||||||
while getopts "hb:n:u:" arg; do
|
|
||||||
case $arg in
|
|
||||||
b)
|
|
||||||
BACKUP=$OPTARG
|
|
||||||
;;
|
|
||||||
h)
|
|
||||||
usage
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
n)
|
|
||||||
UNIT_HOSTNAME=$OPTARG
|
|
||||||
;;
|
|
||||||
u)
|
|
||||||
UNIT_USERNAME=$OPTARG
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
usage
|
|
||||||
exit 1
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
# name of the ethernet gadget interface on the host
|
|
||||||
UNIT_HOSTNAME=${UNIT_HOSTNAME:-10.0.0.2}
|
|
||||||
# output backup tgz file
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
if [ -z $BACKUP ]; then
|
|
||||||
# shellcheck disable=SC2012
|
|
||||||
BACKUP=$(ls -rt "${UNIT_HOSTNAME}"-backup-*.tgz 2>/dev/null | tail -n1)
|
|
||||||
if [ -z "$BACKUP" ]; then
|
|
||||||
echo "@ Can't find backup file. Please specify one with '-b'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "@ Found backup file:"
|
|
||||||
# shellcheck disable=SC2028
|
|
||||||
echo "\t${BACKUP}"
|
|
||||||
# shellcheck disable=SC2039
|
|
||||||
echo -n "@ continue restroring this file? (y/n) "
|
|
||||||
# shellcheck disable=SC2162
|
|
||||||
read CONTINUE
|
|
||||||
CONTINUE=$(echo "${CONTINUE}" | tr "[:upper:]" "[:lower:]")
|
|
||||||
if [ "${CONTINUE}" != "y" ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
# username to use for ssh
|
|
||||||
UNIT_USERNAME=${UNIT_USERNAME:-pi}
|
|
||||||
|
|
||||||
ping -c 1 "${UNIT_HOSTNAME}" > /dev/null 2>&1 || {
|
|
||||||
echo "@ unit ${UNIT_HOSTNAME} can't be reached, make sure it's connected and a static IP assigned to the USB interface."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "@ restoring $BACKUP to $UNIT_HOSTNAME ..."
|
|
||||||
# shellcheck disable=SC2002
|
|
||||||
cat "${BACKUP}" | ssh "${UNIT_USERNAME}@${UNIT_HOSTNAME}" "sudo tar xzv -C /"
|
|
Reference in New Issue
Block a user