#!/bin/bash

if [ -f /etc/default/gsplash ]; then
  source /etc/default/gsplash
fi

NAME="done"
DESC="gsplash"
DAEMON="/opt/gira/bin/gsplash"
MSG1="Gira G1 Konfiguration"
MSG2="Der Gira G1 wird gestartet"

if [ -f /opt/userdata/devicestack/appData/powerd/SplashScreenText ]; then
     MSG1=$(grep -m 1 title /opt/userdata/devicestack/appData/powerd/SplashScreenText | cut -d : -f 2 | sed -e 's/"//g' -e 's/,//g' -e 's/^[ \t]*//g')
     MSG2=$(grep -m 1 action /opt/userdata/devicestack/appData/powerd/SplashScreenText | cut -d : -f 2 | sed -e 's/"//g' -e 's/^[ \t]*//g')
fi


start() {
  echo "start"
}

stop() {
  echo "stop"
}

case "$1" in
  start)
    echo -n "Starting with startup check ${DESC}: "
    ${DAEMON} -c "${MSG1}" "${MSG2}" &
    echo "$NAME."
    ;;
  stop)
    echo -n "starting $DESC: "
    ${DAEMON} "${MSG1}" "${MSG2}" &
    echo "$NAME."
    ;;
  *)
    N=/etc/init.d/$NAME
    echo "Usage: $N {start|stop}" >&2
    exit 1
    ;;
esac

exit 0
