-
-
Save scottleibrand/90bced09f9745e792474 to your computer and use it in GitHub Desktop.
mm-uploader.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 | |
# if it's been more than 3 minutes, unlock the CarelinkUSB | |
find /tmp/carelink.lock -mmin +3 -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 | |
echo "No lockfile: continuing" | |
touch /tmp/carelink.lock | |
export SERIAL=<snip> | |
/home/pi/decocare/bin/mm-send-comm.py --init sleep 1 | |
/home/pi/decocare/bin/mm-latest.py 180 --parser-out /home/pi/latest | |
/home/pi/decocare/bin/mm-send-comm.py tweak ReadRTC | grep -A2 decoded | tail -1 | sed "s/'//g" | while read line; do echo $line; done | while read line; do echo '{ "_type": "RTC", "_description": "live", "timestamp": "'$line'", "date": '`date +%s -d $line-0800`'000.0 }'; done | tee clock.json | |
rm /tmp/carelink.lock | |
/usr/bin/mongoimport -h <host>:27017 -d <db> -u <user> -p <password> --collection pump --jsonArray --upsert --upsertFields _description < /home/pi/latest | |
/usr/bin/mongoimport -h <host>:27017 -d <db> -u <user> -p <password> --collection pump --jsonArray --upsert --upsertFields _type < /home/pi/clock.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment