blob: e2aa33676eda52bd7379b9e4e60b54471f041ce4 (
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
#!/bin/sh
# Created by: Sean McAfee <smcafee@collaborativefusion.com>
# $FreeBSD$
# PROVIDE: smokeping
# REQUIRE: LOGIN
# KEYWORD: shutdown
# Define these smokeping_* variables in one of these files:
# /etc/rc.conf
# /etc/rc.conf.local
# /etc/rc.conf.d/smokeping
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
#
# smokeping_flags="<set as needed>"
. /etc/rc.subr
name=smokeping
rcvar=smokeping_enable
extra_commands="status configtest reload"
start_cmd="smokeping_start"
status_cmd="smokeping_status"
configtest_cmd="smokeping_configtest"
reload_cmd="smokeping_reload"
stop_cmd="smokeping_stop"
: ${smokeping_enable:=NO}
# pidfile is hardcoded in Smokeping.pm, not configurable
smokeping_pidfile="%%PREFIX%%/var/smokeping/pid"
: ${smokeping_logfile=/var/log/smokeping.log}
: ${smokeping_user="%%USERS%%"}
: ${smokeping_group="%%GROUPS%%"}
command="%%PREFIX%%/bin/smokeping"
command_args="--logfile=${smokeping_logfile}"
pidfile="${smokeping_pidfile}"
command_interpreter="%%PREFIX%%/bin/perl"
smokeping_check_pidfile()
{
rc_pid=$(check_pidfile $pidfile $command)
if [ -z "${rc_pid}" ]; then
rc_pid=$(check_pidfile $pidfile $command $command_interpreter)
fi
}
smokeping_start()
{
smokeping_check_pidfile
if [ -n "$rc_pid" ]; then
echo 1>&2 "${name} already running? (pid=$rc_pid)."
return 1
fi
if [ ! -e ${smokeping_logfile} ];
then
install -o ${smokeping_user} -g ${smokeping_group} -m 644 /dev/null ${smokeping_logfile} ||\
echo "ERROR: Could not initialize logfile at ${smokeping_logfile}.";
fi
echo "Starting ${name}."
su -m ${smokeping_user} -c "sh -c '${command} ${smokeping_flags} ${command_args}'"
}
smokeping_status()
{
smokeping_check_pidfile
if [ -z "$rc_pid" ]; then
echo "${name} is not running."
return 1
else
echo "${name} is running as pid $rc_pid"
fi
}
smokeping_configtest()
{
${command} --check
}
smokeping_reload()
{
smokeping_check_pidfile
if [ -z "$rc_pid" ]; then
_run_rc_notrunning
return 1
else
${command} --reload
fi
}
smokeping_stop()
{
smokeping_check_pidfile
if [ -z "$rc_pid" ]; then
_run_rc_notrunning
return 1
else
echo "Stopping ${name}."
kill -TERM $rc_pid
wait_for_pids $rc_pid
fi
}
load_rc_config $name
run_rc_command "$1"
|