#! /bin/sh
# postinst script for daemontools

set -e

case "$1" in
    configure)
	
	if [ -e /etc/init.d/daemontools ]
	then
		/etc/init.d/daemontools stop || :
		rm -f /etc/init.d/daemontools
		update-rc.d -f daemontools remove || :
	fi

    if grep svscanboot /etc/inittab >/dev/null
    then
        echo 'inittab contains an svscanboot line. I assume that svscan is already running.'
    else
        echo 'Adding svscanboot to inittab...'
        rm -f /etc/inittab'{new}'
        cat /etc/inittab /usr/share/daemontools/package/boot.inittab > /etc/inittab'{new}'
        mv -f /etc/inittab'{new}' /etc/inittab
        kill -HUP 1
        echo 'init should start svscan now.'
    fi
    
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 0
    ;;
esac

exit 0
