#!/bin/sh
# Rotate xtide's xttpd server file if logrotate is not used

set -e

# Only rotate if package is installed
test -f /usr/sbin/xttpd || exit 0

# Only rotate if daemon is actually configured to run.
grep '^PORT' /etc/init.d/xttpd >/dev/null ||   exit 0

# Only rotate if logrotate is not installed (Slink and perhaps potato)
test ! -f /usr/sbin/logrotate || exit 0

if [ -f /var/log/xttpd ]; then
    savelog -g adm -m 644 -u root -c 4 /var/log/xttpd > /dev/null
fi

/etc/init.d/xttpd restart > /dev/null
