shell nginx自启动脚本

!/bin/sh

nginx - this script starts and stops the nginx daemon

chkconfig: - 85 15

description: NGINX is an HTTP(S) server, HTTP(S) reverse \

proxy and IMAP/POP3 proxy server

processname: nginx

config: /usr/local/nginx/conf/nginx.conf

config: /etc/sysconfig/nginx

pidfile: /usr/local/nginx/logs/nginx.pid

Source function library.

. /etc/rc.d/init.d/functions

Source networking configuration.

. /etc/sysconfig/network

Check that networking is up.

[ "$NETWORKING" = "no" ] && exit 0

nginx="/usr/local/nginx/sbin/nginx"
prog=nginx)

NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"

[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

make_dirs() {

make required directories

user=$nginx -V 2>&1 | grep "configure arguments:.*--user=" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -
if [ -n "user /etc/passwd" ]; then useradd -M -s /bin/nologin $user fi options=options; do
if [ echo $opt | grep '.*-temp-path' ]; then
value=echo $opt | cut -d "=" -f 2
if [ ! -d "value
mkdir -p user $value
fi
fi
done
fi
}

start() {
[ -x NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n prog: "
daemon NGINX_CONF_FILE
retval=retval -eq 0 ] && touch retval
}

stop() {
echo -n prog: "
killproc ?
echo
[ lockfile
return $retval
}

restart() {
configtest || return $?
stop
sleep 1
start
}

reload() {
configtest || return "Reloading nginx -HUP
RETVAL=$?
echo
}

force_reload() {
restart
}

configtest() {
NGINX_CONF_FILE
}

rh_status() {
status $prog
}

rh_status_q() {
rh_status >/dev/null 2>&1
}

case "1
;;
stop)
rh_status_q || exit 0
1
;;
reload)
rh_status_q || exit 7
"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac

你可能感兴趣的:(shell nginx自启动脚本)