shell template

163 阅读1分钟
# 获取当前路径
BaseDir=$(cd $(dirname $0) && pwd)

# 颜色变量定义
function echo_err () {
        local what=$*
        echo -e "\e[1;31m[Error]${what}\e[0m"
}
function echo_info () {
        local what=$*
        echo -e "\e[1;32m[Info]${what}\e[0m"
}

# case循环
case "$1" in
    start)
        rh_status_q && exit 0
        ;;
    restart|configtest|reopen_logs)
        ;;
    condrestart|try-restart)
        rh_status_q || exit 7
        restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|reload|configtest|status|force-reload|upgrade|restart|reopen_logs}"
        exit 2
esac