#!/bin/sh

/lib/debian-installer/exit-command
CMDN=$?

case "$CMDN" in
20) CMD=reboot;;
21) CMD=halt;;
22) CMD=poweroff;;
*) echo "got weird return code $CMDN";;
esac

# stop the udev daemon before /dev/ is unmounted
if PID=$(pidof udevd); then
	kill -15 $PID
fi

/bin/umount -a -r
/sbin/swapoff -a

$CMD

# if possible, give init a chance to kill main-menu
if type sleep >/dev/null 2>&1; then
	sleep 10 || true
fi
