#!/bin/sh

set -e

# Remove old init.d links
if dpkg --compare-versions "$2" lt-nl "1.0.10-3"; then
	rm -f /etc/rc1.d/K??acpid
fi

if dpkg --compare-versions "$2" lt-nl "1.0.6-16"; then
	rm -f /etc/rc[06].d/K??acpid
fi

if dpkg --compare-versions "$2" lt "1.0.6-6"; then
	rm -f /etc/rc1.d/K20acpid /etc/rc[2-5].d/S20acpid
fi

# Fix very old permission problem
if dpkg --compare-versions "$2" lt-nl "1.0.10-5"; then
	[ -f /var/log/acpid ] && chmod 640 /var/log/acpid*
fi

# Automatically added by dh_installinit
if [ -x "/etc/init.d/acpid" ] || [ -e "/etc/init/acpid.conf" ]; then
	if [ ! -e "/etc/init/acpid.conf" ]; then
		update-rc.d acpid defaults >/dev/null
	fi
	invoke-rc.d acpid start || exit $?
fi
# End automatically added section
# Automatically added by dh_installinit
update-rc.d -f acpid remove >/dev/null || exit $?
# End automatically added section


