summaryrefslogtreecommitdiff
path: root/databases/py-carbon/files/carbon-relay.sh
blob: 8b62b468ce946bb17ca8e9f9ed6ccf646db00173 (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
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
#!@RCD_SCRIPTS_SHELL@
#
# $NetBSD: carbon-relay.sh,v 1.1 2015/12/11 21:40:50 riz Exp $
#
# PROVIDE: carbon-relay
# REQUIRE: DAEMON
# KEYWORD: shutdown

if [ -f /etc/rc.subr ]; then
	. /etc/rc.subr
fi

name="carbon_relay"
rcvar=$name
command="@PREFIX@/bin/carbon-relay.py"
config="--config=@PKG_SYSCONFDIR@/carbon.conf"
graphite_user="@GRAPHITE_USER@"
graphite_group="@GRAPHITE_GROUP@"
graphite_dir="@GRAPHITE_DIR@"
extra_commands="status"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
status_cmd="${name}_status"
start_precmd='setproclimits'

setproclimits()
{
	local climit
	climit=$(ulimit -n)
	if [ "$climit" -lt 4096 ]; then
		ulimit -n 4096
	fi
}

carbon_relay_start()
{
	@SU@ -m ${graphite_user} -c "${command} ${config}  start"
}

carbon_relay_stop()
{
	@SU@ -m ${graphite_user} -c "${command} ${config} stop"
}

carbon_relay_status()
{
	@SU@ -m ${graphite_user} -c "${command} ${config} status"
}


if [ -f /etc/rc.subr -a -f /etc/rc.conf ]; then
	load_rc_config $name
	run_rc_command "$1"
else
	if [ -f /etc/rc.conf ]; then
		. /etc/rc.conf
	fi
	case $1 in
	start)
		${start_cmd}
		;;
	stop)
		${stop_cmd}
		;;
	restart)
		${stop_cmd} && ${start_cmd}
		;;
	*)
		@ECHO@ "Usage: $0 {start|stop|restart}" 1>&2
		exit 64
		;;
	esac
fi