Skip to content

Commit

Permalink
hack startup script
Browse files Browse the repository at this point in the history
  • Loading branch information
silverchris committed Nov 7, 2020
1 parent 7a7d33b commit a511dac
Showing 1 changed file with 0 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ fi
start_headunit()
{
rm -f /tmp/root/headunit-wireless.status
sed -i 's."wifiTransport": true."wifiTransport": false.g' /tmp/root/headunit.json
taskset 0xFFFFFFFF "${SCRIPTPATH}/headunit" "$@" >> ${LOGPATH} 2>&1 &
sleep 2
touch /tmp/root/headunit.status
Expand All @@ -42,25 +41,6 @@ start_headunit()
echo "====================" >> ${LOGPATH}
}

start_AAwireless()
{
rm -f /tmp/root/headunit.status
sed -i 's."wifiTransport": false."wifiTransport": true.g' /tmp/root/headunit.json
PHONE_IP_ADDRESS=$1
shift
if [ ! -z $PHONE_IP_ADDRESS ]; then
sed -i "s/\"phoneIpAddress\": \".[^\"]*\"/\"phoneIpAddress\": \"$PHONE_IP_ADDRESS\"/g" /tmp/root/headunit.json
fi
sleep 2
echo "Phone IP: $PHONE_IP_ADDRESS" >> ${LOGPATH}
taskset 0xFFFFFFFF "${SCRIPTPATH}/headunit" "$@" >> ${LOGPATH} 2>&1 &
sleep 2
touch /tmp/root/headunit-wireless.status
echo "=== headunit-wifi ===" >> ${LOGPATH}
cat /tmp/root/headunit.json >> ${LOGPATH}
echo "====================" >> ${LOGPATH}
}

iptables -A INPUT -p tcp --dport 30515 -m state --state NEW,ESTABLISHED -j ACCEPT

rm -f /tmp/root/headunit.status /tmp/root/headunit-wireless.status
Expand All @@ -74,7 +54,6 @@ start_headunit
# loop forever. every 5 seconds,
while true
do
PHONE_IP_ADDRESS=`netstat -rn|awk '$2~/192\.168\.43\.[0-9]{1,3}/ {print $2}'`

if [ -e /tmp/root/usb_connect ]; then
USBCHECK=1
Expand All @@ -84,34 +63,17 @@ do
# echo "USB detach" >> ${LOGPATH}
fi

if [ ! -z $PHONE_IP_ADDRESS ] && [ $USBCHECK == 0 ]; then
if [ -e /tmp/root/headunit.status ]; then
killall -q headunit
fi

if ! [ -e /tmp/root/headunit-wireless.status ]; then
echo "WLAN Mode" >> ${LOGPATH}
echo "Start Headunit (WiFi Mode)"
echo "Phone IP: $PHONE_IP_ADDRESS"
start_AAwireless $PHONE_IP_ADDRESS
fi

else
# echo "USB Mode" >> ${LOGPATH}
check_headunit=`ps|grep 'bin/headunit'|grep -v wrapper|grep -v grep|wc -l|awk '{print $1}'`
# echo "check_headunit = $check_headunit" >> ${LOGPATH}

[ $check_headunit -eq 0 ] && rm -f /tmp/root/headunit-wireless.status /tmp/root/headunit.status

if [ -e /tmp/root/headunit-wireless.status ]; then
killall -q headunit
fi
if ! [ -e /tmp/root/headunit.status ]; then
echo "Start Headunit (USB Mode)"
echo "Start USB" >> ${LOGPATH}
start_headunit
fi
fi

RAND=`expr $RANDOM % 5 + 3`
#echo "go sleep $RAND"
Expand Down

0 comments on commit a511dac

Please sign in to comment.