#!/bin/sh

DAEMON=/home/root/blinky
#This script launches the application that will blink an LED mapped to
#the Zynq or ZynqMP PS MIO
#In this case the PS LED is mapped to MIO31
DAEMON_OPTS="-m 31"

start ()
{
# Show the application banner.
echo " "
echo "*********************************************************************"
echo "***                                                               ***"
echo "***   Avnet UltraZed Out Of Box PetaLinux Build V1.2              ***"
echo "***                                                               ***"
echo "***   Based Upon the UZ3EG IOCC 2017.2 PetaLinux BSP from Avnet   ***"
echo "***                                                               ***"
echo "***   More information available on UltraZed.org community site   ***"
echo "***                                                               ***"
echo "***   The PS LED is mapped to ZynqMP MIO31                        ***"
echo "***                                                               ***"
echo "*********************************************************************"
echo " "
    start-stop-daemon -S -o --background -x $DAEMON -- $DAEMON_OPTS
}

stop ()
{
    echo " Stoping blinky"
    start-stop-daemon -K -x $DAEMON
}

restart()
{
    stop
    start
}

[ -e $DAEMON ] || exit 1
    case "$1" in
        start)
            start; ;;
        stop)
            stop; ;;
        restart)
            restart; ;;
        *)
            echo "Usage: $0 {start|stop|restart}"
            exit 1

esac
exit $?
