#!/bin/sh

recipe="$1"
free_size="$2"
min_size="$3"

. /usr/share/debconf/confmodule

# Report too small disks.
# FIXME Call this from the "disk too small hook" when #653305 is
# fixed.  Until then, it is called from a partman/commit.d hook.

if [ ! -f /tmp/ignore-too-small ] && \
   grep -q 'too small for expert recipe' /var/log/syslog ; then
    logger -t debian-edu-install "Disk to small (recipe=$recipe free_size=$free_size min_size=$min_size), asking if installation should be aborted"

    # Remove backup choice from dialog
    db_capb

    db_fset debian-edu-install/disk-too-small seen false
    db_input critical debian-edu-install/disk-too-small || [ $? -eq 30 ]
    db_go
    db_get "debian-edu-install/disk-too-small" || true
    if test "$RET" = true ; then
        reboot
    fi
    touch /tmp/ignore-too-small

    # restore backup choice for the rest of partman
    db_capb backup
fi
