#!/bin/bash

. ${TOOLKIT}-functions.sh

[ -x /usr/sbin/kubackup-update-rsync -a -e /etc/kubackup-run.conf ] && {
	kubackup-update-rsync
}

file=/etc/kusa/modules/local/rsyncd.secrets
orig=/etc/rsyncd.secrets
instfile="/etc/kusa/modules/local/install"

[ -f $file ] || {
	installfile rsyncd.secrets $file root:root 660

	if [ -f $orig ]
	then
		putwarning "/etc/rsyncd.secrets" \
			"This file was moved to $file" \
			"and is now under kusa control"
		cat $orig >>$file
		mv $orig $file.orig
	else
		putwarning "/etc/rsyncd.secrets" \
			"A new, empty file $file was created" 
	fi
	grep -q "rsyncd.secrets" $instfile || {
		echo		>>$instfile
		echo "# rsync"	>>$instfile
		echo "rsyncd.secrets	/etc/ root:root 440" >>$instfile
	}
}

$SOMETHING_CHANGED && {
	which xinetd >/dev/null && {
		restart_service xinetd xinetd || exit 1
	}
}

exit 0
