plugin/nginx: cleanup
Dont overwrite user-set variable, and quote path. Local some variables, `shellcheck`, `shfmt`pull/2011/head
parent
b846c86dbb
commit
079652e6e7
|
|
@ -104,6 +104,7 @@ plugins/available/jekyll.plugin.bash
|
|||
plugins/available/jump.plugin.bash
|
||||
plugins/available/less-pretty-cat.plugin.bash
|
||||
plugins/available/man.plugin.bash
|
||||
plugins/available/nginx.plugin.bash
|
||||
plugins/available/node.plugin.bash
|
||||
plugins/available/nodenv.plugin.bash
|
||||
plugins/available/osx-timemachine.plugin.bash
|
||||
|
|
|
|||
|
|
@ -1,66 +1,55 @@
|
|||
cite about-plugin
|
||||
# shellcheck shell=bash
|
||||
about-plugin 'manage your nginx service'
|
||||
|
||||
export NGINX_PATH='/opt/nginx'
|
||||
pathmunge $NGINX_PATH/sbin after
|
||||
pathmunge "${NGINX_PATH:=/opt/nginx}/sbin" after
|
||||
export NGINX_PATH
|
||||
|
||||
function nginx_reload() {
|
||||
about 'reload your nginx config'
|
||||
group 'nginx'
|
||||
about 'reload your nginx config'
|
||||
group 'nginx'
|
||||
|
||||
FILE="${NGINX_PATH}/logs/nginx.pid"
|
||||
if [ -e $FILE ]; then
|
||||
echo "Reloading NGINX..."
|
||||
PID=`cat $NGINX_PATH/logs/nginx.pid`
|
||||
sudo kill -HUP $PID
|
||||
else
|
||||
echo "Nginx pid file not found"
|
||||
return 0
|
||||
fi
|
||||
local FILE="${NGINX_PATH?}/logs/nginx.pid"
|
||||
if [[ -s $FILE ]]; then
|
||||
echo "Reloading NGINX..."
|
||||
read -r PID < "${FILE}"
|
||||
sudo kill -HUP "${PID?}"
|
||||
else
|
||||
echo "Nginx pid file not found"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
function nginx_stop() {
|
||||
about 'stop nginx'
|
||||
group 'nginx'
|
||||
about 'stop nginx'
|
||||
group 'nginx'
|
||||
|
||||
FILE="${NGINX_PATH}/logs/nginx.pid"
|
||||
if [ -e $FILE ]; then
|
||||
echo "Stopping NGINX..."
|
||||
PID=`cat $NGINX_PATH/logs/nginx.pid`
|
||||
sudo kill -INT $PID
|
||||
else
|
||||
echo "Nginx pid file not found"
|
||||
return 0
|
||||
fi
|
||||
local FILE="${NGINX_PATH?}/logs/nginx.pid"
|
||||
if [[ -s $FILE ]]; then
|
||||
echo "Stopping NGINX..."
|
||||
read -r PID < "${FILE}"
|
||||
sudo kill -INT "${PID?}"
|
||||
else
|
||||
echo "Nginx pid file not found"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
function nginx_start() {
|
||||
about 'start nginx'
|
||||
group 'nginx'
|
||||
about 'start nginx'
|
||||
group 'nginx'
|
||||
|
||||
FILE="${NGINX_PATH}/sbin/nginx"
|
||||
if [ -e $FILE ]; then
|
||||
echo "Starting NGINX..."
|
||||
sudo $NGINX_PATH/sbin/nginx
|
||||
else
|
||||
echo "Couldn't start nginx"
|
||||
fi
|
||||
local FILE="${NGINX_PATH?}/sbin/nginx"
|
||||
if [[ -x $FILE ]]; then
|
||||
echo "Starting NGINX..."
|
||||
sudo "${FILE}"
|
||||
else
|
||||
echo "Couldn't start nginx"
|
||||
fi
|
||||
}
|
||||
|
||||
function nginx_restart() {
|
||||
about 'restart nginx'
|
||||
group 'nginx'
|
||||
about 'restart nginx'
|
||||
group 'nginx'
|
||||
|
||||
FILE="${NGINX_PATH}/logs/nginx.pid"
|
||||
if [ -e $FILE ]; then
|
||||
echo "Stopping NGINX..."
|
||||
PID=`cat $NGINX_PATH/logs/nginx.pid`
|
||||
sudo kill -INT $PID
|
||||
sleep 1
|
||||
echo "Starting NGINX..."
|
||||
sudo $NGINX_PATH/sbin/nginx
|
||||
else
|
||||
echo "Nginx pid file not found"
|
||||
return 0
|
||||
fi
|
||||
nginx_stop && nginx_start
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue