#!/bin/sh -e

if ! [ "$RPM_INSTALL_ARG1" -ge 1 ] 2>/dev/null; then
	echo "post_service: invalid or undefined variable: RPM_INSTALL_ARG1" >&2
	exit 1
fi

if [ $# -ne 1 ]; then
	echo "Usage: post_service <service>" >&2
	exit 1
fi

if [ "$RPM_INSTALL_ARG1" -eq 1 ]; then
	/sbin/chkconfig --add "$1"
else
	/sbin/chkconfig "$1" resetpriorities ||:
	/sbin/service "$1" condrestart ||:
fi
