Skip to content

Commit

Permalink
Update pihole to enable restoring Teleporter archives from the comman…
Browse files Browse the repository at this point in the history
…d line

Signed-off-by: Iain Henderson <iain.henderson@mac.com>
  • Loading branch information
iain-henderson committed Dec 14, 2022
1 parent a4e20f7 commit be80b23
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions advanced/Scripts/webpage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,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
}
Expand Down Expand Up @@ -603,6 +604,27 @@ Interfaces:
}

Teleporter() {
case "${args[2]}" in
"-h" | "help" ) TeleporterHelpFunc;;
"-r" | "restore" ) Restore;;
* ) Backup;;
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
}

Backup() {
local filename
filename="${args[2]}"
if [[ -z "${filename}" ]]; then
Expand All @@ -617,6 +639,15 @@ Teleporter() {
php "${webroot}/admin/scripts/pi-hole/php/teleporter.php" > "${filename}"
}

Restore() {
local filename
filename="${args[3]}"
if [[ -n "${filename}" ]]; then
# webroot is sourced from basic-install above
php "${webroot}/admin/scripts/pi-hole/php/teleporter.php" "${filename}"
fi
}

checkDomain()
{
local domain validDomain
Expand Down

0 comments on commit be80b23

Please sign in to comment.