#!/bin/sh -efu
. install2-init-functions

# /proc/acpi indicates present ACPI support (in installer too)
[ -d /proc/acpi/ ] || {
	[ -x $destdir/etc/init.d/apmd ] && run_chroot chkconfig apmd on
	exit 0
}

# provide kernel interface for ACPI power button
grep -q ^button$ $destdir/etc/modules || echo button >> $destdir/etc/modules

# which one starts: acpid by default
ACPID=on

# is powersaved starting?  if yes, it will (re)start acpid
[ -x $destdir/etc/init.d/powersaved ] \
&& run_chroot chkconfig --list powersaved \
| grep -q '[345]:on' \
&& ACPID=off

[ -x $destdir/etc/init.d/acpid ] && run_chroot chkconfig acpid "$ACPID" ||:
