blob: 85a100d1e94a785e741d1bb73e3bb7e7a06efd9c (
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
|
#!/bin/sh
#
# PROVIDE: csync2
# REQUIRE: LOGIN
# KEYWORD: shutdown
# Add the following line to /etc/rc.conf to enable csync2:
# csync2_enable="YES"
#
# Optional configuration of csync2:
# csync2_cfg (str): Path to csync2 main configuration.
# Default is %%PREFIX%%/etc/csync2.cfg.
# csync2_flags (str): Extra flags passed to csync2 program.
# Default to "-ii -v".
# csync2_logfile (str): Path to logfile where daemon' output logged to.
# Default to "/var/log/csync2.log".
. /etc/rc.subr
name="csync2"
rcvar=csync2_enable
pidfile=/var/run/${name}.pid
command=%%PREFIX%%/sbin/csync2
start_cmd="csync2_start"
load_rc_config $name
: ${csync2_enable="NO"}
: ${csync2_flags="-ii -v"}
: ${csync2_cfg="%%PREFIX%%/etc/csync2.cfg"}
: ${csync2_logfile="/var/log/csync2.log"}
required_files="${csync2_cfg}"
csync2_check_keys()
{
[ -f "${csync2_cfg}" ] || return 1
_key=`grep '^[[:blank:]]*key[[:space:]]\+.\+;\?$' ${csync2_cfg} |\
awk '{print($2)}'`
[ -n "${_key}" ] || return 1
for _file in ${_key}; do
_file=${_file%;}
[ ! -f "${_file}" ] && \
warn "PSK specified but not found, use csync2 -k ${_file} to create it."
done
return 0
}
csync2_start() {
if [ -z "$rc_fast" -a -n "$rc_pid" ]; then
echo 1>&2 "${name} already running? (pid=$rc_pid)."
return 1
fi
csync2_check_keys
check_startmsgs && echo "Starting ${name}."
/usr/sbin/daemon -p ${pidfile} \
${command} ${csync2_flags} >> ${csync2_logfile} 2>&1
}
run_rc_command "$1"
|