#!/bin/sh

if [ -n "$PLESK_INSTALLER_DEBUG" -o -n "$PLESK_INSTALLER_VERBOSE" ]; then
	set -x;
fi

GUARD=/usr/local/psa/var/statistics_collector.MU.replaced

if [ -f $GUARD ]; then
	if [ -n "$PLESK_INSTALLER_DEBUG" -o -n "$PLESK_INSTALLER_VERBOSE" ]; then
		echo statistics_collector is up to date, skipping;
	fi
	exit 0;
fi

if [ -n "$PLESK_INSTALLER_DEBUG" -o -n "$PLESK_INSTALLER_VERBOSE" ]; then
	echo kill the old statistics_collector, if one is running;
fi
killall statistics_collector
sleep 5

if [ -n "$PLESK_INSTALLER_DEBUG" -o -n "$PLESK_INSTALLER_VERBOSE" ]; then
	echo replace statistics_collector;
fi
mv /usr/local/psa/tmp/statistics_collector /usr/local/psa/admin/sbin/

touch $GUARD

