Skip to content

Commit

Permalink
Add rc.local, which starts telegraph binary on boot (once internet is…
Browse files Browse the repository at this point in the history
… connected).
  • Loading branch information
curiositry committed Apr 16, 2017
1 parent c521166 commit bb516d4
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions rc.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/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

exec 2> /rc.local.log # send stderr from rc.local to a log file
exec 1>&2 # send stdout to the same log file
set -x # tell sh to display commands before execution

INTERNET=0;

echo none >/sys/class/leds/led0/trigger
echo 1 >/sys/class/leds/led0/brightness

while [ $INTERNET -ne 1 ]; do
INTERNET=$(ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null && echo 1 || echo 0)

# Sleep for 2 seconds and try again
sleep 2
done

echo 0 >/sys/class/leds/led0/brightness

cd /
./internet-telegraph &

echo mmc0 >/sys/class/leds/led0/trigger

exit 0

0 comments on commit bb516d4

Please sign in to comment.