Menu

[r2016]: / trunk / etc / rc.d / unison  Maximize  Restore  History

Download this file

63 lines (49 with data), 1.5 kB

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

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

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

name="unison"
rcvar=`set_rcvar`

# Custom commands
extra_commands="status"
start_cmd="start_cmd"
stop_cmd=":"
status_cmd="status_cmd"

# Defaults
unison_enable="${unison_enable:=NO}"
unison_config=${unison_config:-"/etc/login.conf"}

start_cmd()
{
	local _makedir _workdir

	echo "Configuring ${name}."

	# Ensure unison workdir exists.
	if [ 0 -eq `grep -c 'UNISON=.*' ${unison_config}` ]; then
		err 1 "Can't find UNISON in ${unison_config}"
	fi

	_workdir=`/usr/local/bin/xml sel -t -m "//unison" \
		-v "concat('/mnt/',share,'/',workdir)" \
		${configxml_file} | /usr/local/bin/xml unesc`

	# Create 'workdir' if necessary (Check if '//unison/makedir' is set). Use '//unison/workdir' to
	# create directory name /mnt/xxx.
	if [ 0 -ne `configxml_get_count "//unison/makedir"` ]; then
		if [ -n ${_workdir} -a ! -e ${_workdir} ]; then
			/bin/mkdir ${_workdir}
			/bin/chmod 0775 ${_workdir}
		fi
	fi

	# Add workdir to login.conf UNISON environment variable.
	_workdir=`echo ${_workdir} | /usr/bin/sed 's/\//\\\\\//g'`
	/usr/bin/sed "s/UNISON=[a-zA-Z0-9/.=+-]*/UNISON=${_workdir}/" ${unison_config} > ${unison_config}.tmp
	mv -f ${unison_config}.tmp ${unison_config}
}

status_cmd()
{
	# Nothing to do here, but keep empty implementation.
}

load_rc_config ${name}
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.