#!/sbin/openrc-run PIFTL_CMD="/usr/bin/pihole-FTL" PIFTL_CONF="${PIFTL_CONF:-/etc/pihole/pihole-FTL.conf}" PIFTL_PID="/run/pihole/FTL.pid" description="Pi-hole FTL" name="Pi-hole daemon" required_files="${PIFTL_CONF}" depend() { need localmount use net provide dns } start_pre() { command_user="pihole:pihole" # Prepare directories with pihole:pihole permissions: checkpath -o "$command_user" -d /run/pihole /var/log/pihole /var/lib/pihole # Prepare pid-file with root:root and 0644 permissions and clear of all # contents. checkpath --file-truncate -f "$PIFTL_PID" # Prepare config and database files to the user FTL runs as. checkpath -o "$command_user" -f \ /run/pihole/FTL.port \ /var/log/pihole/FTL.log \ /var/log/pihole.log \ /var/lib/pihole/dhcp.leases chown -f "$command_user" /var/lib/pihole/gravity.db /var/lib/pihole/pihole-FTL.db || ewarn "gravity.db or pihole-FTL.db is not properly installed" chown -f "$command_user" \ /var/lib/pihole/macvendor.db || ewarn "macvendor.db file is not properly installed" # Prepare database file permissions so that the pihole group (web # interface) can edit the file. { [ -s /var/lib/pihole/gravity.db ] && [ -s /var/lib/pihole/pihole-FTL.db ] && checkpath -m 0664 -f \ /var/lib/pihole/gravity.db /var/lib/pihole/pihole-FTL.db; } || ewarn "gravity.db or pihole-FTL.db is not properly installed" } stop_post() { rm -rf /run/pihole/* /dev/shm/FTL-* } start() { ebegin "Starting $RC_SVCNAME" start-stop-daemon --start --exec "$PIFTL_CMD" --pidfile "$PIFTL_PID" \ --user pihole --group pihole eend $? } stop() { ebegin "Stopping $RC_SVCNAME" start-stop-daemon --stop --exec "$PIFTL_CMD" --pidfile "$PIFTL_PID" \ --user pihole --group pihole eend $? }