mirror of
https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker.git
synced 2025-09-02 10:40:36 +00:00
Merge pull request #135 from itoffshore/alpine
* fix service command for cron jobs * install to /usr/local/sbin by default
This commit is contained in:
commit
baa6b3cb4b
3 changed files with 28 additions and 20 deletions
|
@ -23,18 +23,18 @@
|
|||
### You can also now use a setup script contributed by Stuart Cardall to automatically insert the includes for you
|
||||
### See - https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/setup-ngxblocker
|
||||
|
||||
# Save this file as /usr/sbin/install-ngxblocker
|
||||
# sudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/install-ngxblocker -O /usr/sbin/install-ngxblocker
|
||||
# Save this file as /usr/local/sbin/install-ngxblocker
|
||||
# sudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/install-ngxblocker -O /usr/local/sbin/install-ngxblocker
|
||||
# Make it Executable:
|
||||
# chmod 700 /usr/sbin/install-ngxblocker
|
||||
# chmod 700 /usr/local/sbin/install-ngxblocker
|
||||
# Run it from the command line:
|
||||
# sudo /usr/sbin/install-ngxblocker [ -h ]
|
||||
# sudo /usr/local/sbin/install-ngxblocker [ -h ]
|
||||
|
||||
######## LETS INSTALL NOW ###############################
|
||||
|
||||
CONF_DIR=/etc/nginx/conf.d
|
||||
BOTS_DIR=/etc/nginx/bots.d
|
||||
SCRIPT_DIR=/usr/sbin
|
||||
SCRIPT_DIR=/usr/local/sbin
|
||||
REPO=https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master
|
||||
|
||||
####### end user configuration ##########################
|
||||
|
|
|
@ -12,7 +12,7 @@ VHOST_DIR=/etc/nginx/sites-available
|
|||
BOTS_DIR=/etc/nginx/bots.d
|
||||
CONF_DIR=/etc/nginx/conf.d
|
||||
MAIN_CONF=/etc/nginx/nginx.conf
|
||||
INSTALLER=/usr/sbin/install-ngxblocker
|
||||
INSTALLER=/usr/local/sbin/install-ngxblocker
|
||||
# setting Y / yes will whitelist only directories in $www
|
||||
# that look like domain.names
|
||||
DOT_NAMES="Y"
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
|
||||
# PLEASE READ UPDATED CONFIGURATION INSTRUCTIONS BEFORE USING THIS
|
||||
|
||||
# Save this file as /usr/sbin/update-ngxblocker
|
||||
# cd /usr/sbin
|
||||
# Save this file as /usr/local/sbin/update-ngxblocker
|
||||
# cd /usr/local/sbin
|
||||
# sudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/update-ngxblocker -O update-ngxblocker
|
||||
# Make it Executable chmod 700 /usr/sbin/update-ngxblocker
|
||||
# Make it Executable chmod 700 /usr/local/sbin/update-ngxblocker
|
||||
|
||||
# RUN THE UPDATE
|
||||
# Here our script runs, pulls the latest update, reloads nginx and emails you a notification
|
||||
|
@ -32,7 +32,7 @@ EMAIL="me@myemail.com"
|
|||
SEND_EMAIL="N"
|
||||
CONF_DIR=/etc/nginx/conf.d
|
||||
BOTS_DIR=/etc/nginx/bots.d
|
||||
INSTALLER=/usr/sbin/install-ngxblocker
|
||||
INSTALLER=/usr/local/sbin/install-ngxblocker
|
||||
|
||||
##### end user configuration ##############################################################
|
||||
|
||||
|
@ -140,15 +140,24 @@ update_paths() {
|
|||
|
||||
service_cmd() {
|
||||
# arch linux does not have a 'service' command
|
||||
local svc= svc_list="service systemctl rc-service"
|
||||
local x= svc= svc_list="service systemctl rc-service"
|
||||
|
||||
for svc in $svc_list; do
|
||||
for x in $svc_list; do
|
||||
svc=$(which $svc 2>/dev/null)
|
||||
if [ -n "$svc" ]; then
|
||||
echo $svc
|
||||
exit 0
|
||||
case "$x" in
|
||||
service) svc="$svc nginx reload";;
|
||||
systemctl) svc="$svc reload nginx.service";;
|
||||
rc-service) svc="$svc nginx reload";;
|
||||
esac
|
||||
break
|
||||
else
|
||||
# centos does not have 'which' by default
|
||||
svc="/usr/sbin/service nginx reload"
|
||||
fi
|
||||
done
|
||||
|
||||
echo $svc
|
||||
}
|
||||
|
||||
sanitize_path() {
|
||||
|
@ -259,8 +268,7 @@ get_options() {
|
|||
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=
|
||||
# default to service (centos does not have 'which' by default)
|
||||
local service=${service_cmd:-"service"}
|
||||
local reload_service=$(service_cmd)
|
||||
|
||||
# require root
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
|
@ -307,7 +315,7 @@ main() {
|
|||
# re-read nginx configuration
|
||||
if [ $retval = 0 ]; then
|
||||
|
||||
$service nginx reload 2>&1 >/dev/null
|
||||
$reload_service 2>&1 >/dev/null
|
||||
if [ $? = 0 ]; then
|
||||
status="${BOLDGREEN}[OK]${RESET}"
|
||||
print_message "\nReloading NGINX configuration...$status\n"
|
||||
|
@ -351,13 +359,13 @@ exit $?
|
|||
|
||||
# Add this as a cron to run daily / weekly as you like
|
||||
# Here's a sample CRON entry to update every day at 10pm
|
||||
# 00 22 * * * sudo /usr/sbin/update-ngxblocker -q
|
||||
# 00 22 * * * sudo /usr/local/sbin/update-ngxblocker -q
|
||||
|
||||
# Here's another example to run it daily at midday using a command line switch to set the email address for the notification
|
||||
# 00 12 * * * sudo /usr/sbin/update-ngxblocker -e yourname@youremailprovider.com
|
||||
# 00 12 * * * sudo /usr/local/sbin/update-ngxblocker -e yourname@youremailprovider.com
|
||||
|
||||
# Less verbose logging to a system alias mail address (root crontab)
|
||||
# 00 12 * * * /usr/sbin/update-ngxblocker -q -m webmaster
|
||||
# 00 12 * * * /usr/local/sbin/update-ngxblocker -q -m webmaster
|
||||
|
||||
# better logging for cron jobs:
|
||||
# https://serverfault.com/questions/137468/better-logging-for-cronjobs-send-cron-output-to-syslog
|
||||
|
|
Loading…
Add table
Reference in a new issue