#!/bin/sh

set -e

if test -f /etc/skel/examples.desktop; then
	rm -R /etc/skel/examples.desktop
fi

if test -f /root/.bash_history; then
	rm -f /root/.bash_history
fi

case "$1" in
    configure|triggered)
	#update-alternatives --install /usr/bin/x-session-manager \
    #lightdm-gtk-greeter-config-derivative \
    #/usr/share/ultimate_edition/lightdm-ultimate.conf 90
    if which "/usr/share/ultimate_edition/lightdm-ultimate.conf" >/dev/null 2>&1
    then
	update-alternatives --install /etc/lightdm/lightdm-gtk-greeter.conf \
    lightdm-gtk-greeter-config-derivative \
    /usr/share/ultimate_edition/lightdm-ultimate.conf 90
    fi
	sed -re \
		"/\[Ultimate-Edition-text\]/ {
			N;
			s/(title=Ultimate Edition ).*\$/\1$(lsb_release -rs)/
		}" /usr/share/plymouth/themes/Ultimate-Edition-text/Ultimate-Edition-text.plymouth \
			> /lib/plymouth/themes/Ultimate-Edition-text/Ultimate-Edition-text.plymouth
	update-alternatives \
		--install /lib/plymouth/themes/text.plymouth text.plymouth \
		/usr/share/plymouth/themes/Ultimate-Edition-text/Ultimate-Edition-text.plymouth 90

	#echo "Installing Group Ultimate"
	#echo >&2 "Adding ultimate user group ..."
	#getent group ultimate > /dev/null || groupadd -r ultimate
	#echo >&2 "Adding ultimate user account ..."
	#getent passwd ultimate > /dev/null || useradd -r -g ultimate -c ultimate -s /sbin/nologin -d / ultimate
	#echo "Done."

	if which update-initramfs >/dev/null 2>&1
	then
	    update-initramfs -u
	fi
	;;

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

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

#manually set layout and panels height
#gdm gconftool-2 --set --type string /desktop/gnome/peripherals/mouse/cursor_theme 'Ultimate Edition Blue Velvet Cursor'

#Clear crash log incase issues have arose prior
if test -f /var/crash/*; then
	rm /var/crash/*
fi
exit 0
# ==============================================================================
# This code was automatically cleaned up using code-cleanup
# title			:code-cleanup
# description		:Bash code cleanup script
# Author		:root
# date			:10/23/2013
# version		:1.7.2-1
# http://ultimateedition.info/
# ==============================================================================
