#!/bin/sh

set -x

. /usr/share/volatile/chroot-common.sh

#python /usr/share/volatile/aptInstall -o install_packageslist_chroot -f /usr/share/volatile/data/packageslist.txt
# above packageslist only installs: hunspell-en-ca, libreoffice-help-en-gb, libreoffice-l10n-en-gb, libreoffice-l10n-en-za, mythes-en-au

## chroot_local-hooks/10remove-dmraid-support
# Remove dmraid support in ubiquity to fix "No root file system is defined." error (LP: #1042670)
sed -i 's/touch \/var\/lib\/disk-detect\/activate_dmraid//' /usr/share/ubiquity/activate-dmraid

## chroot_local-hooks/99avoid-eject-in-chroot
if [ -e /etc/init.d/casper ]
    then
    sed -i 's/eject -p -m \/cdrom >\/dev\/null 2>\&1//g' /etc/init.d/casper
        echo "Avoid issueing eject in /etc/init.d/casper"
fi

# chroot_local-hooks/11remove-ubuntu-upgrade-notice: Turn off automatic notification of new versions of Ubuntu (LP: #988728)
sed -i 's/prompt=.*/prompt=never/' /etc/update-manager/release-upgrades

# Disable whoopsie crashes report by default. (LP: #1028236)
sed -i 's/^report_crashes=.*/report_crashes=false/' /etc/default/whoopsie
# Also disable apport
sed -i 's/enabled=1/enabled=0/' /etc/default/apport

#add nomodeset check hook only in non-uefi mode for /boot/grub/nomodesetsystemlist.txt , nomodesetlist.txt is for installer/recovery.
sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT=\"\$GRUB_CMDLINE_LINUX_DEFAULT \\\$vt_handoff\"/GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT \\$vt_handoff \\$nomodeset"\ncat <<EOF\nif [ ! -d \/boot\/efi ]; then\nif hwmatch \/boot\/grub\/nomodesetsystemlist.txt 3; then\nif [ \\${match} != 0 ]; then\nset nomodeset="nomodeset"\nfi\nfi\nfi\nEOF\n/' /etc/grub.d/10_linux

exit 0
