mirror of
https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker.git
synced 2025-09-02 02:29:58 +00:00
Merge pull request #267 from itoffshore/alpine
simplify reloading nginx configuration after updating
This commit is contained in:
commit
71afff69ec
1 changed files with 12 additions and 31 deletions
|
@ -164,29 +164,6 @@ update_paths() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
service_cmd() {
|
|
||||||
# arch linux does not have a 'service' command
|
|
||||||
local x= svc= svc_list="service systemctl rc-service rcctl"
|
|
||||||
|
|
||||||
for x in $svc_list; do
|
|
||||||
svc=$(which $x 2>/dev/null)
|
|
||||||
if [ -n "$svc" ]; then
|
|
||||||
case "$x" in
|
|
||||||
service) svc="$svc nginx reload";;
|
|
||||||
systemctl) svc="$svc reload nginx.service";;
|
|
||||||
rc-service) svc="$svc nginx reload";;
|
|
||||||
rcctl) svc="$svc reload nginx";;
|
|
||||||
esac
|
|
||||||
break
|
|
||||||
else
|
|
||||||
# centos does not have 'which' by default
|
|
||||||
svc="/usr/sbin/service nginx reload"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo $svc
|
|
||||||
}
|
|
||||||
|
|
||||||
sanitize_path() {
|
sanitize_path() {
|
||||||
echo $1 |tr -cd '[:alnum:] [=@=] [=.=] [=-=] [=/=] [=_=]' \
|
echo $1 |tr -cd '[:alnum:] [=@=] [=.=] [=-=] [=/=] [=_=]' \
|
||||||
|tr -s '@.-/_' |awk '{print tolower($0)}'
|
|tr -s '@.-/_' |awk '{print tolower($0)}'
|
||||||
|
@ -335,7 +312,7 @@ get_options() {
|
||||||
main() {
|
main() {
|
||||||
local REPO=https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master
|
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 file=globalblacklist.conf remote_dir=conf.d url= output= update= status= tmp= retval=
|
||||||
local reload_service="$(service_cmd)"
|
local nginx_path=$(find_binary nginx)
|
||||||
|
|
||||||
# require root
|
# require root
|
||||||
if [ "$(id -u)" != "0" ]; then
|
if [ "$(id -u)" != "0" ]; then
|
||||||
|
@ -381,15 +358,19 @@ main() {
|
||||||
# re-read nginx configuration
|
# re-read nginx configuration
|
||||||
if [ $retval = 0 ]; then
|
if [ $retval = 0 ]; then
|
||||||
|
|
||||||
$reload_service 2>&1 >/dev/null
|
if pidof nginx 1>/dev/null; then
|
||||||
|
|
||||||
|
$nginx_path -s reload 2>&1 >/dev/null
|
||||||
|
|
||||||
if [ $? = 0 ]; then
|
if [ $? = 0 ]; then
|
||||||
status="${BOLDGREEN}[OK]${RESET}"
|
status="${BOLDGREEN}[OK]${RESET}"
|
||||||
print_message "\nReloading NGINX configuration...$status\n"
|
print_message "\nReloading NGINX configuration...$status\n"
|
||||||
|
|
||||||
else
|
else
|
||||||
status="${BOLDRED}[FAILED]${RESET}"
|
status="${BOLDRED}[FAILED]${RESET}"
|
||||||
printf "\nReloading NGINX configuration...$status\n"
|
printf "\nReloading NGINX configuration...$status\n"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
printf "\n${BOLDRED}NGINX is not running${RESET}: not reloading NGINX config\n"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
printf "\n${BOLDRED}Download failed${RESET}: not reloading NGINX config\n"
|
printf "\n${BOLDRED}Download failed${RESET}: not reloading NGINX config\n"
|
||||||
|
|
Loading…
Add table
Reference in a new issue