public
Created

azureobd startup script to be placed into init.d replace {KEY}, {NAMESPACE}, and {QUEUE}

  • Download Gist
azureobd
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
#! /bin/bash
### BEGIN INIT INFO
# Provides: azureobd
# Required-Start: $remote_fs $syslog $network $all
# Required-Stop: $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start AzureOBD at boot time
# Description: Start AzureOBD at boot time.
### END INIT INFO
 
# /etc/init.d/azureobd
 
USER=root
HOME=/root
VNCUSER=pi
RETRYCOUNT=20
 
export USER HOME
 
case "$1" in
start)
until [ $RETRYCOUNT -lt 1 ]; do
if ping -w 4 -I wlan0 -c 1 8.8.8.8 > /dev/null
then
echo "$(date) Network connection available" >> /var/log/azureobd.log
break
else
echo "$(date) Still trying network connection ..." >> /var/log/azureobd.log
fi
let RETRYCOUNT-=1
echo "$(date) Retry $RETRYCOUNT"
sleep 5
done
 
echo "$(date) Starting Azure OBD-2" >> /var/log/azureobd.log 2>&1
/usr/bin/azureobdlogger -s /dev/ttyUSB0 -b 38400 -q amqps://owner:{KEY}@{NAMESPACE}.servicebus.windows.net/{QUEUE} >> /var/log/azureobd.log 2>&1 &
echo "." >> /var/log/azureobd.log 2>&1
 
;;
stop)
echo "$(date) Stopping Azure OBD-2" >> /var/log/azureobd.log 2>&1
killall azureobdlogger
echo "." >> /var/log/azureobd.log 2>&1
;;
 
*)
echo "Usage: /etc/init.d/azurobd {start|stop}"
exit 1
;;
esac
 
exit 0

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.