Open bitboss-ca opened 1 year ago
In addition, when flag -q is used together with -m, an empty-body email is sent. If there are no issues during the update, no email should be sent.
@cmdpedro, what operating system are you running?
nginx version: nginx/1.20.1 5.4.0-147-generic #164-Ubuntu SMP Tue Mar 21 14:23:17 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Update: it would appear that this has already been fixed in the main branch, so I guess we're just waiting for the code to get bumped in FreeBSD Packages.
On my system I have this code in /usr/local/sbin/update-ngxblocker
:
update_paths() {
# variables in nginx include files not currently possible
# updates hard coded bots.d path in globalblacklist.conf
local blacklist=$1 include_paths= dir= x=
case ${OS} in
Linux)
if ! grep "$BOTS_DIR" $blacklist 1>/dev/null; then
if [ -d $BOTS_DIR ]; then
printf "${BOLDGREEN}Updating bots.d path${RESET}: ${BOLDWHITE}$BOTS_DIR => $blacklist${RESET}\n"
include_paths=$(grep -E "include /.*.conf;$" $blacklist | awk '{print $2}' | tr -d ';')
for x in $include_paths; do
dir=$(dirname $x)
${SED_CMD} -i "s|$dir|$BOTS_DIR|" $blacklist
done
else
printf "${BOLDRED}ERROR${RESET}: '$BOTS_DIR' does not exist => ${BOLDWHITE}running $INSTALLER${RESET}.\n"
$INSTALL_INC
update_paths $blacklist
fi
fi
;;
*BSD)
printf "${BOLDGREEN}Updating bots.d path${RESET}\n"
/usr/bin/sed -i "" -e 's:include .*nginx/:include :g' ${BOTS_DIR}/*.conf ${CONF_DIR}/*.conf
;;
esac
}
Whereas Master branch has this:
update_paths() {
# variables in nginx include files not currently possible
# updates hard coded bots.d path in globalblacklist.conf
local blacklist=$1 include_paths= dir= x=
if ! grep "$BOTS_DIR" $blacklist 1>/dev/null; then
if [ -d $BOTS_DIR ]; then
printf "${BOLDGREEN}Updating bots.d path${RESET}: ${BOLDWHITE}$BOTS_DIR => $blacklist${RESET}\n"
include_paths=$(grep -E "include /.*.conf;$" $blacklist | awk '{print $2}' | tr -d ';')
for x in $include_paths; do
dir=$(dirname $x)
${SED_CMD} -i "s|$dir|$BOTS_DIR|" $blacklist
done
else
printf "${BOLDRED}ERROR${RESET}: '$BOTS_DIR' does not exist => ${BOLDWHITE}running $INSTALLER${RESET}.\n"
$INSTALL_INC
update_paths $blacklist
fi
fi
}
I'm not sure what this bit of code was intended to accomplish. Running that sed
command on my system doesn't do anything to the .conf
files.
*BSD)
printf "${BOLDGREEN}Updating bots.d path${RESET}\n"
/usr/bin/sed -i "" -e 's:include .*nginx/:include :g' ${BOTS_DIR}/*.conf ${CONF_DIR}/*.conf
;;
esac
So I have commented/disabled it like so.
*BSD)
# printf "${BOLDGREEN}Updating bots.d path${RESET}\n"
# /usr/bin/sed -i "" -e 's:include .*nginx/:include :g' ${BOTS_DIR}/*.conf ${CONF_DIR}/*.conf
;;
esac
Now /usr/local/sbin/update-ngxblocker -q
is silent when there are no errors.
@cmdpedro, I'm on FreeBSD, so I think your case is different. It looks to me the it might have to do with the update_paths()
function testing for the full path to the $BOTS_DIR
in $blacklist
when the path may be relative.
Describe the bug
Running update-ngxblocker -q on FreeBSD outputs: Updating bots.d path
To Reproduce
Install using packages, setup, tested and running fine. Then run updater with
-q
option to suppress non-error messages, like so:Expected behavior
Silent update.
Copy of nginx.conf
Server (please complete the following information):
Additional information
A normal run of the updater would look like this: