summaryrefslogtreecommitdiff
path: root/games-action/teeworlds/files/teeworlds-init.d
blob: eb24a7441e2d82d8945aad7e2b4ae61b49e82f13 (plain)
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
#!/sbin/openrc-run
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

PIDFILE=/var/run/teeworlds.pid
GAME_DIRECTORY=/usr/bin
CONFIG=/etc/teeworlds/teeworlds_srv.cfg

depend() {
	use dns logger net
}

checkconfig() {
        if [ ! -e ${CONFIG} ] ; then
                eerror "You need an ${CONFIG} config file to run TeeWorlds"
                return 1
        fi
}

start() {
	ebegin "Starting TeeWorlds"
	start-stop-daemon --start --background --pidfile "${PIDFILE}" \
		--make-pidfile -d ${GAME_DIRECTORY} --user games \
		--exec ${GAME_DIRECTORY}/teeworlds_srv -- -f ${CONFIG}
	eend $?
}

reload() {
	ebegin "Reloading TeeWorlds configs and restarting processes"
	start-stop-daemon --stop --oknodo --user games \
    		--pidfile "${PIDFILE}" --signal HUP \
		--exec ${GAME_DIRECTORY}/teeworlds_srv -- -f ${CONFIG}
	eend $?
}

stop() {
	ebegin "Stopping TeeWorlds"
	start-stop-daemon --stop --quiet --pidfile "${PIDFILE}"
	eend $?
}