From a9650ae28736aedd62680f4f705525021185d519 Mon Sep 17 00:00:00 2001 From: Karol Kania <44871508+karolkania@users.noreply.github.com> Date: Fri, 28 Feb 2025 12:52:07 +0100 Subject: [PATCH 1/2] Update gravity.sh fix the `if statement` that doesn't seem to work for neither of alpine's ash / bash - applying some workaround with the `stat` command Signed-off-by: Karol Kania <44871508+karolkania@users.noreply.github.com> --- gravity.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gravity.sh b/gravity.sh index 0a34599b..cc8c6ba1 100755 --- a/gravity.sh +++ b/gravity.sh @@ -541,14 +541,18 @@ gravity_DownloadBlocklists() { # it (in case it doesn't exist) # First, check if the directory is writable directory="$(dirname -- "${saveLocation}")" - if [ ! -w "${directory}" ]; then + directory_permissions=$(stat -c %a ${directory}) + # echo "directory_permissions: ${directory_permissions}" + if [ $directory_permissions -lt 700 ]; then echo -e " ${CROSS} Unable to write to ${directory}" echo " Please run pihole -g as root" echo "" continue fi # Then, check if the file is writable (if it exists) - if [ -e "${saveLocation}" ] && [ ! -w "${saveLocation}" ]; then + saveLocation_permissions=$(stat -c %a ${saveLocation}) + # echo "saveLocation_permissions: ${saveLocation_permissions}" + if [ -e "${saveLocation}" ] && [ ${saveLocation_permissions} -lt 600 ]; then echo -e " ${CROSS} Unable to write to ${saveLocation}" echo " Please run pihole -g as root" echo "" From 9c7e02f213654da2cbf83727bbaccd5bd1ff9907 Mon Sep 17 00:00:00 2001 From: Karol Kania <44871508+karolkania@users.noreply.github.com> Date: Sun, 2 Mar 2025 12:05:42 +0100 Subject: [PATCH 2/2] Update gravity.sh remove the left-over commented debug code Signed-off-by: Karol Kania <44871508+karolkania@users.noreply.github.com> --- gravity.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/gravity.sh b/gravity.sh index cc8c6ba1..ad94ca54 100755 --- a/gravity.sh +++ b/gravity.sh @@ -542,7 +542,6 @@ gravity_DownloadBlocklists() { # First, check if the directory is writable directory="$(dirname -- "${saveLocation}")" directory_permissions=$(stat -c %a ${directory}) - # echo "directory_permissions: ${directory_permissions}" if [ $directory_permissions -lt 700 ]; then echo -e " ${CROSS} Unable to write to ${directory}" echo " Please run pihole -g as root" @@ -551,7 +550,6 @@ gravity_DownloadBlocklists() { fi # Then, check if the file is writable (if it exists) saveLocation_permissions=$(stat -c %a ${saveLocation}) - # echo "saveLocation_permissions: ${saveLocation_permissions}" if [ -e "${saveLocation}" ] && [ ${saveLocation_permissions} -lt 600 ]; then echo -e " ${CROSS} Unable to write to ${saveLocation}" echo " Please run pihole -g as root"