#!/usr/bin/sh

#*********************************************************************************************************
#*   __     __               __     ______                __   __                      _______ _______   *
#*  |  |--.|  |.---.-..----.|  |--.|   __ \.---.-..-----.|  |_|  |--..-----..----.    |       |     __|  *
#*  |  _  ||  ||  _  ||  __||    < |    __/|  _  ||     ||   _|     ||  -__||   _|    |   -   |__     |  *
#*  |_____||__||___._||____||__|__||___|   |___._||__|__||____|__|__||_____||__|      |_______|_______|  *
#* http://www.blackpantheros.eu | http://www.blackpanther.hu - kbarcza[]blackpanther.hu * Charles Barcza *
#*************************************************************************************(c)2002-2023********
case $LANG in
	hu* ) 
	WARNING="HU"
	;;
	*)
	WARNING="EN"
	;;
esac

. /etc/blackPanther-default-apps.conf
echo -e "${RED}AirPlay Streaming Server started on${GRN} $(lsb_release -sir) ..$DEF"

if [ ! -n "$(ps --no-header -C 'uxplay' -o pid=)" ];then 

bubblemsg "AirPlay Server" "UxPlay is started now!<b>Run again for open manager dialog..</b>"


uxplay
bubblemsg "AirPlay Streaming" "The Server is shutdown.."
else
bubblemsg "AirPlay Streaming" "Already running! Please stop first.."
pydialog --title "AirPlay" --yesnocancel "Streaming Server already running!<br><u>Stop</u> or <u>Restart</u> now?!" --yes-label="Stop" --no-label="Restart"
RET=$?
echo $RET
if [ "$RET" = "0" ];then
echo "Stop..."
kill -HUP $(ps --no-header -C 'uxplay' -o pid=)
elif [ "$RET" = "1" ];then
echo "Restart..."
kill -HUP $(ps --no-header -C 'uxplay' -o pid=)
sleep 2
uxplay
bubblemsg "AirPlay Streaming" "The Server is shutdown.."
fi

fi


