编写SVN服务脚本

#!/bin/bash
 
# For example: following config would generate link
# S51myservice in rc2.d, rc3.d, rc4.d, rc5.d and 
# K49myservice in rc0.d, rc1.d, rc6.d
 
# Comments to support chkconfig on RedHat Linux
# run level, start order, stop order
 
# chkconfig: 2345 51 49 
# description: Customized service written by Alvis.

  
start() {

        sh /script/svn/svnstart.sh
        if [[ $? -eq 0 ]]; then 
                echo "svn start success"
        else
                return 1
        exit
        fi
}
stop() {
        sh /script/svn/svnstop.sh
        if [[ $? -eq 0 ]]; then
                echo "svn stop success"
        else
                return 1
        exit
        fi

}
restart() {
        sh /script/svn/svnstart.sh
        if [[ $? -eq 0 ]]; then
                echo "svn start success;" 
        else
                 return 1
        exit
        fi
        sh /script/svn/svnstop.sh
        if [[ $? -eq 0 ]]; then
                echo "svn stop success"
        else
                return 1
        exit
        fi

}
status() {
        pgrep "svnserve" >>null
        if [[ $? -eq 0 ]]; then
                echo "svn is running pid is `pgrep "svnserve"` ......"
        else
                echo "svn is stopping ......"
        exit
        fi
}

case "$1" in 

    start)

        start

        ;;

    stop)

        stop

        ;;

    restart)

        restart

        ;;

    status)

        status

        ;;

    *)

        echo 'Usage: service myservice {start|status|stop|restart}'

        echo ''

        exit 1
esac

exit 0

2017-3-29 10:44:30

点赞