# File Debian-custom/001-ltsp-settings
# Deal with case that ltsp-client-builder doesn't look up another
# mirror if cdrom is still mounted.
# Lookup if ISO type is NETINST, not if usbstick (debian-cd BD disk type) ISO image is used.
case $MODE in
  configure)
    if [ file:///media/cdrom = "$option_mirror_value" ] && ! grep -q BD /etc/apt/sources.list ; then
        NEWMIRROR=$(awk '/^deb (http|ftp):\/\/.* main/ { if (!first) { print $2; first=1 } }' < /etc/apt/sources.list)
        echo "info: Changing LTSP mirror from '$option_mirror_value' to '$NEWMIRROR'"
        option_mirror_value=$NEWMIRROR
    fi
  ;;
  install)
    mkdir -p $ROOT/etc/apt/apt.conf.d
    (
        echo 'APT::Get::AllowUnauthenticated "true";'
        echo 'APT::Authentication::TrustCDROM "true";'
        echo 'APT::Cmdline::ignore-trust-violations "true";'
    ) >> $ROOT/etc/apt/apt.conf.d/90ltsp-build-client
  ;;
    after-install)
        mkdir -p $ROOT/etc/ltsp/update-kernels.conf.d
        echo 'IPAPPEND="2"' > $ROOT/etc/ltsp/update-kernels.conf.d/pxe
        ;;
esac
