From 03c65dd0e951343c68335eca5959501482fe35e5 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 24 Aug 2019 04:33:32 -0700 Subject: [PATCH] Convert hardcoded /usr/local/bin to variable Update pihole script with full path to 'pihole' Variable for webpage.sh 'pihole' call. Signed-off-by: Dan Schaper --- advanced/Scripts/webpage.sh | 3 ++- automated install/basic-install.sh | 11 ++++++----- pihole | 9 +++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index c8dfb129..65b6587e 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -16,6 +16,7 @@ readonly dhcpconfig="/etc/dnsmasq.d/02-pihole-dhcp.conf" readonly FTLconf="/etc/pihole/pihole-FTL.conf" # 03 -> wildcards readonly dhcpstaticconfig="/etc/dnsmasq.d/04-pihole-static-dhcp.conf" +readonly PI_HOLE_BIN_DIR="/usr/local/bin" coltable="/opt/pihole/COL_TABLE" if [[ -f ${coltable} ]]; then @@ -274,7 +275,7 @@ Reboot() { } RestartDNS() { - /usr/local/bin/pihole restartdns + "${PI_HOLE_BIN_DIR}"/pihole restartdns } SetQueryLogOptions() { diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 6af88a57..afd6ce23 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -65,6 +65,7 @@ PI_HOLE_FILES=(chronometer list piholeDebug piholeLogFlush setupLCD update versi # This directory is where the Pi-hole scripts will be installed PI_HOLE_INSTALL_DIR="/opt/pihole" PI_HOLE_CONFIG_DIR="/etc/pihole" +PI_HOLE_BIN_DIR="/usr/local/bin" PI_HOLE_BLOCKPAGE_DIR="${webroot}/pihole" useUpdateVars=false @@ -1339,7 +1340,7 @@ installScripts() { install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./advanced/Scripts/*.sh install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./automated\ install/uninstall.sh install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./advanced/Scripts/COL_TABLE - install -o "${USER}" -Dm755 -t /usr/local/bin/ pihole + install -o "${USER}" -Dm755 -t "${PI_HOLE_BIN_DIR}" pihole install -Dm644 ./advanced/bash-completion/pihole /etc/bash_completion.d/pihole printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}" @@ -1692,13 +1693,13 @@ installPiholeWeb() { # and copy in the pihole sudoers file install -m 0640 ${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole.sudo /etc/sudoers.d/pihole # Add lighttpd user (OS dependent) to sudoers file - echo "${LIGHTTPD_USER} ALL=NOPASSWD: /usr/local/bin/pihole" >> /etc/sudoers.d/pihole + echo "${LIGHTTPD_USER} ALL=NOPASSWD: ${PI_HOLE_BIN_DIR}/pihole" >> /etc/sudoers.d/pihole # If the Web server user is lighttpd, if [[ "$LIGHTTPD_USER" == "lighttpd" ]]; then # Allow executing pihole via sudo with Fedora - # Usually /usr/local/bin is not permitted as directory for sudoable programs - echo "Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin" >> /etc/sudoers.d/pihole + # Usually /usr/local/bin ${PI_HOLE_BIN_DIR} is not permitted as directory for sudoable programs + echo "Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:${PI_HOLE_BIN_DIR}" >> /etc/sudoers.d/pihole fi # Set the strict permissions on the file chmod 0440 /etc/sudoers.d/pihole @@ -2674,7 +2675,7 @@ main() { if [[ "${INSTALL_TYPE}" == "Update" ]]; then printf "\\n" - /usr/local/bin/pihole version --current + "${PI_HOLE_BIN_DIR}" version --current fi } diff --git a/pihole b/pihole index 90309eee..5befe926 100755 --- a/pihole +++ b/pihole @@ -10,6 +10,7 @@ # Please see LICENSE file for your rights under this license. readonly PI_HOLE_SCRIPT_DIR="/opt/pihole" +readonly PI_HOLE_BIN_DIR="/usr/local/bin" readonly gravitylist="/etc/pihole/gravity.list" readonly blacklist="/etc/pihole/black.list" @@ -160,7 +161,7 @@ Time: local str="Disabling blocking for ${tt} seconds" echo -e " ${INFO} ${str}..." local str="Blocking will be re-enabled in ${tt} seconds" - nohup bash -c "sleep ${tt}; pihole enable" /dev/null & + nohup bash -c "sleep ${tt}; ${PI_HOLE_BIN_DIR}/pihole enable" /dev/null & else local error=true fi @@ -171,7 +172,7 @@ Time: echo -e " ${INFO} ${str}..." local str="Blocking will be re-enabled in ${tt} minutes" tt=$((${tt}*60)) - nohup bash -c "sleep ${tt}; pihole enable" /dev/null & + nohup bash -c "sleep ${tt}; ${PI_HOLE_BIN_DIR}/pihole enable" /dev/null & else local error=true fi @@ -233,7 +234,7 @@ Options: sed -i 's/^QUERY_LOGGING=true/QUERY_LOGGING=false/' /etc/pihole/setupVars.conf if [[ "${2}" != "noflush" ]]; then # Flush logs - pihole -f + "${PI_HOLE_BIN_DIR}"/pihole -f fi echo -e " ${INFO} Disabling logging..." local str="Logging has been disabled!" @@ -286,7 +287,7 @@ statusFunc() { *) echo -e " ${INFO} Pi-hole blocking will be enabled";; esac # Enable blocking - pihole enable + "${PI_HOLE_BIN_DIR}"/pihole enable fi }