File: init

package info (click to toggle)
tetrinetx 1.13.16-14
  • links: PTS
  • area: main
  • in suites: bullseye, buster, jessie, jessie-kfreebsd, sid, stretch, wheezy
  • size: 512 kB
  • ctags: 500
  • sloc: ansic: 6,955; sh: 110; makefile: 58
file content (86 lines) | stat: -rw-r--r-- 2,116 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/sh
### BEGIN INIT INFO
# Provides:          tetrinetx
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Init script for tetrinetx
### END INIT INFO

SCRIPT=$0
ACTION=$1

NAME="tetrinetx"
DESC="Tetrinet Server"
RUNDIR="/var/run/tetrinetx"
PIDF="${RUNDIR}/game.pid"
LOGF="/var/log/tetrinetx/game.log"
CONF="/etc/tetrinetx/game.conf"
BINX="/usr/games/tetrinetx"

test -x $BINX || exit 0

if [ "`echo $ACTION | cut -d- -f2`" != "now" ]; then
  test -f /etc/default/tetrinetx || exit 0
  # handle guys wo do not want to run tetrinetx through init.d
  . /etc/default/tetrinetx
  RUNIT=`echo $RUN_AT_STARTUP | tr '[a-z]' '[A-Z]'`
  if [ "$RUNIT" = "NO" ]; then
    exit 0
  fi
fi

if [ ! -d ${RUNDIR} ] ; then
	mkdir -p ${RUNDIR} || true
	if [ -d ${RUNDIR} ] ; then
		chown -R games:games ${RUNDIR}
	fi
fi

case "$ACTION" in
	start|start-now)
	  echo -n "Starting ${DESC}: "
	  start-stop-daemon --start -q --pidfile $PIDF \
		-c games:games --exec $BINX 2>&1 >> $LOGF
          if [ "$?" -eq "1" ]; then
            echo "${NAME} already running, not started."
	    exit 0
          else
	    echo "${NAME}."
	  fi
	  ;;
	stop|stop-now)
	  echo -n "Stopping ${DESC}: "
	  start-stop-daemon --stop -q  --pidfile $PIDF \
		--retry 10 --exec $BINX 2>&1 >> $LOGF
          if [ "$?" -eq "1" ]; then
            echo "${NAME} not running, not stopped."
	    exit 0
          else
	    echo "${NAME}."
	  fi
	  ;;
	restart|force-reload)
	  echo -n "Restarting ${DESC}: "
	  start-stop-daemon --stop -q  --pidfile $PIDF \
		--retry 10 --exec $BINX 2>&1 >> $LOGF
          if [ "$?" -eq "1" ]; then
            echo "${NAME} not running, not stopped."
          fi
	  start-stop-daemon --start -q --pidfile $PIDF \
		-c games:games --exec $BINX 2>&1 >> $LOGF
          if [ "$?" -eq "1" ]; then
            echo "${NAME} already running, not started."
	    exit 0
          else
	    echo "${NAME}."
	  fi
	  ;;
	*)
	  echo "Usage: $SCRIPT {start[-now]|stop[-now]|restart|force-reload}"
	  exit 1
	  ;;
esac

exit 0