From af2ec619655015a25b497b877782dba388ea03b5 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sun, 29 Jul 2018 08:17:57 -0700 Subject: [PATCH 1/6] Convert [] to () Signed-off-by: Dan Schaper --- advanced/Templates/pihole-FTL.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/advanced/Templates/pihole-FTL.conf b/advanced/Templates/pihole-FTL.conf index e4b9fae9..03f42932 100644 --- a/advanced/Templates/pihole-FTL.conf +++ b/advanced/Templates/pihole-FTL.conf @@ -30,14 +30,14 @@ #RESOLVE_IPV4=yes ## Max Database Days -## How long should queries be stored in the database [days]? +## How long should queries be stored in the database (days)? ## Setting this to 0 disables the database ## See: https://docs.pi-hole.net/ftldns/database/ ## Options: number of days #MAXDBDAYS=365 ## Database Interval -## How often do we store queries in FTL's database [minutes]? +## How often do we store queries in FTL's database (minutes)? ## See: https://docs.pi-hole.net/ftldns/database/ ## Options: number of minutes #DBINTERVAL=1.0 @@ -50,7 +50,7 @@ #DBFILE=/etc/pihole/pihole-FTL.db ## Max Log Age -## Up to how many hours of queries should be imported from the database and logs [hours]? +## Up to how many hours of queries should be imported from the database and logs (hours)? ## Maximum is 744 (31 days) ## Options: number of days #MAXLOGAGE=24.0 From af13ceac24807aa24601a758a416c509802dd0dc Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sun, 29 Jul 2018 08:42:59 -0700 Subject: [PATCH 2/6] Touch file as ${USER} instead of copying template. Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 2f1248e9..6ccbbb5c 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2027,7 +2027,10 @@ FTLinstall() { # Install template if it does not exist if [[ ! -f "/etc/pihole/pihole-FTL.conf" ]]; then - install -o "${USER}" -Dm644 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL.conf" "/etc/pihole/pihole-FTL.conf" + if ! sudo -u ${USER} touch "/etc/pihole/pihole-FTL.conf" 2&>1 /dev/null; then + echo -e " ${COL_LIGHT_RED}Error: Unable to initialize configuration file /etc/pihole/pihole-FTL.conf" + return 1 + fi fi local ftlBranch From 17c1e64f7e3417b592d677e9ffdacf05ab833c28 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sun, 29 Jul 2018 09:06:51 -0700 Subject: [PATCH 3/6] Moved FTL configuration copy in to scripts copy function. Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 6ccbbb5c..86e66ca0 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1219,12 +1219,19 @@ installScripts() { install -o "${USER}" -Dm755 -t /usr/local/bin/ pihole install -Dm644 ./advanced/bash-completion/pihole /etc/bash_completion.d/pihole echo -e "${OVER} ${TICK} ${str}" + # Install template if it does not exist + if [[ ! -f "/etc/pihole/pihole-FTL.conf" ]]; then + if ! sudo -u ${USER} touch "${PI_HOLE_INSTALL_DIR}/pihole-FTL.conf" 2&>1 /dev/null; then + echo -e " ${COL_LIGHT_RED}Error: Unable to initialize configuration file /etc/pihole/pihole-FTL.conf" + return 1 + fi + fi # Otherwise, else # Show an error and exit echo -e "${OVER} ${CROSS} ${str} ${COL_LIGHT_RED}Error: Local repo ${PI_HOLE_LOCAL_REPO} not found, exiting installer${COL_NC}" - exit 1 + return 1 fi } @@ -1770,7 +1777,10 @@ installPihole() { accountForRefactor fi # Install base files and web interface - installScripts + if ! installScripts; then + echo -e " {CROSS} Failure in dependent script copy function." + exit 1 + fi # Install config files installConfigs # If the user wants to install the dashboard, @@ -2025,14 +2035,6 @@ FTLinstall() { # Always replace pihole-FTL.service install -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL.service" "/etc/init.d/pihole-FTL" - # Install template if it does not exist - if [[ ! -f "/etc/pihole/pihole-FTL.conf" ]]; then - if ! sudo -u ${USER} touch "/etc/pihole/pihole-FTL.conf" 2&>1 /dev/null; then - echo -e " ${COL_LIGHT_RED}Error: Unable to initialize configuration file /etc/pihole/pihole-FTL.conf" - return 1 - fi - fi - local ftlBranch local url From d0d030bafc7ba85b13eb7323500ea80599dca270 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 30 Jul 2018 14:02:18 -0700 Subject: [PATCH 4/6] Moved file creation to proper function. Included bash variables for file location. Set to pihole:pihole ownership with 644 permissions. Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 86e66ca0..0c257e96 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1219,13 +1219,7 @@ installScripts() { install -o "${USER}" -Dm755 -t /usr/local/bin/ pihole install -Dm644 ./advanced/bash-completion/pihole /etc/bash_completion.d/pihole echo -e "${OVER} ${TICK} ${str}" - # Install template if it does not exist - if [[ ! -f "/etc/pihole/pihole-FTL.conf" ]]; then - if ! sudo -u ${USER} touch "${PI_HOLE_INSTALL_DIR}/pihole-FTL.conf" 2&>1 /dev/null; then - echo -e " ${COL_LIGHT_RED}Error: Unable to initialize configuration file /etc/pihole/pihole-FTL.conf" - return 1 - fi - fi + # Otherwise, else # Show an error and exit @@ -1241,7 +1235,13 @@ installConfigs() { echo -e " ${INFO} Installing configs from ${PI_HOLE_LOCAL_REPO}..." # Make sure Pi-hole's config files are in place version_check_dnsmasq - + # Install template if it does not exist + if [[ ! -f "${PI_HOLE_INSTALL_DIR}/pihole-FTL.conf" ]]; then + if ! install -o pihole -g pihole -m 664 /dev/null "${PI_HOLE_INSTALL_DIR}/pihole-FTL.conf" &>/dev/nul; then + echo -e " ${COL_LIGHT_RED}Error: Unable to initialize configuration file ${PI_HOLE_INSTALL_DIR}/pihole-FTL.conf" + return 1 + fi + fi # If the user chose to install the dashboard, if [[ "${INSTALL_WEB_SERVER}" == true ]]; then # and if the Web server conf directory does not exist, @@ -1782,7 +1782,10 @@ installPihole() { exit 1 fi # Install config files - installConfigs + if ! installConfigs; then + echo -e " {CROSS} Failure in dependent config copy function." + exit 1 + fi # If the user wants to install the dashboard, if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then # do so From 448fc7231c55314585053e658b3f5e148ed447bf Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 30 Jul 2018 14:26:07 -0700 Subject: [PATCH 5/6] Installed to `/etc/pihole` as PI_HOLE_CONFIG_DIR variable. Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 0c257e96..178673a4 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -47,6 +47,7 @@ PI_HOLE_LOCAL_REPO="/etc/.pihole" PI_HOLE_FILES=(chronometer list piholeDebug piholeLogFlush setupLCD update version gravity uninstall webpage) # This folder is where the Pi-hole scripts will be installed PI_HOLE_INSTALL_DIR="/opt/pihole" +PI_HOLE_CONFIG_DIR="/etc/pihole" useUpdateVars=false adlistFile="/etc/pihole/adlists.list" @@ -1236,9 +1237,9 @@ installConfigs() { # Make sure Pi-hole's config files are in place version_check_dnsmasq # Install template if it does not exist - if [[ ! -f "${PI_HOLE_INSTALL_DIR}/pihole-FTL.conf" ]]; then - if ! install -o pihole -g pihole -m 664 /dev/null "${PI_HOLE_INSTALL_DIR}/pihole-FTL.conf" &>/dev/nul; then - echo -e " ${COL_LIGHT_RED}Error: Unable to initialize configuration file ${PI_HOLE_INSTALL_DIR}/pihole-FTL.conf" + if [[ ! -f "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" ]]; then + if ! install -o pihole -g pihole -m 664 /dev/null "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" &>/dev/nul; then + echo -e " ${COL_LIGHT_RED}Error: Unable to initialize configuration file ${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" return 1 fi fi From 993beab3b7bd2dab01dffd4f84f3b0f6a5c3a190 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Tue, 31 Jul 2018 11:14:26 -0700 Subject: [PATCH 6/6] Changed wording. Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 958c36c7..10e43b6c 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1237,7 +1237,7 @@ installConfigs() { echo -e " ${INFO} Installing configs from ${PI_HOLE_LOCAL_REPO}..." # Make sure Pi-hole's config files are in place version_check_dnsmasq - # Install template if it does not exist + # Install empty file if it does not exist if [[ ! -f "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" ]]; then if ! install -o pihole -g pihole -m 664 /dev/null "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" &>/dev/nul; then echo -e " ${COL_LIGHT_RED}Error: Unable to initialize configuration file ${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf"