From f4f0e3ca8303be6bb1c9201d7749a372521966b5 Mon Sep 17 00:00:00 2001 From: Dana Lewis Date: Sat, 31 Dec 2016 14:29:28 -0600 Subject: [PATCH 01/20] Commenting out "type": = "current" (#296) --- lib/profile/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/profile/index.js b/lib/profile/index.js index 8a466fd78..a6295d26f 100644 --- a/lib/profile/index.js +++ b/lib/profile/index.js @@ -7,7 +7,7 @@ var carb_ratios = require('./carbs'); function defaults ( ) { var profile = { max_iob: 0 // if max_iob is not provided, never give more insulin than the pump would have - , type: 'current' + // , type: 'current' , max_daily_safety_multiplier: 3 , current_basal_safety_multiplier: 4 , autosens_max: 1.2 From aed5d31e629fa6306957071248094153b1b7d848 Mon Sep 17 00:00:00 2001 From: kenstack Date: Sun, 1 Jan 2017 16:08:42 -0500 Subject: [PATCH 02/20] restart networking completely instead just cycling wlan0 (#284) * restart networking completely instead just cycling wlan0 this has proved more stable for me across some wifi netoworks * Re-add dhclient release/renew * Update oref0-online.sh --- bin/oref0-online.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/oref0-online.sh b/bin/oref0-online.sh index 50f9ddf38..bb539ad9b 100755 --- a/bin/oref0-online.sh +++ b/bin/oref0-online.sh @@ -2,9 +2,11 @@ MAC=$1 echo -n "At $(date) my IP is: " if ! curl -m 15 icanhazip.com; then - echo -n "Error, cycling wlan0 " - sudo ifdown wlan0 - sudo ifup wlan0 + echo -n "Error, cycling networking " + # simply restart networking completely for stability purposes + /etc/init.d/networking stop + sleep 5 + /etc/init.d/networking start echo -n "and getting new wlan0 IP" ps aux | grep -v grep | grep -q "dhclient wlan0" && sudo killall dhclient sudo dhclient wlan0 -r @@ -13,7 +15,7 @@ if ! curl -m 15 icanhazip.com; then echo -n "At $(date) my IP is: " if ! curl -m 15 icanhazip.com; then echo -n "Error, connecting BT to $MAC " - sudo killall bluetoothd; sudo /usr/local/bin/bluetoothd --experimental & + sudo killall bluetoothd; sleep 5; sudo /usr/local/bin/bluetoothd --experimental & sudo bt-pan client $MAC echo -n "and getting bnep0 IP" sudo dhclient bnep0 From c308e1749083fcc13d73965c996efa3a330aea9b Mon Sep 17 00:00:00 2001 From: John Benjamin Date: Sun, 1 Jan 2017 17:08:03 -0500 Subject: [PATCH 03/20] Bt device name (#307) * Update oref0-online.sh Change the BT devicename from BlueZ 5.37 to hostname of Board * Update oref0-setup.sh add hostname as BT device name. --- bin/oref0-online.sh | 1 + bin/oref0-setup.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/bin/oref0-online.sh b/bin/oref0-online.sh index bb539ad9b..f0334d630 100755 --- a/bin/oref0-online.sh +++ b/bin/oref0-online.sh @@ -16,6 +16,7 @@ if ! curl -m 15 icanhazip.com; then if ! curl -m 15 icanhazip.com; then echo -n "Error, connecting BT to $MAC " sudo killall bluetoothd; sleep 5; sudo /usr/local/bin/bluetoothd --experimental & + sudo hciconfig hci0 name $HOSTNAME sudo bt-pan client $MAC echo -n "and getting bnep0 IP" sudo dhclient bnep0 diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index aaa9bd6cc..3422cc23f 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -300,6 +300,7 @@ if [[ ! -z "$BT_MAC" || ${CGM,,} =~ "shareble" ]]; then cd $HOME/src/bluez-5.37 && ./configure --enable-experimental --disable-systemd && \ make && sudo make install && sudo cp ./src/bluetoothd /usr/local/bin/ || die "Couldn't make bluez" sudo killall bluetoothd; sudo /usr/local/bin/bluetoothd --experimental & + sudo hciconfig hci0 name $HOSTNAME else echo bluez v 5.37 already installed fi From 3e9805b213487fb3c4bc4a052180ac1cabf200c4 Mon Sep 17 00:00:00 2001 From: ijustlovemath Date: Sun, 1 Jan 2017 22:27:01 -0500 Subject: [PATCH 04/20] Exit scripts when variables under or functions fail (#309) * Exit script when variables unset or functions fail --- bin/mm-format-ns-glucose.sh | 3 +++ bin/mm-format-ns-profile.sh | 3 +++ bin/mm-format-ns-pump-history.sh | 3 +++ bin/mm-format-ns-treatments.sh | 3 +++ bin/mm-format-oref0-glucose.sh | 3 +++ bin/mm-stick.sh | 3 +++ bin/nightscout.sh | 2 ++ bin/ns-dedupe-treatments.sh | 3 +++ bin/ns-get.sh | 3 +++ bin/ns-upload-entries.sh | 3 +++ bin/ns-upload.sh | 3 +++ bin/oref0-conditional-run.sh | 5 ++++- bin/oref0-copy-fresher | 4 ++++ bin/oref0-fix-git-corruption.sh | 4 ++++ bin/oref0-ifttt-notify | 3 +++ bin/oref0-mint-max-iob.sh | 2 ++ bin/oref0-reset-git.sh | 3 +++ bin/oref0-reset-usb.sh | 3 +++ bin/oref0-set-device-clocks.sh | 3 +++ bin/oref0-set-system-clock.sh | 3 +++ bin/oref0-setup.sh | 4 ++++ bin/oref0-truncate-git-history.sh | 3 +++ bin/oref0.sh | 2 ++ 23 files changed, 70 insertions(+), 1 deletion(-) diff --git a/bin/mm-format-ns-glucose.sh b/bin/mm-format-ns-glucose.sh index aa7a1b390..1b3211660 100755 --- a/bin/mm-format-ns-glucose.sh +++ b/bin/mm-format-ns-glucose.sh @@ -5,6 +5,9 @@ # Written for decocare v0.0.17. Will need updating the the decocare json format changes. +# Exit script when variables are unset or functions fail +set -eu + NSONLY="" test "$1" = "--oref0" && NSONLY="this.glucose = this.sgv" && shift diff --git a/bin/mm-format-ns-profile.sh b/bin/mm-format-ns-profile.sh index 718224ce6..3c64db3b5 100755 --- a/bin/mm-format-ns-profile.sh +++ b/bin/mm-format-ns-profile.sh @@ -2,6 +2,9 @@ # Author: Ben West +# Exit when variables are unset or functions fail +set -eu + self=$(basename $0) SETTINGS=${1-monitor/settings.json} CARBS=${2-monitor/carb-ratios.json} diff --git a/bin/mm-format-ns-pump-history.sh b/bin/mm-format-ns-pump-history.sh index 478561ee5..aa5c2fe50 100755 --- a/bin/mm-format-ns-pump-history.sh +++ b/bin/mm-format-ns-pump-history.sh @@ -3,6 +3,9 @@ # Author: Ben West # Maintainer: Scott Leibrand +# Exit when variables are unset or functions fail +set -eu + self=$(basename $0) function usage ( ) { diff --git a/bin/mm-format-ns-treatments.sh b/bin/mm-format-ns-treatments.sh index ebc884627..c28bf36b1 100755 --- a/bin/mm-format-ns-treatments.sh +++ b/bin/mm-format-ns-treatments.sh @@ -2,6 +2,9 @@ # Author: Ben West +# Exit when variables are unset or functions fail +set -eu + HISTORY=${1-monitor/pump-history-zoned.json} MODEL=${2-model.json} OUTPUT=${3-/dev/fd/1} diff --git a/bin/mm-format-oref0-glucose.sh b/bin/mm-format-oref0-glucose.sh index 975a542a9..86c3edd5c 100755 --- a/bin/mm-format-oref0-glucose.sh +++ b/bin/mm-format-oref0-glucose.sh @@ -3,6 +3,9 @@ # Author: Ben West @bewest # Maintainer: @tghoward +# Exit when variables are unset or functions fail +set -eu + # Written for decocare v0.0.18. Will need updating the the decocare json format changes. self=$(basename $0) HISTORY=${1-glucosehistory.json} diff --git a/bin/mm-stick.sh b/bin/mm-stick.sh index afb6c9123..1b30eb4a1 100755 --- a/bin/mm-stick.sh +++ b/bin/mm-stick.sh @@ -2,6 +2,9 @@ # Author: Ben West @bewest +# Exit when variables are unset or functions fail +set -eu + # Written for decocare v0.0.17. self=$(basename $0) OUTPUT=/dev/fd/1 diff --git a/bin/nightscout.sh b/bin/nightscout.sh index 5db9e62ca..ce02f9fcb 100755 --- a/bin/nightscout.sh +++ b/bin/nightscout.sh @@ -1,5 +1,7 @@ #!/bin/bash +# Exit when variables are unset or functions fail +set -eu self=$(basename $0) NAME=${1-help} diff --git a/bin/ns-dedupe-treatments.sh b/bin/ns-dedupe-treatments.sh index 7785f39ea..2acae8960 100755 --- a/bin/ns-dedupe-treatments.sh +++ b/bin/ns-dedupe-treatments.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Exit when variables are unset or functions fail +set -eu + self=$(basename $0) function usage ( ) { diff --git a/bin/ns-get.sh b/bin/ns-get.sh index 330662c2a..d5ecedc45 100755 --- a/bin/ns-get.sh +++ b/bin/ns-get.sh @@ -2,6 +2,9 @@ # Author: Ben West +# Exit when variables are unset or functions fail +set -eu + self=$(basename $0) REPORT=${1-entries.json} NIGHTSCOUT_HOST=${NIGHTSCOUT_HOST-${2-localhost:1337}} diff --git a/bin/ns-upload-entries.sh b/bin/ns-upload-entries.sh index a60f8053f..ac26d80aa 100755 --- a/bin/ns-upload-entries.sh +++ b/bin/ns-upload-entries.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Exit when variables are unset or functions fail +set -eu + # Author: Ben West # Maintainer: @cjo20, @scottleibrand diff --git a/bin/ns-upload.sh b/bin/ns-upload.sh index 5df63d052..8d1c6bd61 100755 --- a/bin/ns-upload.sh +++ b/bin/ns-upload.sh @@ -2,6 +2,9 @@ # Author: Ben West +# Exit when variables are unset or functions fail +set -eu + self=$(basename $0) NIGHTSCOUT_HOST=${NIGHTSCOUT_HOST-${1-localhost:1337}} API_SECRET=${2-${API_SECRET}} diff --git a/bin/oref0-conditional-run.sh b/bin/oref0-conditional-run.sh index b448b2df6..f9397e46e 100755 --- a/bin/oref0-conditional-run.sh +++ b/bin/oref0-conditional-run.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Exit when variables are unset or functions fail +set -eu + export GENERATE=false export FILE=$1 export FILE2=$2 @@ -35,4 +38,4 @@ if [ "$GENERATE" = true ]; then fi else echo "$FILE exists and is new, skipping invoke" -fi \ No newline at end of file +fi diff --git a/bin/oref0-copy-fresher b/bin/oref0-copy-fresher index 4d9f12081..10d71d75c 100755 --- a/bin/oref0-copy-fresher +++ b/bin/oref0-copy-fresher @@ -1,4 +1,8 @@ #!/bin/bash + +# Exit when variables are unset or functions fail +set -eu + self=$(basename $0) WITHIN=0 diff --git a/bin/oref0-fix-git-corruption.sh b/bin/oref0-fix-git-corruption.sh index 715bf730c..85149ecfd 100755 --- a/bin/oref0-fix-git-corruption.sh +++ b/bin/oref0-fix-git-corruption.sh @@ -4,6 +4,10 @@ # Author: Ben West # # + +# Exit when variables are unset or functions fail +set -eu + < Date: Mon, 2 Jan 2017 14:39:37 -0800 Subject: [PATCH 05/20] first attempt at setting up nightly autotune with oref0-setup and using autotuned profile.json for looping --- ...-autotune-test.sh => oref0-ns-autotune.sh} | 0 bin/oref0-setup.sh | 98 +++++++++++-------- lib/oref0-setup/autotune.json | 43 ++++++++ package.json | 3 + 4 files changed, 104 insertions(+), 40 deletions(-) rename bin/{oref0-autotune-test.sh => oref0-ns-autotune.sh} (100%) create mode 100644 lib/oref0-setup/autotune.json diff --git a/bin/oref0-autotune-test.sh b/bin/oref0-ns-autotune.sh similarity index 100% rename from bin/oref0-autotune-test.sh rename to bin/oref0-ns-autotune.sh diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index aaa9bd6cc..0a29d60ba 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -185,6 +185,10 @@ if [[ -z "$DIR" || -z "$serial" ]]; then if [[ $REPLY =~ ^[Yy]$ ]]; then ENABLE+=" autosens " fi + read -p "Enable autotuning of basals and ratios? y/[N] " -r + if [[ $REPLY =~ ^[Yy]$ ]]; then + ENABLE+=" autotune " + fi read -p "Enable advanced meal assist? y/[N] " -r if [[ $REPLY =~ ^[Yy]$ ]]; then ENABLE+=" meal " @@ -336,7 +340,7 @@ elif [[ ${CGM,,} =~ "shareble" ]]; then if bluetoothd --version | grep -q 5.37 2>/dev/null; then sudo cp $HOME/src/openxshareble/bluetoothd.conf /etc/dbus-1/system.d/bluetooth.conf || die "Couldn't copy bluetoothd.conf" fi - # add two lines to /etc/rc.local if they are missing. + # add two lines to /etc/rc.local if they are missing. if ! grep -q '/usr/local/bin/bluetoothd --experimental &' /etc/rc.local; then sed -i"" 's/^exit 0/\/usr\/local\/bin\/bluetoothd --experimental \&\n\nexit 0/' /etc/rc.local fi @@ -486,14 +490,6 @@ if [[ ${CGM,,} =~ "xdrip" ]]; then touch /tmp/reboot-required fi -# configure optional features -if [[ $ENABLE =~ autosens && $ENABLE =~ meal ]]; then - EXTRAS="settings/autosens.json monitor/meal.json" -elif [[ $ENABLE =~ autosens ]]; then - EXTRAS="settings/autosens.json" -elif [[ $ENABLE =~ meal ]]; then - EXTRAS='"" monitor/meal.json' -fi # Install EdisonVoltage if egrep -i "edison" /etc/passwd 2>/dev/null; then echo "Checking if EdisonVoltage is already installed" @@ -509,11 +505,29 @@ if egrep -i "edison" /etc/passwd 2>/dev/null; then for type in edisonbattery; do echo importing $type file cat $HOME/src/oref0/lib/oref0-setup/$type.json | openaps import || die "Could not import $type.json" - done + done +fi + +# configure optional features passed to enact/suggested.json report +if [[ $ENABLE =~ autosens && $ENABLE =~ meal ]]; then + EXTRAS="settings/autosens.json monitor/meal.json" +elif [[ $ENABLE =~ autosens ]]; then + EXTRAS="settings/autosens.json" +elif [[ $ENABLE =~ meal ]]; then + EXTRAS='"" monitor/meal.json' fi echo Running: openaps report add enact/suggested.json text determine-basal shell monitor/iob.json monitor/temp_basal.json monitor/glucose.json settings/profile.json $EXTRAS openaps report add enact/suggested.json text determine-basal shell monitor/iob.json monitor/temp_basal.json monitor/glucose.json settings/profile.json $EXTRAS +# configure autotune if enabled +if [[ $ENABLE =~ autotune ]]; then + cd $directory || die "Can't cd $directory" + for type in autotune; do + echo importing $type file + cat $HOME/src/oref0/lib/oref0-setup/$type.json | openaps import || die "Could not import $type.json" + done +fi + # Create ~/.profile so that openaps commands can be executed from the command line # as long as we still use enivorement variables it's easy that the openaps commands work from both crontab and from a common shell # TODO: remove API_SECRET and NIGHTSCOUT_HOST (see https://github.com/openaps/oref0/issues/299) @@ -533,44 +547,48 @@ echo read -p "Schedule openaps in cron? y/[N] " -r if [[ $REPLY =~ ^[Yy]$ ]]; then # add crontab entries -(crontab -l; crontab -l | grep -q "$NIGHTSCOUT_HOST" || echo NIGHTSCOUT_HOST=$NIGHTSCOUT_HOST) | crontab - -(crontab -l; crontab -l | grep -q "API_SECRET=" || echo API_SECRET=$(nightscout hash-api-secret $API_SECRET)) | crontab - -(crontab -l; crontab -l | grep -q "PATH=" || echo "PATH=$PATH" ) | crontab - -(crontab -l; crontab -l | grep -q "oref0-online $BT_MAC" || echo '* * * * * ps aux | grep -v grep | grep -q "oref0-online '$BT_MAC'" || oref0-online '$BT_MAC' >> /var/log/openaps/network.log' ) | crontab - -(crontab -l; crontab -l | grep -q "sudo wpa_cli scan" || echo '* * * * * sudo wpa_cli scan') | crontab - -(crontab -l; crontab -l | grep -q "killall -g --older-than" || echo '* * * * * killall -g --older-than 15m openaps') | crontab - -# repair or reset git repository if it's corrupted or disk is full -(crontab -l; crontab -l | grep -q "cd $directory && oref0-reset-git" || echo "* * * * * cd $directory && oref0-reset-git") | crontab - -#truncate git history to 1000 commits if it has grown past 1500 -(crontab -l; crontab -l | grep -q "cd $directory && oref0-truncate-git-history" || echo "* * * * * cd $directory && oref0-truncate-git-history") | crontab - -if [[ ${CGM,,} =~ "shareble" ]]; then - (crontab -l; crontab -l | grep -q "cd $directory-cgm-loop && ps aux | grep -v grep | grep -q 'openaps monitor-cgm'" || echo "* * * * * cd $directory-cgm-loop && ps aux | grep -v grep | grep -q 'openaps monitor-cgm' || ( date; openaps monitor-cgm) | tee -a /var/log/openaps/cgm-loop.log; cp -up monitor/glucose-raw-merge.json $directory/cgm/glucose.json ; cp -up $directory/cgm/glucose.json $directory/monitor/glucose.json") | crontab - -elif [[ ${CGM,,} =~ "xdrip" ]]; then - (crontab -l; crontab -l | grep -q "cd $directory && ps aux | grep -v grep | grep -q 'openaps monitor-xdrip'" || echo "* * * * * cd $directory && ps aux | grep -v grep | grep -q 'openaps monitor-xdrip' || ( date; openaps monitor-xdrip) | tee -a /var/log/openaps/xdrip-loop.log; cp -up $directory/xdrip/glucose.json $directory/monitor/glucose.json") | crontab - - (crontab -l; crontab -l | grep -q "xDripAPS.py" || echo "@reboot python $HOME/.xDripAPS/xDripAPS.py") | crontab - -elif [[ $ENABLE =~ dexusb ]]; then - (crontab -l; crontab -l | grep -q "@reboot .*dexusb-cgm" || echo "@reboot /usr/bin/python -u /usr/local/bin/oref0-dexusb-cgm-loop >> /var/log/openaps/cgm-dexusb-loop.log 2>&1" ) | crontab - -elif ! [[ ${CGM,,} =~ "mdt" ]]; then # use nightscout for cgm - (crontab -l; crontab -l | grep -q "cd $directory && ps aux | grep -v grep | grep -q 'openaps get-bg'" || echo "* * * * * cd $directory && ps aux | grep -v grep | grep -q 'openaps get-bg' || ( date; openaps get-bg ; cat cgm/glucose.json | json -a sgv dateString | head -1 ) | tee -a /var/log/openaps/cgm-loop.log") | crontab - -fi -(crontab -l; crontab -l | grep -q "cd $directory && ps aux | grep -v grep | grep -q 'openaps ns-loop'" || echo "* * * * * cd $directory && ps aux | grep -v grep | grep -q 'openaps ns-loop' || openaps ns-loop | tee -a /var/log/openaps/ns-loop.log") | crontab - -if [[ $ENABLE =~ autosens ]]; then - (crontab -l; crontab -l | grep -q "cd $directory && ps aux | grep -v grep | grep -q 'openaps autosens'" || echo "* * * * * cd $directory && ps aux | grep -v grep | grep -q 'openaps autosens' || openaps autosens | tee -a /var/log/openaps/autosens-loop.log") | crontab - -fi -if [[ "$ttyport" =~ "spi" ]]; then - (crontab -l; crontab -l | grep -q "reset_spi_serial.py" || echo "@reboot reset_spi_serial.py") | crontab - + (crontab -l; crontab -l | grep -q "$NIGHTSCOUT_HOST" || echo NIGHTSCOUT_HOST=$NIGHTSCOUT_HOST) | crontab - + (crontab -l; crontab -l | grep -q "API_SECRET=" || echo API_SECRET=$(nightscout hash-api-secret $API_SECRET)) | crontab - + (crontab -l; crontab -l | grep -q "PATH=" || echo "PATH=$PATH" ) | crontab - + (crontab -l; crontab -l | grep -q "oref0-online $BT_MAC" || echo '* * * * * ps aux | grep -v grep | grep -q "oref0-online '$BT_MAC'" || oref0-online '$BT_MAC' >> /var/log/openaps/network.log' ) | crontab - + (crontab -l; crontab -l | grep -q "sudo wpa_cli scan" || echo '* * * * * sudo wpa_cli scan') | crontab - + (crontab -l; crontab -l | grep -q "killall -g --older-than" || echo '* * * * * killall -g --older-than 15m openaps') | crontab - + # repair or reset git repository if it's corrupted or disk is full + (crontab -l; crontab -l | grep -q "cd $directory && oref0-reset-git" || echo "* * * * * cd $directory && oref0-reset-git") | crontab - + # truncate git history to 1000 commits if it has grown past 1500 + (crontab -l; crontab -l | grep -q "cd $directory && oref0-truncate-git-history" || echo "* * * * * cd $directory && oref0-truncate-git-history") | crontab - + if [[ ${CGM,,} =~ "shareble" ]]; then + (crontab -l; crontab -l | grep -q "cd $directory-cgm-loop && ps aux | grep -v grep | grep -q 'openaps monitor-cgm'" || echo "* * * * * cd $directory-cgm-loop && ps aux | grep -v grep | grep -q 'openaps monitor-cgm' || ( date; openaps monitor-cgm) | tee -a /var/log/openaps/cgm-loop.log; cp -up monitor/glucose-raw-merge.json $directory/cgm/glucose.json ; cp -up $directory/cgm/glucose.json $directory/monitor/glucose.json") | crontab - + elif [[ ${CGM,,} =~ "xdrip" ]]; then + (crontab -l; crontab -l | grep -q "cd $directory && ps aux | grep -v grep | grep -q 'openaps monitor-xdrip'" || echo "* * * * * cd $directory && ps aux | grep -v grep | grep -q 'openaps monitor-xdrip' || ( date; openaps monitor-xdrip) | tee -a /var/log/openaps/xdrip-loop.log; cp -up $directory/xdrip/glucose.json $directory/monitor/glucose.json") | crontab - + (crontab -l; crontab -l | grep -q "xDripAPS.py" || echo "@reboot python $HOME/.xDripAPS/xDripAPS.py") | crontab - + elif [[ $ENABLE =~ dexusb ]]; then + (crontab -l; crontab -l | grep -q "@reboot .*dexusb-cgm" || echo "@reboot /usr/bin/python -u /usr/local/bin/oref0-dexusb-cgm-loop >> /var/log/openaps/cgm-dexusb-loop.log 2>&1" ) | crontab - + elif ! [[ ${CGM,,} =~ "mdt" ]]; then # use nightscout for cgm + (crontab -l; crontab -l | grep -q "cd $directory && ps aux | grep -v grep | grep -q 'openaps get-bg'" || echo "* * * * * cd $directory && ps aux | grep -v grep | grep -q 'openaps get-bg' || ( date; openaps get-bg ; cat cgm/glucose.json | json -a sgv dateString | head -1 ) | tee -a /var/log/openaps/cgm-loop.log") | crontab - + fi + (crontab -l; crontab -l | grep -q "cd $directory && ps aux | grep -v grep | grep -q 'openaps ns-loop'" || echo "* * * * * cd $directory && ps aux | grep -v grep | grep -q 'openaps ns-loop' || openaps ns-loop | tee -a /var/log/openaps/ns-loop.log") | crontab - + if [[ $ENABLE =~ autosens ]]; then + (crontab -l; crontab -l | grep -q "cd $directory && ps aux | grep -v grep | grep -q 'openaps autosens'" || echo "* * * * * cd $directory && ps aux | grep -v grep | grep -q 'openaps autosens' || openaps autosens | tee -a /var/log/openaps/autosens-loop.log") | crontab - + fi + if [[ $ENABLE =~ autotune ]]; then + # autotune nightly at 12:05am using data from NS + (crontab -l; crontab -l | grep -q "oref0-autotune -d=$directory -n=$NIGHTSCOUT_HOST" || echo "5 0 * * * oref0-ns-autotune -d=$directory -n=$NIGHTSCOUT_HOST && cp $directory/autotune/profile.json $directory/settings/autotune.json | tee -a /var/log/openaps/autotune.log") | crontab - + fi + if [[ "$ttyport" =~ "spi" ]]; then + (crontab -l; crontab -l | grep -q "reset_spi_serial.py" || echo "@reboot reset_spi_serial.py") | crontab - + fi + (crontab -l; crontab -l | grep -q "cd $directory && ( ps aux | grep -v grep | grep -q 'openaps pump-loop'" || echo "* * * * * cd $directory && ( ps aux | grep -v grep | grep -q 'openaps pump-loop' || openaps pump-loop ) 2>&1 | tee -a /var/log/openaps/pump-loop.log") | crontab - + crontab -l fi -(crontab -l; crontab -l | grep -q "cd $directory && ( ps aux | grep -v grep | grep -q 'openaps pump-loop'" || echo "* * * * * cd $directory && ( ps aux | grep -v grep | grep -q 'openaps pump-loop' || openaps pump-loop ) 2>&1 | tee -a /var/log/openaps/pump-loop.log") | crontab - -crontab -l if [[ ${CGM,,} =~ "shareble" ]]; then echo echo "To pair your G4 Share receiver, open its Setttings, select Share, Forget Device (if previously paired), then turn sharing On" fi -fi -fi +fi # from 'read -p "Continue? y/[N] " -r' after interactive setup is complete if [ -e /tmp/reboot-required ]; then read -p "Reboot required. Press enter to reboot or Ctrl-C to cancel" diff --git a/lib/oref0-setup/autotune.json b/lib/oref0-setup/autotune.json new file mode 100644 index 000000000..cd3c4ad45 --- /dev/null +++ b/lib/oref0-setup/autotune.json @@ -0,0 +1,43 @@ +[ + { + "settings/pumpprofile.json": { + "use": "shell", + "bg_targets": "settings/bg_targets.json", + "preferences": "preferences.json", + "settings": "settings/settings.json", + "basal_profile": "settings/basal_profile.json", + "reporter": "text", + "json_default": "True", + "carb_ratios": "settings/carb_ratios.json", + "device": "get-profile", + "remainder": "--model=settings/model.json", + "isf": "settings/insulin_sensitivities.json" + }, + "type": "report", + "name": "settings/pumpprofile.json" + }, + { + "settings/profile.json": { + "use": "shell", + "bg_targets": "settings/bg_targets.json", + "preferences": "preferences.json", + "settings": "settings/settings.json", + "basal_profile": "settings/basal_profile.json", + "reporter": "text", + "json_default": "True", + "carb_ratios": "settings/carb_ratios.json", + "device": "get-profile", + "remainder": "settings/temptargets.json --model=settings/model.json --autotune settings/autotune.json", + "isf": "settings/insulin_sensitivities.json" + }, + "type": "report", + "name": "settings/profile.json" + }, + { + "type": "alias", + "name": "get-settings", + "get-settings": { + "command": "report invoke settings/model.json settings/bg_targets_raw.json settings/bg_targets.json settings/insulin_sensitivities_raw.json settings/insulin_sensitivities.json settings/basal_profile.json settings/settings.json settings/carb_ratios.json settings/pumpprofile.json settings/profile.json" + } + } +] diff --git a/package.json b/package.json index 61445857e..78da9bbac 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,8 @@ "ns-upload": "./bin/ns-upload.sh", "ns-upload-entries": "./bin/ns-upload-entries.sh", "oref0": "./bin/oref0.sh", + "oref0-autotune-prep": "./bin/oref0-autotune-prep.js", + "oref0-autotune": "./bin/oref0-autotune.js", "oref0-calculate-iob": "./bin/oref0-calculate-iob.js", "oref0-copy-fresher": "./bin/oref0-copy-fresher", "oref0-crun": "./bin/oref0-conditional-run.sh", @@ -50,6 +52,7 @@ "oref0-meal": "./bin/oref0-meal.js", "oref0-mint-max-iob": "./bin/oref0-mint-max-iob.sh", "oref0-normalize-temps": "./bin/oref0-normalize-temps.js", + "oref0-ns-autotune": "./bin/oref0-ns-autotune.sh", "oref0-online": "./bin/oref0-online.sh", "oref0-pebble": "./bin/oref0-pebble.js", "oref0-raw": "./bin/oref0-raw.js", From 989a20456abb4be11700ab9324c616575e8c87c8 Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 2 Jan 2017 14:44:16 -0800 Subject: [PATCH 06/20] increment version number for autotune --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 61445857e..c2a41c241 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oref0", - "version": "0.3.4-dev", + "version": "0.3.5-dev", "description": "openaps oref0 reference implementation of the reference design", "scripts": { "test": "make test", From f529ed4d1ef3015600dbb34b3cde858fd39dc677 Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 2 Jan 2017 14:57:47 -0800 Subject: [PATCH 07/20] check if settings/autotune.json is valid json --- bin/oref0-ns-autotune.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/oref0-ns-autotune.sh b/bin/oref0-ns-autotune.sh index 67c913cce..444ae3d20 100755 --- a/bin/oref0-ns-autotune.sh +++ b/bin/oref0-ns-autotune.sh @@ -99,8 +99,8 @@ fi # Get profile for testing copied to home directory. "openaps" is my loop directory name. cd $directory && mkdir -p autotune cp settings/profile.json autotune/profile.pump.json -# If a previous settings/autotune.json exists, use that; otherwise start from settings/profile.json -cp settings/autotune.json autotune/profile.json || cp autotune/profile.pump.json autotune/profile.json +# If a previous valid settings/autotune.json exists, use that; otherwise start from settings/profile.json +cp settings/autotune.json autotune/profile.json && cat autotune/profile.json | json | grep start || cp autotune/profile.pump.json autotune/profile.json cd autotune # TODO: Need to think through what to remove in the autotune folder... @@ -145,10 +145,12 @@ do cp profile.json profile.$run_number.$i.json # Autotune Prep (required args, ), output prepped glucose # data or below + echo "~/src/oref0/bin/oref0-autotune-prep.js ns-treatments.json profile.json ns-entries.$i.json > autotune.$run_number.$i.json" ~/src/oref0/bin/oref0-autotune-prep.js ns-treatments.json profile.json ns-entries.$i.json > autotune.$run_number.$i.json # Autotune (required args, ), # output autotuned profile or what will be used as in the next iteration + echo "~/src/oref0/bin/oref0-autotune.js autotune.$run_number.$i.json profile.json profile.pump.json > newprofile.$run_number.$i.json" ~/src/oref0/bin/oref0-autotune.js autotune.$run_number.$i.json profile.json profile.pump.json > newprofile.$run_number.$i.json # Copy tuned profile produced by autotune to profile.json for use with next day of data From 0a1023dc627770ba23b4a0b3cc8ac44e94d11300 Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 2 Jan 2017 15:00:25 -0800 Subject: [PATCH 08/20] specify a default for radio_locale --- bin/oref0-setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index 8d0163466..06a185754 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -28,6 +28,7 @@ CGM="G4" DIR="" directory="" EXTRAS="" +radio_locale="US" for i in "$@" do From 4618457e3fb4691ac1b2f0cb7800818e7765caf9 Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 2 Jan 2017 15:06:57 -0800 Subject: [PATCH 09/20] remove set -e from oref0-setup --- bin/oref0-setup.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index 06a185754..8b366b8da 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -14,8 +14,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -# Exit when variables are unset or functions fail -set -eu +# Exit when functions fail +set -u die() { echo "$@" @@ -28,7 +28,6 @@ CGM="G4" DIR="" directory="" EXTRAS="" -radio_locale="US" for i in "$@" do From 2e9a098c4f6c492a5d291262a91d1385544aa91a Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 2 Jan 2017 15:12:22 -0800 Subject: [PATCH 10/20] require openaps 0.1.6 or higher for radio_locale --- bin/oref0-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index 8b366b8da..ed2e2c68e 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -355,7 +355,7 @@ elif [[ ${CGM,,} =~ "shareble" ]]; then # comment out existing line if it exists and isn't already commented out sed -i"" 's/^screen -S "brcm_patchram_plus" -d -m \/usr\/local\/sbin\/bluetooth_patchram.sh/# &/' /etc/rc.local echo Checking openaps dev installation - if ! openaps use cgm -h | grep -q nightscout_calibrations; then + if ! openaps --version | egrep "0.1.[6-9]"; then if [ -d "$HOME/src/openaps/" ]; then echo "$HOME/src/openaps/ already exists; pulling latest dev branch" (cd ~/src/openaps && git fetch && git checkout dev && git pull) || die "Couldn't pull latest openaps dev" From f700e08c19f93aaf811a296e0de7aedf80bd2c27 Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 2 Jan 2017 15:15:52 -0800 Subject: [PATCH 11/20] apparently set -u requires radio_locale to be set --- bin/oref0-setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index ed2e2c68e..3c032ba1d 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -28,6 +28,7 @@ CGM="G4" DIR="" directory="" EXTRAS="" +radio_locale="US" for i in "$@" do From 66c3145958a0354146e488c1375ba1b69a401dff Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 2 Jan 2017 15:22:12 -0800 Subject: [PATCH 12/20] radio_locale requires openaps 0.2.0-dev or later --- bin/oref0-setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index 3c032ba1d..0415428c7 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -356,7 +356,7 @@ elif [[ ${CGM,,} =~ "shareble" ]]; then # comment out existing line if it exists and isn't already commented out sed -i"" 's/^screen -S "brcm_patchram_plus" -d -m \/usr\/local\/sbin\/bluetooth_patchram.sh/# &/' /etc/rc.local echo Checking openaps dev installation - if ! openaps --version | egrep "0.1.[6-9]"; then + if ! openaps --version | egrep "0.[2-9].[0-9]"; then if [ -d "$HOME/src/openaps/" ]; then echo "$HOME/src/openaps/ already exists; pulling latest dev branch" (cd ~/src/openaps && git fetch && git checkout dev && git pull) || die "Couldn't pull latest openaps dev" @@ -452,7 +452,7 @@ if [[ -z "$ttyport" ]]; then openaps alias add wait-for-long-silence 'report invoke monitor/temp_basal.json' openaps alias add mmtune 'report invoke monitor/temp_basal.json' else - # radio_locale requires openaps 0.1.6-dev or later + # radio_locale requires openaps 0.2.0-dev or later openaps device add pump mmeowlink subg_rfspy $ttyport $serial $radio_locale || die "Can't add pump" openaps alias add wait-for-silence '! bash -c "(mmeowlink-any-pump-comms.py --port '$ttyport' --wait-for 1 | grep -q comms && echo -n Radio ok, || openaps mmtune) && echo -n \" Listening: \"; for i in $(seq 1 100); do echo -n .; mmeowlink-any-pump-comms.py --port '$ttyport' --wait-for 30 2>/dev/null | egrep -v subg | egrep No && break; done"' openaps alias add wait-for-long-silence '! bash -c "echo -n \"Listening: \"; for i in $(seq 1 200); do echo -n .; mmeowlink-any-pump-comms.py --port '$ttyport' --wait-for 45 2>/dev/null | egrep -v subg | egrep No && break; done"' From 588799d099dcd9cab2e11d51b16787d9c8e88da9 Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 2 Jan 2017 15:53:34 -0800 Subject: [PATCH 13/20] attempt to fix set -eu NIGHTSCOUT_DEBUG: unbound variable --- bin/ns-get.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ns-get.sh b/bin/ns-get.sh index d5ecedc45..c8e00d80c 100755 --- a/bin/ns-get.sh +++ b/bin/ns-get.sh @@ -13,8 +13,8 @@ OUTPUT=${4-/dev/fd/1} CURL_FLAGS="-g -s" NIGHTSCOUT_FORMAT=${NIGHTSCOUT_FORMAT-json} -test "$NIGHTSCOUT_DEBUG" = "1" && CURL_FLAGS="${CURL_FLAGS} -iv" -test "$NIGHTSCOUT_DEBUG" = "1" && set -x +if "$NIGHTSCOUT_DEBUG" = "1"; then CURL_FLAGS="${CURL_FLAGS} -iv"; fi +if "$NIGHTSCOUT_DEBUG" = "1"; then set -x; fi function usage ( ) { cat < Date: Mon, 2 Jan 2017 15:58:29 -0800 Subject: [PATCH 14/20] Revert "attempt to fix set -eu NIGHTSCOUT_DEBUG: unbound variable" This reverts commit 588799d099dcd9cab2e11d51b16787d9c8e88da9. --- bin/ns-get.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ns-get.sh b/bin/ns-get.sh index c8e00d80c..d5ecedc45 100755 --- a/bin/ns-get.sh +++ b/bin/ns-get.sh @@ -13,8 +13,8 @@ OUTPUT=${4-/dev/fd/1} CURL_FLAGS="-g -s" NIGHTSCOUT_FORMAT=${NIGHTSCOUT_FORMAT-json} -if "$NIGHTSCOUT_DEBUG" = "1"; then CURL_FLAGS="${CURL_FLAGS} -iv"; fi -if "$NIGHTSCOUT_DEBUG" = "1"; then set -x; fi +test "$NIGHTSCOUT_DEBUG" = "1" && CURL_FLAGS="${CURL_FLAGS} -iv" +test "$NIGHTSCOUT_DEBUG" = "1" && set -x function usage ( ) { cat < Date: Mon, 2 Jan 2017 16:01:07 -0800 Subject: [PATCH 15/20] set -eu incompatible with test "$NIGHTSCOUT_DEBUG" = "1" && --- bin/ns-get.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/bin/ns-get.sh b/bin/ns-get.sh index d5ecedc45..330662c2a 100755 --- a/bin/ns-get.sh +++ b/bin/ns-get.sh @@ -2,9 +2,6 @@ # Author: Ben West -# Exit when variables are unset or functions fail -set -eu - self=$(basename $0) REPORT=${1-entries.json} NIGHTSCOUT_HOST=${NIGHTSCOUT_HOST-${2-localhost:1337}} From fac3cb34e5b5c78626f0b9c02026f60cd5b81bb8 Mon Sep 17 00:00:00 2001 From: Scott Leibrand Date: Mon, 2 Jan 2017 18:12:28 -0600 Subject: [PATCH 16/20] Revert "Exit scripts when variables under or functions fail" --- bin/mm-format-ns-glucose.sh | 3 --- bin/mm-format-ns-profile.sh | 3 --- bin/mm-format-ns-pump-history.sh | 3 --- bin/mm-format-ns-treatments.sh | 3 --- bin/mm-format-oref0-glucose.sh | 3 --- bin/mm-stick.sh | 3 --- bin/nightscout.sh | 2 -- bin/ns-dedupe-treatments.sh | 3 --- bin/ns-get.sh | 3 --- bin/ns-upload-entries.sh | 3 --- bin/ns-upload.sh | 3 --- bin/oref0-conditional-run.sh | 5 +---- bin/oref0-copy-fresher | 4 ---- bin/oref0-fix-git-corruption.sh | 4 ---- bin/oref0-ifttt-notify | 3 --- bin/oref0-mint-max-iob.sh | 2 -- bin/oref0-reset-git.sh | 3 --- bin/oref0-reset-usb.sh | 3 --- bin/oref0-set-device-clocks.sh | 3 --- bin/oref0-set-system-clock.sh | 3 --- bin/oref0-setup.sh | 4 ---- bin/oref0-truncate-git-history.sh | 3 --- bin/oref0.sh | 2 -- 23 files changed, 1 insertion(+), 70 deletions(-) diff --git a/bin/mm-format-ns-glucose.sh b/bin/mm-format-ns-glucose.sh index 1b3211660..aa7a1b390 100755 --- a/bin/mm-format-ns-glucose.sh +++ b/bin/mm-format-ns-glucose.sh @@ -5,9 +5,6 @@ # Written for decocare v0.0.17. Will need updating the the decocare json format changes. -# Exit script when variables are unset or functions fail -set -eu - NSONLY="" test "$1" = "--oref0" && NSONLY="this.glucose = this.sgv" && shift diff --git a/bin/mm-format-ns-profile.sh b/bin/mm-format-ns-profile.sh index 3c64db3b5..718224ce6 100755 --- a/bin/mm-format-ns-profile.sh +++ b/bin/mm-format-ns-profile.sh @@ -2,9 +2,6 @@ # Author: Ben West -# Exit when variables are unset or functions fail -set -eu - self=$(basename $0) SETTINGS=${1-monitor/settings.json} CARBS=${2-monitor/carb-ratios.json} diff --git a/bin/mm-format-ns-pump-history.sh b/bin/mm-format-ns-pump-history.sh index aa5c2fe50..478561ee5 100755 --- a/bin/mm-format-ns-pump-history.sh +++ b/bin/mm-format-ns-pump-history.sh @@ -3,9 +3,6 @@ # Author: Ben West # Maintainer: Scott Leibrand -# Exit when variables are unset or functions fail -set -eu - self=$(basename $0) function usage ( ) { diff --git a/bin/mm-format-ns-treatments.sh b/bin/mm-format-ns-treatments.sh index c28bf36b1..ebc884627 100755 --- a/bin/mm-format-ns-treatments.sh +++ b/bin/mm-format-ns-treatments.sh @@ -2,9 +2,6 @@ # Author: Ben West -# Exit when variables are unset or functions fail -set -eu - HISTORY=${1-monitor/pump-history-zoned.json} MODEL=${2-model.json} OUTPUT=${3-/dev/fd/1} diff --git a/bin/mm-format-oref0-glucose.sh b/bin/mm-format-oref0-glucose.sh index 86c3edd5c..975a542a9 100755 --- a/bin/mm-format-oref0-glucose.sh +++ b/bin/mm-format-oref0-glucose.sh @@ -3,9 +3,6 @@ # Author: Ben West @bewest # Maintainer: @tghoward -# Exit when variables are unset or functions fail -set -eu - # Written for decocare v0.0.18. Will need updating the the decocare json format changes. self=$(basename $0) HISTORY=${1-glucosehistory.json} diff --git a/bin/mm-stick.sh b/bin/mm-stick.sh index 1b30eb4a1..afb6c9123 100755 --- a/bin/mm-stick.sh +++ b/bin/mm-stick.sh @@ -2,9 +2,6 @@ # Author: Ben West @bewest -# Exit when variables are unset or functions fail -set -eu - # Written for decocare v0.0.17. self=$(basename $0) OUTPUT=/dev/fd/1 diff --git a/bin/nightscout.sh b/bin/nightscout.sh index ce02f9fcb..5db9e62ca 100755 --- a/bin/nightscout.sh +++ b/bin/nightscout.sh @@ -1,7 +1,5 @@ #!/bin/bash -# Exit when variables are unset or functions fail -set -eu self=$(basename $0) NAME=${1-help} diff --git a/bin/ns-dedupe-treatments.sh b/bin/ns-dedupe-treatments.sh index 2acae8960..7785f39ea 100755 --- a/bin/ns-dedupe-treatments.sh +++ b/bin/ns-dedupe-treatments.sh @@ -1,8 +1,5 @@ #!/bin/bash -# Exit when variables are unset or functions fail -set -eu - self=$(basename $0) function usage ( ) { diff --git a/bin/ns-get.sh b/bin/ns-get.sh index d5ecedc45..330662c2a 100755 --- a/bin/ns-get.sh +++ b/bin/ns-get.sh @@ -2,9 +2,6 @@ # Author: Ben West -# Exit when variables are unset or functions fail -set -eu - self=$(basename $0) REPORT=${1-entries.json} NIGHTSCOUT_HOST=${NIGHTSCOUT_HOST-${2-localhost:1337}} diff --git a/bin/ns-upload-entries.sh b/bin/ns-upload-entries.sh index ac26d80aa..a60f8053f 100755 --- a/bin/ns-upload-entries.sh +++ b/bin/ns-upload-entries.sh @@ -1,8 +1,5 @@ #!/bin/bash -# Exit when variables are unset or functions fail -set -eu - # Author: Ben West # Maintainer: @cjo20, @scottleibrand diff --git a/bin/ns-upload.sh b/bin/ns-upload.sh index 8d1c6bd61..5df63d052 100755 --- a/bin/ns-upload.sh +++ b/bin/ns-upload.sh @@ -2,9 +2,6 @@ # Author: Ben West -# Exit when variables are unset or functions fail -set -eu - self=$(basename $0) NIGHTSCOUT_HOST=${NIGHTSCOUT_HOST-${1-localhost:1337}} API_SECRET=${2-${API_SECRET}} diff --git a/bin/oref0-conditional-run.sh b/bin/oref0-conditional-run.sh index f9397e46e..b448b2df6 100755 --- a/bin/oref0-conditional-run.sh +++ b/bin/oref0-conditional-run.sh @@ -1,8 +1,5 @@ #!/bin/bash -# Exit when variables are unset or functions fail -set -eu - export GENERATE=false export FILE=$1 export FILE2=$2 @@ -38,4 +35,4 @@ if [ "$GENERATE" = true ]; then fi else echo "$FILE exists and is new, skipping invoke" -fi +fi \ No newline at end of file diff --git a/bin/oref0-copy-fresher b/bin/oref0-copy-fresher index 10d71d75c..4d9f12081 100755 --- a/bin/oref0-copy-fresher +++ b/bin/oref0-copy-fresher @@ -1,8 +1,4 @@ #!/bin/bash - -# Exit when variables are unset or functions fail -set -eu - self=$(basename $0) WITHIN=0 diff --git a/bin/oref0-fix-git-corruption.sh b/bin/oref0-fix-git-corruption.sh index 85149ecfd..715bf730c 100755 --- a/bin/oref0-fix-git-corruption.sh +++ b/bin/oref0-fix-git-corruption.sh @@ -4,10 +4,6 @@ # Author: Ben West # # - -# Exit when variables are unset or functions fail -set -eu - < Date: Mon, 2 Jan 2017 16:18:11 -0800 Subject: [PATCH 17/20] grep quietly --- bin/oref0-ns-autotune.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/oref0-ns-autotune.sh b/bin/oref0-ns-autotune.sh index 444ae3d20..9622e0c1b 100755 --- a/bin/oref0-ns-autotune.sh +++ b/bin/oref0-ns-autotune.sh @@ -100,7 +100,7 @@ fi cd $directory && mkdir -p autotune cp settings/profile.json autotune/profile.pump.json # If a previous valid settings/autotune.json exists, use that; otherwise start from settings/profile.json -cp settings/autotune.json autotune/profile.json && cat autotune/profile.json | json | grep start || cp autotune/profile.pump.json autotune/profile.json +cp settings/autotune.json autotune/profile.json && cat autotune/profile.json | json | grep -q start || cp autotune/profile.pump.json autotune/profile.json cd autotune # TODO: Need to think through what to remove in the autotune folder... From 3d954f78faf7ec295f39b4ebde5a387bd7315494 Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 2 Jan 2017 16:22:36 -0800 Subject: [PATCH 18/20] redirect oref0-ns-autotune stderr to log file --- bin/oref0-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index ecc05665f..10136b6f3 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -575,7 +575,7 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then fi if [[ $ENABLE =~ autotune ]]; then # autotune nightly at 12:05am using data from NS - (crontab -l; crontab -l | grep -q "oref0-autotune -d=$directory -n=$NIGHTSCOUT_HOST" || echo "5 0 * * * oref0-ns-autotune -d=$directory -n=$NIGHTSCOUT_HOST && cp $directory/autotune/profile.json $directory/settings/autotune.json | tee -a /var/log/openaps/autotune.log") | crontab - + (crontab -l; crontab -l | grep -q "oref0-autotune -d=$directory -n=$NIGHTSCOUT_HOST" || echo "5 0 * * * ( oref0-ns-autotune -d=$directory -n=$NIGHTSCOUT_HOST && cp $directory/autotune/profile.json $directory/settings/autotune.json) 2>&1 | tee -a /var/log/openaps/autotune.log") | crontab - fi if [[ "$ttyport" =~ "spi" ]]; then (crontab -l; crontab -l | grep -q "reset_spi_serial.py" || echo "@reboot reset_spi_serial.py") | crontab - From d6da295649f3e34535d60f8a3b91e659198ba81b Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 2 Jan 2017 16:44:27 -0800 Subject: [PATCH 19/20] update script name in usage --- bin/oref0-ns-autotune.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/oref0-ns-autotune.sh b/bin/oref0-ns-autotune.sh index 9622e0c1b..3ee637322 100755 --- a/bin/oref0-ns-autotune.sh +++ b/bin/oref0-ns-autotune.sh @@ -75,7 +75,7 @@ esac done if [[ -z "$DIR" || -z "$NIGHTSCOUT_HOST" ]]; then - echo "Usage: oref0-autotune-test.sh <--dir=openaps_directory> <--ns-host=https://mynightscout.azurewebsites.net> [--start-date=YYYY-MM-DD] [--runs=number_of_runs] [--end-date=YYYY-MM-DD]" + echo "Usage: oref0-ns-autotune <--dir=openaps_directory> <--ns-host=https://mynightscout.azurewebsites.net> [--start-date=YYYY-MM-DD] [--runs=number_of_runs] [--end-date=YYYY-MM-DD]" exit 1 fi if [[ -z "$START_DATE" ]]; then From 7e5537a139c14db515a412547739fe39d26574ec Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 2 Jan 2017 16:46:40 -0800 Subject: [PATCH 20/20] use settings/pumpprofile.json in oref0-ns-autotune --- bin/oref0-ns-autotune.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/oref0-ns-autotune.sh b/bin/oref0-ns-autotune.sh index 3ee637322..34d085230 100755 --- a/bin/oref0-ns-autotune.sh +++ b/bin/oref0-ns-autotune.sh @@ -98,7 +98,7 @@ fi # Get profile for testing copied to home directory. "openaps" is my loop directory name. cd $directory && mkdir -p autotune -cp settings/profile.json autotune/profile.pump.json +cp settings/pumpprofile.json autotune/profile.pump.json # If a previous valid settings/autotune.json exists, use that; otherwise start from settings/profile.json cp settings/autotune.json autotune/profile.json && cat autotune/profile.json | json | grep -q start || cp autotune/profile.pump.json autotune/profile.json cd autotune