#/scripts/produktion.sh

echo "[produktion]S99z_cv_start.sh mit arg 1 $1"

start() {

	# Watchdog deaktivieren
	echo V >/dev/watchdog

	stty 57600 -F /dev/ttyO1

	/opt/boot.elf -b

	/scripts/produktion.sh -a 2>&1 | tee /home/user/prod.log;

    mount -t ubifs ubi0:rootfs /mnt/rootfs/
    echo "Production.sh Log"   > /mnt/sdboot/flash.log
    echo "==================" >> /mnt/sdboot/flash.log
    date                      >> /mnt/sdboot/flash.log
    echo ""                   >> /mnt/sdboot/flash.log
    mkdir -p /mnt/rootfs/home/user/simulatedPrinter/drives/X/
    echo "Production.sh Log"   > /mnt/rootfs/home/user/LogUpdate.txt
    echo "==================" >> /mnt/rootfs/home/user/LogUpdate.txt
    date                      >> /mnt/rootfs/home/user/LogUpdate.txt
    echo ""                   >> /mnt/rootfs/home/user/LogUpdate.txt
    if  [ -e /home/user/flash.log ]
    then
        cat /home/user/flash.log >> /mnt/sdboot/flash.log
        cat /home/user/flash.log >> /mnt/rootfs/home/user/LogUpdate.txt
    fi
    if  [ -e /home/user/prod.log ]
    then
        cat /home/user/prod.log >> /mnt/sdboot/flash.log
        cat /home/user/prod.log >> /mnt/rootfs/home/user/LogUpdate.txt
    fi

	sync
	# umount /mnt/sdboot
}

stop() {
	echo "Stopping S99z_cv_start"
}

restart() {
	stop
	start
}

case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  restart|reload)
  	restart
	;;
  *)
	echo "Usage: $0 {start|stop|restart}"
	exit 1
esac

exit $?

