琐碎的学习——lsb服务启动脚本
#!/bin/shNGINX_BIN="/usr/local/ciaos/sbin/nginx"# Shell functions sourced from /etc/rc.status:# rc_check check and set local and overall rc status# rc_status check and set local and overall rc status# rc_status -v ditto but be verbose in local rc status# rc_status -v -r ditto and clear the local rc status# rc_failed set local and overall rc status to failed# rc_failed <num> set local and overall rc status to <num><num># rc_reset clear local rc status (overall remains)# rc_exit exit appropriate to overall rc status. /etc/rc.statusrc_resetulimit -SHn 65535PHPFPM='/usr/local/ciaos/etc/init.d/php-fpm'case "$1" in start) echo -n "Starting Nginx" startproc $NGINX_BIN rc_status -v $PHPFPM start ;; stop) echo -n "Shutting down Nginx" killproc -TERM $NGINX_BIN rc_status -v $PHPFPM stop ;; restart) $0 stop $0 start rc_status ;; reload) echo -n "Reloading Nginx" killproc -HUP $NGINX_BIN rc_status -v $PHPFPM reload ;; status) echo -n "Checking for Nginx: " checkproc $NGINX_BIN rc_status -v ;; *) echo "Usage: $0 {start|stop|status|restart|reload|probe}" exit 1 ;;esacrc_exit?保存问test.sh,可以简单地时间服务开启关闭查看状态等操作(效果如下)
?
ciaos #./test.sh startStarting Nginx doneStarting php-fpm done, pid file found.ciaos #./test.sh statusChecking for Nginx: runningciaos #./test.sh restartShutting down Nginx doneGracefully shutting down php-fpm . doneStarting Nginx doneStarting php-fpm doneciaos #./test.sh stopShutting down Nginx doneGracefully shutting down php-fpm . done
附参考链接:Opensuse启动脚本