#!/bin/bash

set -eux

install-packages rsync

cat > /etc/cron.d/swift-recon <<EOF
# Cronjob to track async pending on the object server.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=""
*/5 * * * * swift swift-recon-cron /etc/swift/object-server.conf
EOF

if [ -f /etc/default/rsync ] ; then
    # On ubuntu enable rsync by setting RSYNC_ENABLE=true in /etc/default/rsync
    sed -i "s/^RSYNC_ENABLE[[:space:]]*=[[:space:]]*false/RSYNC_ENABLE=true/" /etc/default/rsync
elif [ -f /etc/xinetd.d/rsync ] ; then
    # On fedora enable rsync by setting disable = no in /etc/xinetd.d/rsync
    sed -i "s/disable[[:space:]]*=[[:space:]]*yes/disable = no/" /etc/xinetd.d/rsync
fi

# rsync is configured to log under /mnt/state/var/log/rsyncd.log
register-state-path /var/log/rsyncd.log
