#!/bin/sh
export PATH=/opt/lnxall_app/bin:/opt/lnxall_app/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
PLATSPEC=/opt/lnxall_app/platspec

# /etc/splash.d -> /opt/lnxall_app/etc/splash.d
rm -r -f /etc/splash.d
ln -s -n -f /opt/lnxall_app/etc/splash.d /etc/splash.d
[ -L /etc/splash.d ] && [ -e /etc/splash.d ] || {
    echo "Error, /etc/splash.d symlink is invalid"
    exit 2
}

# install the systemd unit (concurrent-with-lightdm + VT bounce version)
cp -f $PLATSPEC/boot-splash.service /lib/systemd/system
[ $? -ne 0 ] && exit 3

# NOTE: boot.img logo repacking (rk3568_change_bootlogo) is intentionally NOT
# performed by this package. Background/logo are rendered by boot-splash in
# userspace; the boot partition stays untouched.

# remove legacy logo-session autostart (pre boot-splash boot method)
if [ -f /etc/lightdm/lightdm.conf ] ; then
	sed -i '/^[[:space:]]*autologin-session[[:space:]]*=[[:space:]]*logo-session[[:space:]]*$/d' \
		/etc/lightdm/lightdm.conf
fi
rm -f /home/linaro/.config/autostart/logo-session.desktop

systemctl daemon-reload
systemctl enable boot-splash.service

exit 0