From fdaab9bf7876de764f83f328a09d4e59fff9335d Mon Sep 17 00:00:00 2001 From: root Date: Fri, 15 Aug 2014 18:12:57 -0700 Subject: [PATCH] Add wifiboot service files --- wifiboot.service | 9 +++++++++ wifiboot/cp_service | 1 + wifiboot/last_ping.txt | 1 + wifiboot/ping_test.py | 33 +++++++++++++++++++++++++++++++++ wifiboot/wifiboot.service | 9 +++++++++ wifiboot/wifiboot.sh | 14 ++++++++++++++ 6 files changed, 67 insertions(+) create mode 100644 wifiboot.service create mode 100755 wifiboot/cp_service create mode 100644 wifiboot/last_ping.txt create mode 100644 wifiboot/ping_test.py create mode 100644 wifiboot/wifiboot.service create mode 100755 wifiboot/wifiboot.sh diff --git a/wifiboot.service b/wifiboot.service new file mode 100644 index 0000000..1c95343 --- /dev/null +++ b/wifiboot.service @@ -0,0 +1,9 @@ +[Unit] +Description=Wifi Startup Retry + +[Service] +WorkingDirectory=/home/root/wifiboot/ +ExecStart=/home/root/wifiboot/wifiboot.sh + +[Install] +WantedBy=multi-user.target diff --git a/wifiboot/cp_service b/wifiboot/cp_service new file mode 100755 index 0000000..0ec2213 --- /dev/null +++ b/wifiboot/cp_service @@ -0,0 +1 @@ +cp wifiboot.service /lib/systemd/system/ diff --git a/wifiboot/last_ping.txt b/wifiboot/last_ping.txt new file mode 100644 index 0000000..6018703 --- /dev/null +++ b/wifiboot/last_ping.txt @@ -0,0 +1 @@ +Sat Nov 30 04:27:32 2013 \ No newline at end of file diff --git a/wifiboot/ping_test.py b/wifiboot/ping_test.py new file mode 100644 index 0000000..c2617ba --- /dev/null +++ b/wifiboot/ping_test.py @@ -0,0 +1,33 @@ +import subprocess +import time + +host = "yahoo.com" + +while True: + ping = subprocess.Popen( + ["ping", "-c", "2", host], + stdout = subprocess.PIPE, + stderr = subprocess.PIPE + ) + + out, error = ping.communicate() + + + print out + import re + matcher = re.search(r"(\d) packets transmitted, (\d) received",out) + if(matcher): + print matcher.group(1) + print matcher.group(2) + + sent = matcher.group(1) + received = matcher.group(2) + + if(sent == received): + time_now = time.asctime(time.localtime()) + print time_now + f = open('last_ping.txt','w') + f.write(time_now) + f.close() + + time.sleep(10) diff --git a/wifiboot/wifiboot.service b/wifiboot/wifiboot.service new file mode 100644 index 0000000..1c95343 --- /dev/null +++ b/wifiboot/wifiboot.service @@ -0,0 +1,9 @@ +[Unit] +Description=Wifi Startup Retry + +[Service] +WorkingDirectory=/home/root/wifiboot/ +ExecStart=/home/root/wifiboot/wifiboot.sh + +[Install] +WantedBy=multi-user.target diff --git a/wifiboot/wifiboot.sh b/wifiboot/wifiboot.sh new file mode 100755 index 0000000..a1dfd98 --- /dev/null +++ b/wifiboot/wifiboot.sh @@ -0,0 +1,14 @@ +#!/bin/sh - +sleep 10 +#systemctl restart connman.service + +#python ping_test.py >/dev/null & + +cd /home/root/halo_git/ + +./Halo_Master.pl > /dev/null & + +cd /home/root/colorpicker-beaglebone/ + +NODE_ENV=production npm start +