aboutsummaryrefslogtreecommitdiff
path: root/devel/cvsd/files/cvsd.in
blob: 171cd7edd678a9bcde10b3e5fe9684fbc50cd5c7 (plain) (blame)
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
#!/bin/sh
# $FreeBSD$
#
# PROVIDE: cvsd
# REQUIRE: LOGIN syslogd
# KEYWORD: nojail shutdown

. /etc/rc.subr

name="cvsd"
rcvar=${name}_enable

command="%%PREFIX%%/sbin/$name"
command_args='-f $cvsd_config'
required_files=$cvsd_config

start_precmd=${name}_prestart
stop_precmd=cvsd_config
stop_postcmd=${name}_poststop

cvsd_config()
{
	osreldate=`sysctl -n kern.osreldate`
	chrootjail=`sed -n 's/^ *RootJail *\([^ ]*\) *$/\1/p' < $cvsd_config`
	if [ -z "$chrootjail" ]; then
		err 1 "RootJail is not specified in $cvsd_config"
	fi

	pidfile=`sed -n 's/^ *PidFile *\([^ ]*\) *$/\1/p' < $cvsd_config`
	if [ -z "$pidfile" ]; then
		err 1 "PidFile is not specified in $cvsd_config"
	fi
}

cvsd_prestart()
{
	cvsd_config
	if [ $osreldate -gt 500000 ] && [ "$chrootjail" != "none" ]; then
		mount -t devfs devfs $chrootjail/dev
		devfs -m $chrootjail/dev rule apply hide
		devfs -m $chrootjail/dev rule apply path null unhide
		devfs -m $chrootjail/dev rule apply path zero unhide
	fi

}

cvsd_poststop()
{
	if [ $osreldate -gt 500000 ] && [ "$chrootjail" != "none" ]; then
		umount -t devfs $chrootjail/dev
	fi
}

load_rc_config $name

: ${cvsd_enable="NO"}
: ${cvsd_config="%%PREFIX%%/etc/$name/$name.conf"}

run_rc_command "$1"