#! /bin/sh
#
### BEGIN INIT INFO
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Provides:          unattended-upgrade-shutdown-check
# Default-Start:     
# Default-Stop:      0 6
# Short-Description: Check if unattended upgrades are being applied
# Description:       Check if unattended upgrades are being applied
#                    and wait for them to finish
### END INIT INFO


PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=unattended-upgrades
DESC=unattended-upgrades
SHUTDOWN_HELPER=/usr/share/unattended-upgrades/unattended-upgrade-shutdown

set -e

case "$1" in
  start)
        # nothing, just to keep update-rc.d happy (see debian #630732)
        ;;
  stop)
        echo "Checking for running $DESC: "
        if [ -e $SHUTDOWN_HELPER ]; then
	    python $SHUTDOWN_HELPER
        fi
        ;;
  restart|force-reload)
	# nothing
	;;
  status)
	exit 0
	;;
  *)
    N=/etc/init.d/$NAME
    echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
    exit 1
    ;;
esac

exit 0
