]> git.pld-linux.org Git - packages/crossfire.git/blobdiff - crossfire.init
- release 7
[packages/crossfire.git] / crossfire.init
index aa3adfa7461ad426094db8b4fbb2c59a164c0c52..1a2958f4f6d2cef816d8fbb5186e1878cd7145c6 100644 (file)
@@ -1,10 +1,10 @@
 #!/bin/sh
 #
 # chkconfig:   345 98 03
-# description: Starts and stops the Crossfire server 
+# description: Starts and stops the Crossfire server
 #
 
-export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin
 
 # Source function library.
 . /etc/rc.d/init.d/functions
@@ -16,57 +16,71 @@ export PATH=/bin:/sbin:/usr/bin:/usr/sbin
 . /etc/sysconfig/crossfire
 
 # Check that networking is up.
-if is_no "${NETWORKING}"; then
-        msg_Network_Down crossfire
-        exit 1
+if is_yes "${NETWORKING}"; then
+       if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+               msg_network_down crossfire
+               exit 1
+       fi
+else
+       exit 0
 fi
 
 TMPDIR="/tmp"; export TMPDIR
-cd /
 
+RETVAL=0
 case "$1" in
-    start)
-        if [ ! -f /var/lock/subsys/crossfire ]; then
+  start)
+       if [ ! -f /var/lock/subsys/crossfire ]; then
+               cd /
+               FLAGS="-log /var/log/crossfire"
+               if [ -n "$PORT" ]; then
+                       FLAGS="$FLAGS -csport $PORT"
+               fi
+               if is_yes "$DEBUG" ; then
+                       FLAGS="$FLAGS -d"
+               else
+                       FLAGS="$FLAGS +d"
+               fi
                msg_starting crossfire
-               daemon "su games -s /bin/sh -c '/usr/X11R6/bin/crossloop >/dev/null 2>&1 &'"
+               daemon su games -s /bin/sh -c "\"exec crossfire -detach $FLAGS >>/var/log/crossfire 2>&1\""
                RETVAL=$?
                [ $RETVAL -eq 0 ] && touch /var/lock/subsys/crossfire
-        else
-                msg_Already_Running crossfire
-                exit 1
-        fi
+       else
+               msg_already_running crossfire
+       fi
        ;;
-    stop)
-        if [ -f /var/lock/subsys/crossfire ]; then
-                msg_stopping crossloop
-               killproc crossloop
-                msg_stopping crossfire
+  stop)
+       if [ -f /var/lock/subsys/crossfire ]; then
+               msg_stopping crossfire
                killproc crossfire
                rm -f /var/lock/subsys/crossfire >/dev/null 2>&1
-        else
-                msg_Not_Running crossfire
-                exit 1
-        fi
+       else
+               msg_not_running crossfire
+       fi
        ;;
-   status)
-       status crossfire
-       status crossloop
-       exit $?
+  status)
+       status crossfire
+       RETVAL=$?
+       su games -c "crossfire +d -s"
        ;;
   restart)
        $0 stop
        $0 start
+       RETVAL=$?
        ;;
-  reload)
+  reload|force-reload)
        if [ -f /var/lock/subsys/crossfire ]; then
-               msg_reloading crossfire
-               killproc crossfire
+               msg_reloading crossfire
+               killproc crossfire
+               RETVAL=$?
        else
-               msg_Not_Running crossfire
-               exit 1
-        fi
+               msg_not_running crossfire >&2
+               exit 7
+       fi
        ;;
   *)
-       msg_Usage "$0 {start|stop|restart|reload|status}"
-       exit 1
+       msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
+       exit 3
 esac
+
+exit $RETVAL
This page took 0.102813 seconds and 4 git commands to generate.