Menu

[r10367]: / legacy / etc / rc.d / rsyncd  Maximize  Restore  History

Download this file

75 lines (64 with data), 2.2 kB

#!/bin/sh
# Copyright (c) 2007-2009 Volker Theile (votdev@gmx.de)
# All rights reserved.

# PROVIDE: rsyncd
# REQUIRE: DAEMON
# KEYWORD: shutdown
# XQUERY: -i "count(//rsyncd/enable) > 0" -o "0" -b
# RCVAR: rsyncd

. /etc/rc.subr
. /etc/configxml.subr

name="rsyncd"
rcvar=`set_rcvar`

load_rc_config "${name}"

# Custom commands
start_precmd="rsyncd_mkconf"
mkconf_cmd="rsyncd_mkconf"
extra_commands="mkconf"

# Defaults
rsyncd_enable=${rsyncd_enable:-"NO"}
rsyncd_config=${rsyncd_config:-"/var/etc/${name}.conf"}
rsyncd_motd=${rsyncd_motd:-"/var/etc/rsyncd.motd"}
command="/usr/local/bin/rsync"
command_args="--daemon --config=${rsyncd_config}"
pidfile="/var/run/${name}.pid"

rsyncd_mkconf()
{
	local _motd

	# Create rsyncd.conf file
	/usr/local/bin/xml sel -t -m "//rsyncd" \
		-o "syslog facility = local4" -n \
		-o "list = no" -n \
		-v "concat('port = ',port)" -n \
		-o "pid file = ${pidfile}" -n \
		-i "string-length(motd) > 0" -o "motd file = ${rsyncd_motd}" -n -b \
		-i "count(rsyncd_user) > 0" -v "concat('uid = ',rsyncd_user)" -n -b \
		-m "auxparam" \
			-v "." -n -b \
		-m "module" \
			-n \
			-v "concat('[',name,']')" -n \
			-v "concat('comment = ',comment)" -n \
			-v "concat('path = ',path)" -n \
			-i "count(list) > 0" -o "list = true" -n -b \
			-i "string-length(maxconnections) > 0" -v "concat('max connections = ',maxconnections)" -n -b \
			-i "rwmode[. = 'rw']" -o "read only = false" -n -b \
			-i "rwmode[. = 'ro']" -o "read only = true" -n -b \
			-i "rwmode[. = 'wo']" -o "read only = false" -n -o "write only = true" -n -b \
			-i "string-length(hostsallow) > 0" -v "concat('hosts allow = ',hostsallow)" -n -b \
			-i "string-length(hostsdeny) > 0" -v "concat('hosts deny = ',hostsdeny)" -n -b \
			-i "string-length(uid) > 0" -v "concat('uid = ',uid)" -n -b \
			-i "string-length(gid) > 0" -v "concat('gid = ',gid)" -n -b \
			-m "auxparam" \
				-v "." -n -b \
		-b \
		${configxml_file} | /usr/local/bin/xml unesc > ${rsyncd_config}

	# Create MOTD file
	_motd=`configxml_get "//rsyncd/motd"`
	if [ -n "${_motd}" ]; then
		echo "${_motd}" > ${rsyncd_motd}.tmp
		/usr/bin/uudecode -m -p -r ${rsyncd_motd}.tmp > ${rsyncd_motd}
		/bin/rm -f ${rsyncd_motd}.tmp
	fi
}

run_rc_command "$1"
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.