#!/bin/sh

if [ -f /etc/default/grub ]; then
	. /etc/default/grub
fi

if [ -z "$GRUB_CMDLINE_LINUX_DEFAULT" ]; then
	set -- $(cat /proc/cmdline)
	bootopts=
	for opt; do
		case "$opt" in
		initrd=*|BOOT_IMAGE=*|root=*|rootflags=*) ;;
		*) bootopts="$bootopts $opt";;
		esac
	done
	mkdir -p /etc/default
	echo "GRUB_CMDLINE_LINUX_DEFAULT=\"$bootopts\"" >> /etc/default/grub
fi

if [ -e /etc/grub-autoinstall ]; then
	. /etc/grub-autoinstall
fi
