#! /bin/bash

set -e

case "$1" in
configure)
	PLYMOUTHCONF="/etc/plymouth/plymouthd.conf"
	if [ -e $PLYMOUTHCONF ] ; then
		if ( ! grep '^\[Daemon\]' $PLYMOUTHCONF > /dev/null 2>&1 ) ; then
			echo '[Daemon]' >> $PLYMOUTHCONF
		fi
		if ( grep '^Theme=' $PLYMOUTHCONF > /dev/null 2>&1 ) ; then
			sed -i 's/^Theme=.*$/Theme=blorand/g'	$PLYMOUTHCONF
		else
			echo 'Theme=blorand' >> $PLYMOUTHCONF
		fi
	else
		echo -e "[Daemon]\nTheme=blorand" > $PLYMOUTHCONF
	fi
	update-rc.d plymouth defaults
	update-rc.d plymouth-log defaults

	if [ -e /etc/default/grub ] ; then
		if ( ! awk -F'=' '$1 ~ /^GRUB_CMDLINE_LINUX_DEFAULT/ { print $2 }' /etc/default/grub | grep splash > /dev/null 2>&1) ; then
			sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT="\([^"]*\).*$/GRUB_CMDLINE_LINUX_DEFAULT="\1 splash"/g' /etc/default/grub
			[ -x /usr/sbin/update-grub2 ] && /usr/sbin/update-grub2
		fi
	fi
	update-initramfs -u
	;;

	abort-upgrade|abort-remove|abort-deconfigure)
	
	;;

	*)
	echo "postinst called with unknown argument \`$1'" >&2
	exit 0
	;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.



exit 0
