-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrc.local
48 lines (36 loc) · 1.09 KB
/
rc.local
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
#!/bin/bash
# 202202021651
########!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
# wait for networks to start
STATE="error";
while [ $STATE == "error" ]; do
#do a ping and check that its not a default message or change to grep for something else
STATE=$(ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null && echo ok || echo error)
#sleep for 2 seconds and try again
sleep 2
done
# if this file exists then skip processing
declare SKIP_PROCESSING="/home/pi/ble-sensors/skip.txt"
if [ -f "$SKIP_PROCESSING" ]; then
echo "$SKIP_PROCESSING exists, not starting ble monitor."
exit 1
fi
su pi -c 'tmux new-session -d -s ble'
su pi -c 'tmux send-keys sudo Space /home/pi/ble-sensors/hack_ble.sh C-m'
exit 0