1 #!/bin/bash 2 #chkconfig: - 85 15 3 #by zhangjia 4 #2019年2月20日11:53:25 5 #shell_name:nginx_system_service.shell_name 6 #install nignx system service 7 ###################################################### 8 set -e 9 PATH="/usr/local/nginx" 10 DESC="nginx daemon" 11 NAME="nginx" 12 CONFIG_FILE=${PATH}/config/${NAME}.conf 13 DAEMON=${PATH}/sbin/${NAME} 14 PIDFILE=${PATH}/logs/${NAME}.pid 15 SCRIPTNAME=/etc/init.d/${NAME} 16 [ -x ${DAEMON} ] || exit 0 17 do_start() { 18 19 ${DAEMON} -c ${CONFIG_FILE} || echo -n "nginx already running" 20 } 21 22 do_stop() { 23 ${DAEMON} -s stop || echo -n "nginx is not running" 24 } 25 26 do_reload() { 27 ${DAEMON} -s reload || echo -n "nginx can not reload" 28 } 29 30 case $1 in 31 start) 32 do_start 33 echo "." 34 ;; 35 36 stop) 37 do_stop 38 ;; 39 40 reload) 41 do_reload 42 ;; 43 44 restart) 45 do_stop 46 do_start 47 ;; 48 *) 49 echo -e "please enter \"start | stop | restart | reload \"";; 50 esac 51