In general:
- Each script reruns itself as either root or pihole. Any $SUDO variables are removed.
- Two new scripts are created that need to be run as root.
- The installer creates a file in sudoers.d that allows the pihole user to run the above two scripts as root.
piholeReloadServices.sh: Script to reload dnsmasq (or start it if required).
piholeSetPermissions.sh: Script to set the permissions on /etc/pihole
basic-install.sh:
- Copy two new scripts.
- Set owner and permissions on /etc/pihole
- Install the sudoers file to allow the pihole user to run certain scripts as root without a password.
uninstall.sh:
- Remote two new scripts.
- Remove sudoers file
gravity.sh:
- Rerun as pihole user.
- Use sudo for setting permissions and reloading services.
- Replaced chmod 777 with piholeSetPermissions.sh.
blacklist.sh, whitelist.sh: Rerun as pihole user. Use sudo for reloading services.
chronometer.sh, piholeLogFlush.sh: Rerun as pihole user.
setupLCD.sh: Rerun as root.
Added links to where code was borrowed from
added reboot at the end
also added a few things commented out that might be useful for some
people to learn.
Prep for using sed to insert user selected DNSs into 01-pihole.conf.
Selections will come from dialog during install script containing the
following choices: Google, DynDNS, and eventually 2 custom DNS servers.
Check if /etc/dnsmasq.conf is from pihole. If so, replace with an
original and install new in .d directory. Add and unmolested version of
dnsmasq.conf to the ./advanced directory.
I wanted the whitelist feature to keep the user on the same page
without having to reload it. I'm sure someone better versed in PHP
could eliminate the need for this hack. Nonetheless, it works.
www-data runs the script if executed from the Web interface. www-data
also needs access to write to /etc/pihole/gravity.list to actually
remove the domain. So a few more things need to happen before this
will fully work.
The changes in this script won't change what is displayed if run from
the terminal, but will help when it needs to be run from the Web
interface, so I am just committing this now.
The only other thing I would like to see would be a progress spinner,
but my Web skills still need some work...