#!/bin/bash

#SAFERM#

set -e


case "$1" in
    configure)
        sed -i 's/RSYNC_ENABLE=false/RSYNC_ENABLE=true/' /etc/default/rsync

        if [[ $(hostname) =~ "test" ]]; then
            sed -i 's/\(hosts allow\) =.*/\1 = '$(hostname -f)'/' /etc/rsyncd.conf
        fi

        /etc/init.d/rsync restart
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac


exit 0
