#! /bin/sh
set -e

# Disable netinst CD image in sources.list if any other sources are present
if [ -e /cdrom/.disk/base_installable ] && \
   [ -e /cdrom/.disk/cd_type ] && \
   [ "$(cat /cdrom/.disk/cd_type)" = not_complete ] && \
   grep -q "^deb \(ht\|f\)tp" /target/etc/apt/sources.list; then
	logger -t finish-install "Disabling netinst CD in sources.list"
	sed -i "/^deb cdrom:/s/^/#/" /target/etc/apt/sources.list
	log-output -t finish-install chroot /target apt-get update
fi
