From f108ed95a7d0c559b028a263edcdebfa2f66c308 Mon Sep 17 00:00:00 2001 From: IncredInComp <incredincomp@gmail.com> Date: Wed, 2 Oct 2019 23:12:57 -0700 Subject: [PATCH] added hostname backup and restore https://github.com/evilsocket/pwnagotchi/issues/69#issue-501710314 Couldn't decide if it should be a separate option by itself, but I personally think they do go hand in hand. --- scripts/update_pwnagotchi.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/update_pwnagotchi.sh b/scripts/update_pwnagotchi.sh index 0039e7b..eae69d5 100644 --- a/scripts/update_pwnagotchi.sh +++ b/scripts/update_pwnagotchi.sh @@ -18,8 +18,8 @@ function usage() { -v # Version to update to, can be a branch or commit. (default: master) -u # Url to clone from. (default: https://github.com/evilsocket/pwnagotchi) -m # Mode to restart to. (Supported: ${SUPPORTED_RESTART_MODES[*]}; default: auto) - -b # Backup the current pwnagotchi config. - -r # Restore the current pwnagotchi config. (-b will be enabled.) + -b # Backup the current pwnagotchi config and hostname references. + -r # Restore the current pwnagotchi config and hostname references. (-b will be enabled.) -h # Shows this help. EOF @@ -89,8 +89,11 @@ echo "[+] Installing $(git log -1 --format="%h")" echo "[+] Updating..." if [ $BACKUPCONFIG -eq 1 ]; then - echo "[+] Creating backup of config.yml" - mv /root/pwnagotchi/config.yml /root/config.yml.bak -f + echo "[+] Creating backup of config.yml and hostname references" + mv /root/pwnagotchi/config.yml /root/config.bak -f + mv /etc/hosts /root/hosts.bak -f + mv /etc/hostname /root/hostname.bak -f + mv /etc/network/interfaces /root/interfaces.bak -f fi rm /root/pwnagotchi -rf # ensures old files are removed rsync -aPq $GIT_FOLDER/sdcard/boot/* /boot/ @@ -98,8 +101,11 @@ rsync -aPq $GIT_FOLDER/sdcard/rootfs/* / cd /tmp rm $GIT_FOLDER -rf if [ $RESTORECONFIG -eq 1 ]; then - echo "[+] Restoring backup of config.yml" + echo "[+] Restoring backup of config.yml and hostname references" mv /root/config.yml.bak /root/pwnagotchi/config.yml -f + mv /etc/hosts.bak /etc/hosts -f + mv /etc/hostname.bak /etc/hostname -f + mv /etc/network/interfaces.bak /etc/network/interfaces -f fi echo "[+] Restarting pwnagotchi in $MODE mode. $( screen -X -S pwnagotchi quit)" @@ -108,4 +114,4 @@ if [ $MODE == "auto" ]; then elif [ $MODE == "manual" ]; then sudo -H -u root /usr/bin/screen -dmS pwnagotchi -c /root/pwnagotchi/data/screenrc.manual fi -echo "[+] Finished" \ No newline at end of file +echo "[+] Finished"