Skip to content

Instantly share code, notes, and snippets.

@DustinAlandzes
Created October 14, 2016 20:39
Show Gist options
  • Save DustinAlandzes/45c619b4213e0e2f102ff65ede590ccd to your computer and use it in GitHub Desktop.
Save DustinAlandzes/45c619b4213e0e2f102ff65ede590ccd to your computer and use it in GitHub Desktop.
#!/bin/sh
ACCT_ID="6ptphr42"
LOG_FILE="/var/log/install-dp.log"
#Wait maximum 30 seconds on network connectivity before giving up
limit=30
retry=0
#Don't bother to run when lo is configured
if [ "$IFACE" = lo ]; then
exit 0
fi
#Only run from ifup
if [ "$MODE" != start ]; then
exit 0
fi
if [ ! -e /opt/dataplicity/tuxtunnel/auth ]; then
echo $IFACE >> $LOG_FILE 2>&1
until ping -c 1 www.dataplicity.com ; do
sleep 1
retry=$(($retry+1))
if [ $retry -eq $limit ]; then
echo "Interface didn't connect to network and limit reached..." >> $LOG_FILE 2>&1
exit 0
fi
done
echo "Dataplicity will now be installed..." >> $LOG_FILE 2>&1
/bin/sh -c "curl https://www.dataplicity.com/$ACCT_ID.py | sudo python" >> $LOG_FILE 2>&1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment