-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2011 from gaelicWizard/plugin-nginx
plugin/nginx: cleanup
- Loading branch information
Showing
2 changed files
with
41 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
|
||
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 | ||
about 'reload your nginx config' | ||
group 'nginx' | ||
|
||
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' | ||
|
||
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 | ||
about 'stop nginx' | ||
group 'nginx' | ||
|
||
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' | ||
|
||
FILE="${NGINX_PATH}/sbin/nginx" | ||
if [ -e $FILE ]; then | ||
echo "Starting NGINX..." | ||
sudo $NGINX_PATH/sbin/nginx | ||
else | ||
echo "Couldn't start nginx" | ||
fi | ||
about 'start nginx' | ||
group 'nginx' | ||
|
||
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 | ||
} |