initial server
This commit is contained in:
commit
bd0f7c4c76
32
phtransfer-server.sh
Normal file
32
phtransfer-server.sh
Normal file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
## Script for NH-Opti160 to take a backup of pihole configuration, for nanopineo (or other alternate pihole servers) to pick up over SSH on a scheduled task.
|
||||
## Author: iRaven
|
||||
|
||||
## CONFIGURATION OPTIONS BELOW ##
|
||||
|
||||
# low-privileged user info
|
||||
PHTRANSUSR=phtrans
|
||||
PHTRANSPWD=nope!
|
||||
|
||||
## END configuration options ##
|
||||
|
||||
if [[ $EUID > 0 ]]; then
|
||||
echo "Not running as root, exiting"
|
||||
exit
|
||||
fi
|
||||
|
||||
## Make the user if it doesc't exist.
|
||||
## We're assuming you have a low-privileged user set up for other pihole systems to retrieve the backup file.
|
||||
## This gets configured automatically the first time you run this (below), or you can configure this yourself. Don't give it any permissions.
|
||||
if [ ! -d "/home/${PHTRANSUSR}" ]; then
|
||||
useradd -m -p ${PHTRANSPWD} ${PHTRANSUSR}
|
||||
ssh-keygen -C "piholetransfer" -f /home/${PHTRANSUSR}/.ssh/id_rsa
|
||||
chown -R ${PHTRANSUSR} /home/${PHTRANSUSR}/
|
||||
fi
|
||||
|
||||
## Backup pi-hole FTL DB
|
||||
pihole -a -t /home/${PHTRANSUSR}/phbackup.tar.gz
|
||||
|
||||
## Copy any custom shit in dnsmasq's config directory to the user, too.
|
||||
cp -v /etc/dnsmasq.d/* /home/${PHTRANSUSR}
|
Reference in New Issue
Block a user