#!/usr/bin/env /lib/runit/invoke-run
#Copyright: 2026 Aitor <aitor@genuen.org>
#License: CC0-1.0
#Comment: ported for runit-services testing (rsync)

exec 2>&1
RSYNC_ENABLE=false
RSYNC_OPTS=''
RSYNC_CONFIG_FILE=/etc/rsyncd.conf
[ -s /etc/default/rsync ] && . /etc/default/rsync
case "x${RSYNC_ENABLE}" in
  xtrue) ;;
  xinetd) exit 161 ;;
  *) exit 161 ;;
esac
[ -x /usr/bin/rsync ] || exit 162
[ -s "$RSYNC_CONFIG_FILE" ] || exit 161
nice=
case "x${RSYNC_NICE:-}" in
  x[0-9]|x1[0-9]) nice="nice -n ${RSYNC_NICE}" ;;
esac
ionice=
case "x${RSYNC_IONICE:-}" in
  x-c[123]*) ionice="ionice ${RSYNC_IONICE}" ;;
esac
exec $nice $ionice /usr/bin/rsync --daemon --no-detach --config "$RSYNC_CONFIG_FILE" $RSYNC_OPTS
