琐碎的学习——lsb服务启动脚本

#!/bin/sh
NGINX_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.status

rc_reset

ulimit -SHn 65535

PHPFPM='/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
        ;;
esac
rc_exit

 保存问test.sh,可以简单地时间服务开启关闭查看状态等操作(效果如下)

 

ciaos #./test.sh start
Starting Nginx                                                        done
Starting php-fpm done, pid file found.
ciaos #./test.sh status
Checking for Nginx:                                                   running
ciaos #./test.sh restart
Shutting down Nginx                                                   done
Gracefully shutting down php-fpm . done
Starting Nginx                                                        done
Starting php-fpm  done
ciaos #./test.sh stop
Shutting down Nginx                                                   done
Gracefully shutting down php-fpm . done

附参考链接:Opensuse启动脚本

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值