Index: head/www/nginx-ultimate-bad-bot-blocker/Makefile =================================================================== --- head/www/nginx-ultimate-bad-bot-blocker/Makefile (revision 532268) +++ head/www/nginx-ultimate-bad-bot-blocker/Makefile (revision 532269) @@ -1,41 +1,47 @@ # $FreeBSD$ PORTNAME= nginx-ultimate-bad-bot-blocker DISTVERSIONPREFIX= V +# The config files are updated frequently (not installed by this port, +# but by install-ngxblocker / update-ngxblocker). +# The scripts (installed by this port) are not updated frequently. +# The version number of the project is related to the combination of +# scripts and config. As such a more recent upstream version is most +# of the time OK (as long as you use update-ngxblocker in crontab). DISTVERSION= 4.2020.03.2005 -PORTREVISION= 0 +PORTREVISION= 1 CATEGORIES= www security MAINTAINER= netchild@FreeBSD.org COMMENT= Nginx bad bot and other things blocker LICENSE= MIT LICENSE_FILE= ${WRKSRC}/LICENSE.md RUN_DEPENDS= curl:ftp/curl \ gsed:textproc/gsed \ wget:ftp/wget USE_GITHUB= yes GH_ACCOUNT= mitchellkrogza NO_ARCH= yes NO_BUILD= yes SUB_FILES= pkg-message PLIST_FILES= sbin/install-ngxblocker \ sbin/setup-ngxblocker \ sbin/update-ngxblocker post-patch: ${REINPLACE_CMD} -e 's:/usr/local:${PREFIX}:g' \ -e 's:/etc/nginx:${LOCALBASE}/etc/nginx:g' \ -e 's:nginx/sites-available:nginx/sites:g' \ -e 's:/var/www:${LOCALBASE}/www:g' \ -e 's:VHOST_EXT="vhost":VHOST_EXT="conf":' ${WRKSRC}/*-ngxblocker do-install: ${INSTALL_SCRIPT} ${WRKSRC}/*-ngxblocker ${STAGEDIR}${PREFIX}/sbin/ .include Index: head/www/nginx-ultimate-bad-bot-blocker/files/patch-update-ngxblocker =================================================================== --- head/www/nginx-ultimate-bad-bot-blocker/files/patch-update-ngxblocker (revision 532268) +++ head/www/nginx-ultimate-bad-bot-blocker/files/patch-update-ngxblocker (revision 532269) @@ -1,79 +1,79 @@ --- update-ngxblocker +++ update-ngxblocker @@ -148,6 +148,8 @@ update_paths() { # 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" @@ -163,6 +165,12 @@ update_paths() { 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_DIR}/* ++ /usr/bin/sed -i "" -e 's:include .*nginx/:include :g' ${BOTS_DIR}/*.conf ${CONF_DIR}/*.conf + ;; + esac } sanitize_path() { @@ -319,11 +327,39 @@ get_options() { INSTALL_INC="$INSTALLER -b $BOTS_DIR -c $CONF_DIR -x" } +nginx_check_status() { + local pidof_path=$(find_binary pidof) + + case ${OS} in + Linux) + $pidof_path nginx 1>/dev/null + return $? + ;; + FreeBSD) + /usr/sbin/service nginx status | /usr/bin/grep -q running + return $? + ;; + esac +} + +nginx_reload() { + local nginx_path=$(find_binary nginx) + + case ${OS} in + Linux) + $nginx_path -s reload 2>&1 >/dev/null + return $? + ;; + FreeBSD) + /usr/sbin/service nginx reload >/dev/null 2>&1 + return $? + ;; + esac +} + main() { local REPO=https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master local file=globalblacklist.conf remote_dir=conf.d url= output= update= status= tmp= retval= - local nginx_path=$(find_binary nginx) - local pidof_path=$(find_binary pidof) # require root if [ "$(id -u)" != "0" ]; then @@ -370,9 +406,10 @@ main() { if [ $retval = 0 ]; then # use full paths to workaround crontabs without $PATH configured - if $pidof_path nginx 1>/dev/null; then + nginx_check_status + if [ $? -eq 0 ]; then - $nginx_path -s reload 2>&1 >/dev/null + nginx_reload if [ $? = 0 ]; then status="${BOLDGREEN}[OK]${RESET}"