summaryrefslogtreecommitdiff
blob: 1261fb5099a3e5176654744cc39a6c0eebd5a040 (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
#!/sbin/runscript
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/games-strategy/netpanzer/files/netpanzer.rc,v 1.3 2007/03/07 17:30:56 wolf31o2 Exp $

depend() {
	need net
}

start() {
	ebegin "Starting netpanzer dedicated server"
	screen -A -m -d -S netpanzer-ded su - GAMES_USER_DED -c "GENTOO_DIR/netpanzer-ded"
	eend $?
}

stop() {
	ebegin "Stopping netpanzer dedicated server"
	local pid=`screen -list | grep netpanzer-ded | awk -F . '{print $1}' | sed -e s/.//`
	if [[ -z "${pid}" ]] ; then
		eend 1 "Lost screen session"
	else
		pid=`pstree -p ${pid} | sed -e 's:^.*netpanzer-ded(\([0-9]*\)).*:\1:'`
		if [[ -z "${pid}" ]] ; then
			eend 1 "Lost netpanzer-ded session"
		else
			kill ${pid}
			eend $? "Could not kill netpanzer-ded"
		fi
	fi
}

status() {
	screen -list | grep netpanzer-ded
}