#!/bin/sh -e

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

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

if [ "$RPM_INSTALL_ARG1" -eq 0 ]; then
        /sbin/chkconfig --del "$1" ||:
        /sbin/service "$1" condstop ||:
fi
