Onion Scripts

http://robin.me/pi
======================= rc.local # Put your custom commands here that should be executed once # the system init finished. By default this file does nothing. sleep 3 python /root/active.py& sleep 3 /root/logrestart.sh sleep 30 python /root/spainmqtt.py& sleep 90 /root/check_internet.sh& exit 0 ======================= logrestart.sh echo "Device restarted at: $(date)." >> /root/alarmlog.txt ======================= #!/bin/sh # Check if scripts are running and restart if not # Check if connected to wifi and restart if not # Check if connected to the internet and restart if not # If can't ping google after 7 attempts then reboot # store the date and print it date=`date` echo 'Hello date' ${date} # Set infinite loop around whole script while true do echo 'started script' # Check if active.py is running and restart if not printf "\n" if ! pgrep -f "active.py" > /dev/null then echo "active.py Stopped" python /root/active.py & echo 'restarted active.py ' ${date} >> /root/alarmlog.txt echo 'restarted active.py ' echo ' ' sleep 30 else echo 'active.py running' echo ' ' fi # Check if spainmqtt is running and restart if not printf "\n" if ! pgrep -f "spainmqtt.py" > /dev/null then echo "spainmqtt.py Stopped" python /root/spainmqtt.py & echo 'restarted spainmqtt.py ' ${date} >> /root/alarmlog.txt echo 'restarted spainmqtt.py ' echo ' ' sleep 30 else echo 'spainmqtt.py running' echo ' ' fi # See if we can ping google and restart the wifi if not # If we can't ping google after trying to restart wifi, then reboot pinging() { sleep 3 ping -c2 google.com if [ $? -eq 0 ]; then let "totping--" echo "ping works ok" else echo 'no ping to google.com ' ${date} echo 'no ping to google.com ' ${date} >> /root/alarmlog.txt sleep 3 echo 'wifi' wifi echo 'toping is ' $toping echo ' ' let "totping++" fi } pinging while [ $totping -gt 0 ] do pinging echo "totping is now " $totping " Restarting at 20" if [ $totping -gt 20 ] then echo 'noping reboot' ${date} >> /root/alarmlog.txt echo 'noping reboot' ${date} let "totping=0" reboot fi printf "\n" done printf "\n" echo 'completed script' let "totping=0" printf "\n\n\n" sleep 15 done ======================= logunique.sh awk '!seen[$0]++' alarmlog.txt >alarmlog.tmp && mv alarmlog.tmp alarmlog.txt ======================= crontab # 0 19 * * * sleep 70 && touch /etc/banner && reboot >> /root/cronlog.txt 2>&1 */5 * * * * /root/logunique.sh #end =======================