-
-
Save scottleibrand/37234e6c643aa5d68b5e to your computer and use it in GitHub Desktop.
closedloop.live.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
/home/pi/bin/mm-uploader.live.sh >> /var/log/uploader.log | |
curl -sk https://<hostname>/closedloop.php | |
# if it's been more than 5 minutes, unlock the CarelinkUSB | |
#find /tmp/carelink.lock -mmin +5 -exec rm -f {} \; 2>/dev/null >/dev/null | |
# only one process can talk to the pump at a time | |
ls /tmp/carelink.lock >/dev/null 2>/dev/null && echo "Carelink locked: exiting" && exit | |
if /usr/bin/curl -sk https://<hostname>/closedloop.txt | /bin/grep set; then | |
echo "No lockfile: continuing" | |
touch /tmp/carelink.lock | |
export SERIAL=<snip> | |
/usr/bin/curl -sk https://<hostname>/closedloop.txt | while read line; do echo "/usr/local/bin/mm-temp-basals.py $line" | bash; done | |
rm /tmp/carelink.lock | |
/home/pi/bin/mm-uploader.live.short.sh >> /var/log/uploader.log | |
fi | |
# if there are still any mm-* processes running, kill them off and remove the lock | |
/bin/ps aux | /bin/grep mm-.* | /bin/grep -v grep | /usr/bin/awk '{print $2}' | while read line; do /bin/kill $line; done | |
rm /tmp/carelink.lock |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment