Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable restoring Teleporter archives from the command line #5064

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions advanced/Scripts/webpage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading