|
@@ -0,0 +1,107 @@
|
|
|
+#!/bin/bash
|
|
|
+Mode=UART # (UART / USB )
|
|
|
+Output=0
|
|
|
+Beep=0
|
|
|
+
|
|
|
+# echo "T" >/dev/ttyAMA0
|
|
|
+
|
|
|
+echo -n "Serial ledStatus v1.0 : "
|
|
|
+if [ $Mode = "UART" ]
|
|
|
+then
|
|
|
+echo -e "UART mode\n"
|
|
|
+Output=serial
|
|
|
+#stty -F /dev/serial0 ispeed 9600 ospeed 9600 -ignpar cs8 -cstopb -echo
|
|
|
+echo "serial0" >/tmp/mcled
|
|
|
+else
|
|
|
+echo -e "USB mode\n"
|
|
|
+Output=ttyACM0
|
|
|
+stty -F /dev/ttyACM0 ispeed 9600 ospeed 9600 -ignpar cs8 -cstopb -echo
|
|
|
+echo "ttyACM0" >/tmp/mcled
|
|
|
+fi
|
|
|
+
|
|
|
+
|
|
|
+#ip=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')
|
|
|
+#ip=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')
|
|
|
+ip=192.168.1.8
|
|
|
+test=$(mcstatus $ip status | grep players: | awk '{print$2}' | sed 's/\x2F20//g')
|
|
|
+player1=$(mcstatus $ip status | grep players: | awk '{print$3}' | sed 's/\[\x2E//g')
|
|
|
+date_raw=$(date +%H%M)
|
|
|
+
|
|
|
+if [ -f /tmp/bootdelay ]
|
|
|
+then
|
|
|
+boottime=`cat /tmp/bootdelay | awk '{print $1}'`
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "z" >/dev/$Output'
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "0" >/dev/$Output'
|
|
|
+echo
|
|
|
+echo "boot delay wait"
|
|
|
+sleep 600
|
|
|
+rm /tmp/bootdelay
|
|
|
+fi
|
|
|
+
|
|
|
+case $Beep in
|
|
|
+0*)
|
|
|
+echo "Buzzer: OFF"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "z" >/dev/$Output'
|
|
|
+;;
|
|
|
+1*)
|
|
|
+echo "Buzzer: ON"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "Z" >/dev/$Output'
|
|
|
+;;
|
|
|
+*)
|
|
|
+;;
|
|
|
+esac
|
|
|
+
|
|
|
+if [ "$date_raw" -ge 0900 -a "$date_raw" -le 2100 ]
|
|
|
+then
|
|
|
+echo "Day: ON"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "D" >/dev/$Output'
|
|
|
+else
|
|
|
+echo "Day: OFF"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "N" >/dev/$Output'
|
|
|
+fi
|
|
|
+
|
|
|
+
|
|
|
+case $test in
|
|
|
+0*)
|
|
|
+echo "Players: O"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "0" >/dev/$Output'
|
|
|
+#curl http://192.168.1.120/off
|
|
|
+;;
|
|
|
+1*)
|
|
|
+if [ $player1 = "Tristus51" ]
|
|
|
+then
|
|
|
+echo "Code: Tristan"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "T" >/dev/$Output'
|
|
|
+#curl http://192.168.1.120/on
|
|
|
+echo $tristan
|
|
|
+elif [ $player1 = "ALVARE" ]
|
|
|
+then
|
|
|
+echo "Code: MisterPig"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "V" >/dev/$Output'
|
|
|
+#curl http://192.168.1.120/on
|
|
|
+elif [ $player1 = "BobBadin" ]
|
|
|
+then
|
|
|
+echo "Code: Ethan"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "E" >/dev/$Output'
|
|
|
+#curl http://192.168.1.120/on
|
|
|
+else
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "1" >/dev/$Output'
|
|
|
+#curl http://192.168.1.120/on
|
|
|
+fi
|
|
|
+;;
|
|
|
+2*)
|
|
|
+echo "Code: two"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "2" >/dev/$Output'
|
|
|
+#curl http://192.168.1.120/on
|
|
|
+;;
|
|
|
+[3-9]|[1-2][0-0]*)
|
|
|
+echo "Code: many"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "3" >/dev/$Output'
|
|
|
+#curl http://192.168.1.120/on
|
|
|
+;;
|
|
|
+*)
|
|
|
+echo "Code: Error"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "X" >/dev/$Output'
|
|
|
+#curl http://192.168.1.120/toggle
|
|
|
+;;
|
|
|
+esac
|