summaryrefslogtreecommitdiff
blob: 569947c660bfe52479541a376a1603ee87f3985f (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
41
42
43
#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

today=$(date '+%Y-%m-%d')

depend() {
	need net
}
checkconfig() {
	if [ ! -e /etc/sancp/sancp.conf ] ; then
		eerror "You need an /etc/sancp/sancp.conf to run sancp"
		return 1
	fi
}

start() {
	checkconfig || return 1
	
	# Today's log directory
	if [ ! -d $LOGDIR/$today ]; then
		/bin/mkdir $LOGDIR/$today
		/bin/rm -f $LOGDIR/today
	fi
	
	# today/ directory :)
	if [ ! -d $LOGDIR/today ]; then
		/bin/ln -s $LOGDIR/$today $LOGDIR/today
	fi
	
	ebegin "Starting sancp"
	start-stop-daemon --start --quiet -m --pidfile /var/run/sancp.pid \
		--exec /usr/bin/sancp \
		-- ${SANCP_OPTS} > /var/log/sancp.log 2>&1 &
	eend $?
}

stop() {
	ebegin "Stopping sancp"
	start-stop-daemon --stop --quiet --pidfile /var/run/sancp.pid
	eend $?
}