summaryrefslogtreecommitdiff
path: root/net/rsync/files/rsyncd.in
blob: d4ea0fe5b42061b01d07cdd2e75e038c2762309d (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
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: %%NAME%%
# REQUIRE: LOGIN
# BEFORE:  securelevel
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable `%%NAME%%':
#
# %%NAME%%_enable="YES"
# %%NAME%%_flags="<set as needed>"
#
# See rsync(1) for %%NAME%%_flags
#

. /etc/rc.subr

name="%%NAME%%"
rcvar=%%NAME%%_enable

command="%%PREFIX%%/bin/rsync"
start_precmd="%%NAME%%_precmd"
pidfile="/var/run/$name.pid"

# read configuration and set defaults
load_rc_config "$name"
: ${%%NAME%%_enable="NO"}
: ${%%NAME%%_configfile:=%%ETCDIR%%/$name.conf}

required_files="${%%NAME%%_configfile}"

command_args="--daemon --config ${%%NAME%%_configfile}"

%%NAME%%_precmd()
{
	if [ -f "%%PREFIX%%/etc/$name.conf" ] && [ ! -L "%%PREFIX%%/etc/$name.conf" ]; then
		echo "Found %%PREFIX%%/etc/$name.conf in old location. Migrating to %%ETCDIR%%/$name.conf."
		mv %%PREFIX%%/etc/$name.conf %%ETCDIR%%/$name.conf
		ln -s %%ETCDIR%%/$name.conf %%PREFIX%%/etc/$name.conf
	fi
}

run_rc_command "$1"