linux启动脚本

#!/bin/bash

#

# chkconfig: 2345 91 35

# description: Starts and stops gemss.

# Source function library.

. /etc/init.d/functions

# Source networking configuration.

. /etc/sysconfig/network

# Check that networking is up.

[ ${NETWORKING} = "no" ] && exit 0

install_dir=/opt/gemss

[ -f ${install_dir}/gemss.xml ] || exit 0

prog=$"gemss"

RETVAL=0

start() {

        KIND="gemss"

        echo -n $"Starting $KIND services: "

        cd $install_dir

        daemon ${install_dir}/gemss --daemon --nochdir

        RETVAL=$?

        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/gemss || \

           RETVAL=1

        return $RETVAL

}

stop() {

        KIND="gemss"

        echo -n $"Shutting down $KIND services: "

        killproc gemss

        RETVAL=$?

        echo

        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/gemss

        echo ""

        return $RETVAL

}

restart() {

        stop

        start

}

reload() {

        echo -n $"Reloading gemss.xml file: "

        killproc gemss -HUP

        RETVAL=$?

        echo

        return $RETVAL

}

rhstatus() {

        status gemss

}

# Allow status as non-root.

if [ "$1" = status ]; then

       rhstatus

       exit $?

fi

# Check that we can write to it... so non-root users stop here

[ -w ${install_dir}/gemss.xml ] || exit 0

case "$1" in

  start)

        start

        ;;

  stop)

        stop

        ;;

  restart)

        restart

        ;;

  reload)

        reload

        ;;

  status)

        rhstatus

        ;;

  condrestart)

        [ -f /var/lock/subsys/gemss ] && restart || :

        ;;

  *)

        echo $"Usage: $0 {start|stop|restart|reload|status|condrestart}"

        exit 1

esac

exit $?


猜你喜欢

转载自lanmh.iteye.com/blog/839584