#!/bin/bash
killall -9 -u $(whoami) run-mudlet.sh
killall -9 -u $(whoami) Mudlet.AppImage
killall -9 -u $(whoami) mudlet
sleep 2

MUDLET_BINARY="$HOME/Desktop/Mudlet.AppImage"

file="$HOME/Desktop/blockbot.txt"
if [ -f "$file" ]
then
	# do not run Mudlet
	echo "blockbot file found.  Mudlet will not be started."
else
	file="$HOME/Desktop/Mudlet.AppImage"
	if [ -f "$file" ] ; then
	  while true ; do
		echo ""
		echo "Running Binary in Restart Mode... "
		echo "  ${MUDLET_BINARY} "
		echo ""

		$MUDLET_BINARY
		wait $!

		echo ""
		echo "Restarting Mudlet..."
		echo ""
	  done
	fi
fi
