From 782cd2edd81073453c2d2f76c26e822db18ae5a6 Mon Sep 17 00:00:00 2001 From: Iain Henderson Date: Mon, 3 Jul 2023 12:17:51 -0400 Subject: [PATCH] Update advanced/Scripts/webpage.sh to enable Teleport restore from the command line --- advanced/Scripts/webpage.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index c92d0458..ede95800 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -52,6 +52,7 @@ Options: -i, interface Specify dnsmasq's interface listening behavior -l, privacylevel Set privacy level (0 = lowest, 3 = highest) -t, teleporter Backup configuration as an archive + Add '-h' for more info on Teleporter usage -t, teleporter myname.tar.gz Backup configuration to archive with name myname.tar.gz as specified" exit 0 } @@ -646,6 +647,27 @@ Interfaces: } Teleporter() { + case "${args[2]}" in + "-h" | "help" ) TeleporterHelpFunc;; + "-r" | "restore" ) TeleporterRestore;; + * ) TeleporterBackup;; + esac +} + +TeleporterHelpFunc() { + echo "Usage: pihole -a -t [options] [file] +If no options or file are specified, then backup configuration as an archive +If a file is specified, then backup configuration to archive with name myname.tar.gz as specified + +Example: pihole -a -t myname.tar.gz +Set options for Teleporter + +Options: + -r, restore myname.tar.gz Restore configuration from an archive with name myname.tar.gz as specified" + exit 0 +} + +TeleporterBackup() { local filename filename="${args[2]}" if [[ -z "${filename}" ]]; then @@ -659,6 +681,15 @@ Teleporter() { php "${webroot}/admin/scripts/pi-hole/php/teleporter.php" > "${filename}" } +TeleporterRestore() { + if [[ "${#args[@]}" -gt 3 ]]; then + # webroot is sourced from basic-install above + php "${webroot}/admin/scripts/pi-hole/php/teleporter.php" "${args[@]:3}" + else + TeleporterHelpFunc + fi +} + checkDomain() { local domain validDomain