#!/bin/sh

source /etc/utils/shell-utils.sh

function is_process_running() {
    # $1 - process name
    [ "" == "`/usr/bin/pgrep -x $1`" ]
}

splash_pid=$(pidof splash)
if [ "$splash_pid" != "" ] ; then
    #Do not restart/kill splash process to get smooth switch_root transition for RDK
    /etc/init.d/splashfb switch_root_restart
    exit 0
fi

# terminate the initramfs splash process and wait while it's gone
echo "killall splash"
killall splash
until is_process_running "splash"; do
    echo "splash is still running";
    sleep 0.1;
done

log "/dev/fb0 found! Starting splash utility..."
source /etc/init.d/splashfb start
