aboutsummaryrefslogtreecommitdiffstats
path: root/net-mgmt/netdisco/files/netdisco.in
blob: 8dccea10f7a9b152ddc5ad44deacfa6945306fbc (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
#!/bin/sh

# $FreeBSD$
# 
# PROVIDE: netdisco
# REQUIRE: DAEMON LOGIN
# AFTER: postgresql
# KEYWORD: shutdown

. /etc/rc.subr

name="netdisco"
rcvar="netdisco_enable"

load_rc_config $name

: ${netdisco_enable="NO"}
: ${netdisco_user="%%NETDISCO_USER%%"}
: ${netdisco_group="%%NETDISCO_GROUP%%"}

start_precmd=${name}_prestart
stop_cmd=${name}_stop
restart_cmd=${name}_restart
status_cmd=${name}_status

command="%%PREFIX%%/bin/netdisco"
command_interpreter="%%PREFIX%%/bin/perl"
netdisco_config="%%ETCDIR%%/netdisco.conf"
pidfile=$(grep ^daemon_pid $netdisco_config | cut -d= -f2 | tail -1)
flags="-p start"

required_files="$netdisco_config"

netdisco_prestart() {
    touch $pidfile && chown $netdisco_user $pidfile
    test -d %%NETDISCO_DBDIR%% || install -d -m 0700 -o $netdisco_user -g $netdisco_group %%NETDISCO_DBDIR%%
}

netdisco_stop() {
    su -m "$netdisco_user" -c "$command -p stop"
}

netdisco_restart() {
    su -m "$netdisco_user" -c "$command -p restart"
}

netdisco_status() {
    su -m "$netdisco_user" -c "$command -p status"
}

run_rc_command "$1"