标签:$0 root enabled etc 条件语句 模拟 span pcr module
说明: 已在CentOS 7.2 上编译安装nginx 1.13.6 -- 练手!!!
[root@rainjin scripts]# /application/nginx/sbin/nginx -V
nginx version: nginx/1.13.6
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
built with OpenSSL 1.1.0f 25 May 2017
TLS SNI support enabled
configure arguments: --prefix=/application/nginx-1.13.6 --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-pcre=../pcre-8.41 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.1.0f
[root@rainjin scripts]# cat nginx.sh
#!/bin/bash
#simulate the Nginx‘s running process;
. /etc/init.d/functions
CMD=$1
if [ "$CMD" = "start" ]
then
if [ `ps -ef | grep -c [n]ginx | wc -l` -gt 1 ]
then
echo "nginx already running."
exit 1
fi
/application/nginx/sbin/nginx &>/dev/null
if [ $? -eq 0 ]
then
action "start nginx" /bin/true
else
action "start nginx" /bin/false
fi
elif [ "$CMD" = "stop" ]
then
killall nginx &>/dev/null
if [ $? -eq 0 ]
then
action "stop nginx" /bin/true
else
action "stop nginx" /bin/false
exit 2
fi
elif [ "$CMD" = "restart" ]
then
killall nginx &>/dev/null
/application/nginx/sbin/nginx &>/dev/null
if [ $? -eq 0 ]
then
action "restart nginx" /bin/true
else
action "restart nginx" /bin/false
fi
else
echo "Usage: sh $0 {start|stop|restart}"
fi
标签:$0 root enabled etc 条件语句 模拟 span pcr module
原文地址:http://www.cnblogs.com/rainjin/p/7747774.html