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.
This commit is contained in:
IncredInComp 2019-10-02 23:12:57 -07:00 committed by GitHub
parent bbcfae19a7
commit f108ed95a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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"
echo "[+] Finished"