Start stop script debian

Discussion in 'Server Operation' started by ColdDoT, Apr 22, 2006.

  1. ColdDoT

    ColdDoT Member

    Hello

    i've got a little program that start a toc server (it is a sh script);
    in it stands
    Code:
    #! /bin/sh
    
    #Additional arguments for the Server
    
    prefix="TOCserver"
    args=" server OBJ-Anvil.to2?AdminName=colddot?AdminPassword=xxxxxxx -ini=../TOCrossfire/Conf/$prefix.ini userini=../TOCross
    fire/Conf/$prefix.user.ini log=../TOCrossfire/Log/$prefix.log -nohomedir"
    
    
    arch=`uname -m`
    
    if [ $arch = "i686" ]; then
            bin="ucc-bin"
    elif [ $arch = "x86_64" ]; then
            bin="ucc-bin-linux-amd64"
    elif [ $arch = "Power Macintosh" ]; then
            bin="ucc-bin-macosx"
    else
            echo "Your system is not supported !"
            exit 0
    fi
    
    while [ true ]; do
    
            cd /var/server/ut/public/System
            ./$bin $args
            sleep 5
    
    done
    
    now what i want to do is making a nicly init.d script
    but i want no output from the program it self
    so i have maded this
    Code:
    #! /bin/sh
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    DAEMON=/usr/bin/toc
    NAME=toc
    DESC="tactical ops crossfire"
    
    test -f $DAEMON || exit 0
    
    set -e
    
    case "$1" in
      start)
            echo -n "Starting $DESC: "
            start-stop-daemon --start --quiet -m -b --pidfile /var/run/$NAME.pid \
                    --exec $DAEMON
            echo "$NAME."
            ;;
      stop)
            echo -n "Stopping $DESC: "
            start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
                    --exec $DAEMON
            echo "$NAME."
            ;;
      restart|force-reload)
            echo -n "Restarting $DESC: "
            start-stop-daemon --stop --quiet --pidfile \
                    /var/run/$NAME.pid --exec $DAEMON
            sleep 1
            start-stop-daemon --start --quiet --pidfile \
                    /var/run/$NAME.pid --exec $DAEMON
            echo "$NAME."
            ;;
      *)
            N=/etc/init.d/$NAME
            echo "Usage: $N {start|stop|restart|force-reload}" >&2
            exit 1
            ;;
    esac
    
    the starting works fine but the shutdown it don't work.
    is there a solution on this?

    greets kevin
     
    Last edited: May 15, 2006
  2. falko

    falko Super Moderator Howtoforge Staff

    Have a look at the stop section of the /etc/init.d/mydns script on http://www.howtoforge.com/mydns_name_server. But this will only work for stopping one process. If multiple processes are running at the same time, it doesn't work.
     
  3. ColdDoT

    ColdDoT Member

    i've made a php script who change my /etc/init.d/toc file if it startsup giving the good kill pid id's

    thx greets(do you mind that i posted a expension on you munit and monit tut)
     
  4. falko

    falko Super Moderator Howtoforge Staff

    No, not at all. :)
     

Share This Page