Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate

Advertising

Paste Description for Something

BF2Server init script

Something
Saturday, February 17th, 2007 at 7:21:36pm UTC 

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          battlefield
  4. # Required-Start:    networking
  5. # Required-Stop:
  6. # Default-Start:     2 3 4 5
  7. # Default-Stop:      S 0 1 6
  8. # Short-Description: Battlefield Server Daemon
  9. # Description:       Starts/Stops/Restarts the Battlefield2 Server Daemon
  10. ### END INIT INFO
  11.  
  12. set -e
  13.  
  14. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/bf2server/mono-1.1.12.1/
  15. DESC="Battlefield Server"
  16. NAME=bf2server
  17. USER=bf2server
  18. DIR=/home/bf2server/bf2
  19. DAEMON=mono
  20. PIDFILE=/var/run/$NAME.pid
  21. SCRIPTNAME=/etc/init.d/$NAME
  22. ARGUMENTS="$DIR/bf2ccd.exe"
  23.  
  24.  
  25. # Gracefully exit if the package has been removed.
  26. # moot
  27. #test -x "$DAEMON" # || exit 0
  28.  
  29. d_start() {
  30.         start-stop-daemon --start --quiet \
  31.                 --chuid $USER \
  32.                 --chdir $DIR \
  33.                 --exec "$DAEMON $ARGUMENTS" \
  34.                 > /dev/null \
  35.                 || echo -n " already running"
  36.         echo $! > $PIDFILE.my
  37. }
  38.  
  39. d_stop() {
  40.         start-stop-daemon --stop --quiet \
  41.                 --chuid $USER \
  42.                 --chdir $DIR \
  43.                 --exec "kill -SIGTERM $(cat $PIDFILE.my)" \
  44.                 || echo -n " not running"
  45.         kill -SIGTERM $(cat $PIDFILE.my)
  46. }
  47.  
  48. case "$1" in
  49.   start)
  50.         echo -n "Starting $DESC: $NAME"
  51.         d_start
  52.         echo "."
  53.         ;;
  54.   stop)
  55.         echo -n "Stopping $DESC: $NAME"
  56.         d_stop
  57.         echo "."
  58.         ;;
  59.   restart|force-reload)
  60.         echo -n "Restarting $DESC: $NAME"
  61.         d_stop
  62.         sleep 15
  63.         d_start
  64.         echo "."
  65.         ;;
  66.   *)
  67.         echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
  68.         exit 3
  69.         ;;
  70. esac
  71.  
  72. exit 0

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will not expire by default. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right
worth-right