From f35b4ffc1c0b52a1b650a752352b2d58a979beb6 Mon Sep 17 00:00:00 2001 From: Dave Acklam Date: Sat, 18 Jun 2022 19:29:34 -0700 Subject: [PATCH 01/38] Support for Debian Bullseye and aarch64 (Raspberry Pi OS/Bullseye 64 Bit) in setup routines (#1429) * Remove redundant pip install for bullseye support pIp is also installed by openaps-packages.sh * Change python default to python2, install pip, pip install numpy for bullseye support * Bullseye support on arm64 (Raspberry Pi OS 64bit) Handle aarch64 architecture properly when downloading golang binaries. Without this setup will fail on Rpi 3/4/Zero2 devices where the user has installed the recently-released 64bit OS. Co-authored-by: Dave Acklam --- bin/openaps-install.sh | 2 +- bin/openaps-packages.sh | 11 ++++++++++- bin/oref0-setup.sh | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/openaps-install.sh b/bin/openaps-install.sh index 9395ab992..3e0265215 100755 --- a/bin/openaps-install.sh +++ b/bin/openaps-install.sh @@ -55,7 +55,7 @@ fi #dpkg -P nodejs nodejs-dev # TODO: remove the `-o Acquire::ForceIPv4=true` once Debian's mirrors work reliably over IPv6 apt-get -o Acquire::ForceIPv4=true update && apt-get -o Acquire::ForceIPv4=true -y dist-upgrade && apt-get -o Acquire::ForceIPv4=true -y autoremove -apt-get -o Acquire::ForceIPv4=true update && apt-get -o Acquire::ForceIPv4=true install -y sudo strace tcpdump screen acpid vim python-pip locate ntpdate ntp +apt-get -o Acquire::ForceIPv4=true update && apt-get -o Acquire::ForceIPv4=true install -y sudo strace tcpdump screen acpid vim locate ntpdate ntp #check if edison user exists before trying to add it to groups grep "PermitRootLogin yes" /etc/ssh/sshd_config || echo "PermitRootLogin yes" >>/etc/ssh/sshd_config diff --git a/bin/openaps-packages.sh b/bin/openaps-packages.sh index 401b783e7..996c3c194 100755 --- a/bin/openaps-packages.sh +++ b/bin/openaps-packages.sh @@ -10,7 +10,16 @@ echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4 apt-get install -y sudo sudo apt-get update && sudo apt-get -y upgrade -sudo apt-get install -y git python python-dev software-properties-common python-numpy python-pip watchdog strace tcpdump screen acpid vim locate lm-sensors || die "Couldn't install packages" +## Debian Bullseye (Raspberry Pi OS 64bit, etc) is python3 by default and does not support python2-pip. +if ! cat /etc/os-release | grep bullseye >& /dev/null; then + sudo apt-get install -y git python python-dev software-properties-common python-numpy python-pip watchdog strace tcpdump screen acpid vim locate lm-sensors || die "Couldn't install packages" +else + # Bullseye based OS. Get PIP2 from pypa and pip-install python packages rather than using the py3 ones from apt + # Also, install python-is-python2, to override the distro default of linking python to python3 + sudo apt-get install -y git python-is-python2 python-dev-is-python2 software-properties-common watchdog strace tcpdump screen acpid vim locate lm-sensors || die "Couldn't install packages" + curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | python2 || die "Couldn't install pip" + python2 -m pip install numpy || die "Couldn't pip install numpy" +fi # We require jq >= 1.5 for --slurpfile for merging preferences. Debian Jessie ships with 1.4. if cat /etc/os-release | grep 'PRETTY_NAME="Debian GNU/Linux 8 (jessie)"' &> /dev/null; then diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index 47eea3f38..b545bef69 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -1200,6 +1200,8 @@ if prompt_yn "" N; then echo "Installing Golang..." if uname -m | grep armv; then cd /tmp && wget -c https://storage.googleapis.com/golang/go${golangversion}.linux-armv6l.tar.gz && tar -C /usr/local -xzvf /tmp/go${golangversion}.linux-armv6l.tar.gz + elif uname -m | grep aarch64; then + cd /tmp && wget -c https://storage.googleapis.com/golang/go${golangversion}.linux-arm64.tar.gz && tar -C /usr/local -xzvf /tmp/go${golangversion}.linux-arm64.tar.gz elif uname -m | grep i686; then cd /tmp && wget -c https://dl.google.com/go/go${golangversion}.linux-386.tar.gz && tar -C /usr/local -xzvf /tmp/go${golangversion}.linux-386.tar.gz fi From 7d539911d084b5676b18c1e2e1503d2c3b4b1d33 Mon Sep 17 00:00:00 2001 From: Robert Date: Sun, 19 Jun 2022 04:41:09 +0200 Subject: [PATCH 02/38] omit string formating in convert_bg (#1414) fixes #1413 --- lib/determine-basal/determine-basal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/determine-basal/determine-basal.js b/lib/determine-basal/determine-basal.js index a599fc8c6..74fa25b76 100644 --- a/lib/determine-basal/determine-basal.js +++ b/lib/determine-basal/determine-basal.js @@ -40,7 +40,7 @@ function convert_bg(value, profile) { if (profile.out_units === "mmol/L") { - return round(value / 18, 1).toFixed(1); + return round(value / 18, 1); } else { From 8881c7f65a5cb15f94837a288e792cefd66408ef Mon Sep 17 00:00:00 2001 From: Chance Harrison Date: Fri, 9 Sep 2022 23:40:47 -0700 Subject: [PATCH 03/38] Improved handling of node installation (& miscellaneous improvements) (#1419) * fix: Remove edison nodesource installation * fix: npm upgrade to latest *compatible* version, not the literal latest The previous command (which installs npm@latest) results in the installation of a version of npm which is almost certainly incompatible with the installed (regardless of source) version of nodejs * fix: Use n instead of apt for installing node & npm * fix: Improve node execution time check function - Remove what should be a redundant install, instead opt to fail if node is missing. Given that openaps-packages.sh handles installing node, this failing check indicates an unmitigated failure in the process previously, so let's not continue and make things potentially worse. - Attempt to remove existing nodejs/npm packages using apt - Warn the user if versions of node and npm remain - Switch nvm for n, using installed version of n if available Else, bootstrap install n as done elsewhere. * fix: Replace broken grep statements --- bin/openaps-install.sh | 7 ----- bin/openaps-packages.sh | 24 +++++++++-------- bin/oref0-setup.sh | 59 +++++++++++++++++++++++++++-------------- 3 files changed, 52 insertions(+), 38 deletions(-) diff --git a/bin/openaps-install.sh b/bin/openaps-install.sh index 3e0265215..d9ac627f6 100755 --- a/bin/openaps-install.sh +++ b/bin/openaps-install.sh @@ -46,13 +46,6 @@ if cat /etc/os-release | grep 'PRETTY_NAME="Debian GNU/Linux 8 (jessie)"' &> /de echo "Jubilinux 0.2.0, based on Debian Jessie, is no longer receiving security or software updates!" fi -#Workaround for Jubilinux to install nodejs/npm from nodesource -if getent passwd edison &> /dev/null; then - #Use nodesource setup script to add nodesource repository to sources.list.d - curl -sL https://deb.nodesource.com/setup_8.x | bash - -fi - -#dpkg -P nodejs nodejs-dev # TODO: remove the `-o Acquire::ForceIPv4=true` once Debian's mirrors work reliably over IPv6 apt-get -o Acquire::ForceIPv4=true update && apt-get -o Acquire::ForceIPv4=true -y dist-upgrade && apt-get -o Acquire::ForceIPv4=true -y autoremove apt-get -o Acquire::ForceIPv4=true update && apt-get -o Acquire::ForceIPv4=true install -y sudo strace tcpdump screen acpid vim locate ntpdate ntp diff --git a/bin/openaps-packages.sh b/bin/openaps-packages.sh index 996c3c194..0fdb15242 100755 --- a/bin/openaps-packages.sh +++ b/bin/openaps-packages.sh @@ -30,18 +30,20 @@ else sudo apt-get -y install jq || die "Couldn't install jq" fi -# Install/upgrade to latest version of node (v10) using apt if neither node 8 nor node 10+ LTS are installed -if ! nodejs --version | grep -e 'v8\.' -e 'v1[02468]\.' &> /dev/null ; then - if getent passwd edison; then - # Only on the Edison, use nodesource setup script to add nodesource repository to sources.list.d, then install nodejs (npm is a part of the package) - curl -sL https://deb.nodesource.com/setup_8.x | bash - - sudo apt-get install -y nodejs=8.* || die "Couldn't install nodejs" - else - sudo apt-get install -y nodejs npm || die "Couldn't install nodejs and npm" - fi +# Install node using n if there is not an installed version of node >=8,<=19 +# Edge case: This is not likely to work as expected if there *is* a version of node installed, but it is outside of the specified version constraints +if ! node --version | grep -q -e 'v[89]\.' -e 'v1[[:digit:]]\.'; then + echo "Installing node via n..." # For context why we don't install using apt or nvm, see https://github.com/openaps/oref0/pull/1419 + curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n + # Install the latest compatible version of node + sudo bash n current + # Delete the local n binary used to boostrap the install + rm n + # Install n globally + sudo npm install -g n - # Upgrade npm to the latest version using its self-updater - sudo npm install npm@latest -g || die "Couldn't update npm" + # Upgrade to the latest supported version of npm for the current node version + sudo npm upgrade -g npm|| die "Couldn't update npm" ## You may also need development tools to build native addons: ## sudo apt-get install gcc g++ make diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index b545bef69..baa928fb0 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -292,14 +292,11 @@ function move_mmtune () { fi } -function install_or_upgrade_nodejs () { - # install/upgrade to latest node 8 if neither node 8 nor node 10+ LTS are installed - if ! nodejs --version | grep -e 'v8\.' -e 'v1[02468]\.' >/dev/null; then - echo Installing node 8 - # Use nodesource setup script to add nodesource repository to sources.list.d - sudo bash -c "curl -sL https://deb.nodesource.com/setup_8.x | bash -" || die "Couldn't setup node 8" - # Install nodejs and npm from nodesource - sudo apt-get install -y nodejs=8.* || die "Couldn't install nodejs" +function check_nodejs_timing () { + # Redundant check that node is installed + # It is installed as part of openaps-packages.sh + if ! node --version | grep -q -e 'v[89]\.' -e 'v1[[:digit:]]\.'; then + die "No version of node (>=8,<=19) was found, which is an unexpected error (node installation should have been handled by previous installation steps)" fi # Check that the nodejs you have installed is not broken. In particular, we're @@ -314,17 +311,39 @@ function install_or_upgrade_nodejs () { echo "Your installed nodejs ($(node --version)) is very slow to start (took ${NODE_EXECUTION_TIME}s)" echo "This is a known problem with certain versions of Raspberry Pi OS." - if prompt_yn "Install a new nodejs version using nvm?" Y; then - echo "Installing nvm and using it to replace the system-provided nodejs" - - # Download nvm - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash - # Run nvm, adding its aliases to this shell - source ~/.nvm/nvm.sh - # Use nvm to install nodejs - nvm install 10.24.1 - # Symlink node into /usr/local/bin, where it will shadow /usr/bin/node - ln -s ~/.nvm/versions/node/v10.24.1/bin/node /usr/local/bin/node + if prompt_yn "Confirm installation of replacement nodejs/npm versions?" Y; then + echo "Attempting to uninstall current nodejs/npm versions (apt-get remove)" + sudo apt-get -y remove nodejs npm + if [[ -n $NVM_DIR ]]; then + echo "Removing nvm ($NVM_DIR)..." + echo "(you may wish to optionally remove the nvm-related lines that still exist in ~/.bashrc; this script won't do it for you)" + rm -rf "$NVM_DIR" + fi + + # Check that there node and npm are no longer available. If they are, warn the user. + nodePath=$(command -v node) + npmPath=$(command -v npm) + if [[ -e "$nodePath" ]]; then + echo "Note: A 'node' binary (located at '$nodePath') still exists and may interfere with the new installation of node" + fi + if [[ -e "$npmPath" ]]; then + echo "Note: A 'npm' binary (located at '$npmPath') still exists and may interfere with the new installation of npm" + fi + + if [[ ! $(command -v n) ]]; then + echo "n already exists on the system, using it to install a new version of node..." + sudo n current + else + echo "Installing n and using it to replace the system-provided nodejs" + echo "Installing node via n..." + curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n + # Install the latest version of node that is supported on this platform + sudo bash n current + # Delete the local n binary used to boostrap the install + rm n + # Install n globally + sudo npm install -g n + fi NEW_NODE_EXECUTION_TIME="$(\time --format %e node -e 'true' 2>&1)" echo "New nodejs took ${NEW_NODE_EXECUTION_TIME}s to start" @@ -730,7 +749,7 @@ if prompt_yn "" N; then echo Running apt-get autoclean sudo apt-get autoclean - install_or_upgrade_nodejs + check_nodejs_timing # Attempting to remove git to make install --nogit by default for existing users echo Removing any existing git in $directory/.git From 21620183a582c395bd2255a0458684b9a93a6651 Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 10 Sep 2022 12:23:06 -0700 Subject: [PATCH 04/38] TODO: revert before release; use dev/bin/openaps-packages.sh --- bin/openaps-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/openaps-install.sh b/bin/openaps-install.sh index d9ac627f6..0405aad23 100755 --- a/bin/openaps-install.sh +++ b/bin/openaps-install.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -BRANCH=${1:-master} +BRANCH=${1:-dev} read -p "Enter your rig's new hostname (this will be your rig's "name" in the future, so make sure to write it down): " -r myrighostname=$REPLY echo $myrighostname > /etc/hostname From 3a730eddf86432a95fb1385e327b5ec10f13c9ec Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 10 Sep 2022 14:19:30 -0700 Subject: [PATCH 05/38] check out the specified branch when cloning --- bin/openaps-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/openaps-install.sh b/bin/openaps-install.sh index 0405aad23..0e77d85d8 100755 --- a/bin/openaps-install.sh +++ b/bin/openaps-install.sh @@ -66,7 +66,7 @@ sed -i "s/daily/hourly/g" /etc/logrotate.conf sed -i "s/#compress/compress/g" /etc/logrotate.conf curl -s https://raw.githubusercontent.com/openaps/oref0/$BRANCH/bin/openaps-packages.sh | bash - -mkdir -p ~/src; cd ~/src && ls -d oref0 && (cd oref0 && git checkout $BRANCH && git pull) || git clone https://github.com/openaps/oref0.git +mkdir -p ~/src; cd ~/src && ls -d oref0 && (cd oref0 && git checkout $BRANCH && git pull) || git clone https://github.com/openaps/oref0.git -b $BRANCH echo "Press Enter to run oref0-setup with the current release ($BRANCH branch) of oref0," read -p "or press ctrl-c to cancel. " -r cd && ~/src/oref0/bin/oref0-setup.sh From a8ec51c0a2efd3b6ff853c8d1d02296df3aa21b1 Mon Sep 17 00:00:00 2001 From: Scott Date: Sun, 11 Sep 2022 13:52:46 -0700 Subject: [PATCH 06/38] use golangversion=1.19.1 and go install to fix #1435 --- bin/oref0-setup.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index baa928fb0..54e9c0d49 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -288,7 +288,7 @@ function move_mmtune () { if [ -f /usr/local/bin/mmtune ]; then mv /usr/local/bin/mmtune /usr/local/bin/Go-mmtune || die "Couldn't move mmtune to Go-mmtune" else - die "Couldn't move_mmtune() because /usr/local/bin/mmtune exists" + echo "Couldn't move_mmtune() because /usr/local/bin/mmtune exists" fi } @@ -815,11 +815,11 @@ if prompt_yn "" N; then echo Checking oref0 installation cd $HOME/src/oref0 if git branch | grep "* master"; then - npm list -g --depth=0 | egrep oref0@0.6.[0] || (echo Installing latest oref0 package && sudo npm install -g oref0) + npm list -g --depth=0 | egrep oref0@0.7.[0] || (echo Installing latest oref0 package && sudo npm install -g oref0) elif [[ ${npm_option,,} == "force" ]]; then echo Forcing install of latest oref0 from $HOME/src/oref0/ && cd $HOME/src/oref0/ && npm run global-install else - npm list -g --depth=0 | egrep oref0@0.6.[1-9] || (echo Installing latest oref0 from $HOME/src/oref0/ && cd $HOME/src/oref0/ && npm run global-install) + npm list -g --depth=0 | egrep oref0@0.7.[1-9] || (echo Installing latest oref0 from $HOME/src/oref0/ && cd $HOME/src/oref0/ && npm run global-install) fi cd $directory || die "Can't cd $directory" @@ -1210,7 +1210,7 @@ if prompt_yn "" N; then # Install Golang mkdir -p $HOME/go source $HOME/.bash_profile - golangversion=1.12.5 + golangversion=1.19.1 if go version | grep go${golangversion}.; then echo Go already installed else @@ -1267,7 +1267,9 @@ if prompt_yn "" N; then esac #Build Go binaries - go get -u -v -tags "$radiotags" github.com/ecc1/medtronic/... || die "Couldn't go get medtronic" + #go get -u -v -tags "$radiotags" github.com/ecc1/medtronic/... || die "Couldn't go get medtronic" + go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/mdt@latest || die "Couldn't go get medtronic mdt" + go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/pumphistory@latest || die "Couldn't go get medtronic mdt" ln -sf $HOME/go/src/github.com/ecc1/medtronic/cmd/pumphistory/openaps.jq $directory/ || die "Couldn't softlink openaps.jq" else #TODO: write validate_ttyport and support non-SPI ports From 84f10113e8a87c7abc60cc34ba2bcc6c61e8441e Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 17 Sep 2022 22:30:39 -0700 Subject: [PATCH 07/38] symlink Go-mmtune to point to oref0-mmtune --- bin/oref0-setup.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index 54e9c0d49..12dfc2b0a 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -285,10 +285,8 @@ function copy_go_binaries () { function move_mmtune () { request_stop_local_binary Go-mmtune - if [ -f /usr/local/bin/mmtune ]; then - mv /usr/local/bin/mmtune /usr/local/bin/Go-mmtune || die "Couldn't move mmtune to Go-mmtune" - else - echo "Couldn't move_mmtune() because /usr/local/bin/mmtune exists" + if [ -f /usr/local/bin/oref0-mmtune ]; then + ln -s /usr/local/bin/oref0-mmtune /usr/local/bin/Go-mmtune || die "Couldn't symlink oref0-mmtune to Go-mmtune" fi } From 151b1abe75aa9ea457d13c4ca3f851c5bca643da Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 17 Sep 2022 22:58:54 -0700 Subject: [PATCH 08/38] Revert "symlink Go-mmtune to point to oref0-mmtune" This reverts commit 84f10113e8a87c7abc60cc34ba2bcc6c61e8441e. --- bin/oref0-setup.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index 12dfc2b0a..54e9c0d49 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -285,8 +285,10 @@ function copy_go_binaries () { function move_mmtune () { request_stop_local_binary Go-mmtune - if [ -f /usr/local/bin/oref0-mmtune ]; then - ln -s /usr/local/bin/oref0-mmtune /usr/local/bin/Go-mmtune || die "Couldn't symlink oref0-mmtune to Go-mmtune" + if [ -f /usr/local/bin/mmtune ]; then + mv /usr/local/bin/mmtune /usr/local/bin/Go-mmtune || die "Couldn't move mmtune to Go-mmtune" + else + echo "Couldn't move_mmtune() because /usr/local/bin/mmtune exists" fi } From 9c20dc60349e05050ed48d91f1649e3434c2809f Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 17 Sep 2022 23:04:06 -0700 Subject: [PATCH 09/38] install mmtune --- bin/oref0-setup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index 54e9c0d49..677753187 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -1269,7 +1269,8 @@ if prompt_yn "" N; then #Build Go binaries #go get -u -v -tags "$radiotags" github.com/ecc1/medtronic/... || die "Couldn't go get medtronic" go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/mdt@latest || die "Couldn't go get medtronic mdt" - go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/pumphistory@latest || die "Couldn't go get medtronic mdt" + go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/mmtune@latest || die "Couldn't go get medtronic mmtune" + go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/pumphistory@latest || die "Couldn't go get medtronic pumphistory" ln -sf $HOME/go/src/github.com/ecc1/medtronic/cmd/pumphistory/openaps.jq $directory/ || die "Couldn't softlink openaps.jq" else #TODO: write validate_ttyport and support non-SPI ports From e35480718ed1a25121958dbae3626bd1dca4ce45 Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 17 Sep 2022 23:08:28 -0700 Subject: [PATCH 10/38] symlink /usr/local/bin/Go-mmtune to point to /root/go/bin/mmtune --- bin/oref0-setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index 677753187..4fb0e587f 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -285,10 +285,10 @@ function copy_go_binaries () { function move_mmtune () { request_stop_local_binary Go-mmtune - if [ -f /usr/local/bin/mmtune ]; then - mv /usr/local/bin/mmtune /usr/local/bin/Go-mmtune || die "Couldn't move mmtune to Go-mmtune" + if [ -f /root/go/bin/mmtune ]; then + ln -s /root/go/bin/mmtune /usr/local/bin/Go-mmtune || die "Couldn't move mmtune to Go-mmtune" else - echo "Couldn't move_mmtune() because /usr/local/bin/mmtune exists" + echo "Couldn't move_mmtune()" fi } From 399e3d6113c83f86b5a6cfedb41e6f1f010d3fb0 Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 17 Sep 2022 23:28:58 -0700 Subject: [PATCH 11/38] have to go install each medtronic command individually --- bin/oref0-setup.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index 4fb0e587f..d77afabe1 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -1271,6 +1271,10 @@ if prompt_yn "" N; then go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/mdt@latest || die "Couldn't go get medtronic mdt" go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/mmtune@latest || die "Couldn't go get medtronic mmtune" go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/pumphistory@latest || die "Couldn't go get medtronic pumphistory" + go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/fakemeter@latest || die "Couldn't go get medtronic fakemeter" + go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/setbasals@latest || die "Couldn't go get medtronic setbasals" + go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/listen@latest || die "Couldn't go get medtronic listen" + go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/sniff@latest || die "Couldn't go get medtronic sniff" ln -sf $HOME/go/src/github.com/ecc1/medtronic/cmd/pumphistory/openaps.jq $directory/ || die "Couldn't softlink openaps.jq" else #TODO: write validate_ttyport and support non-SPI ports From fdb2a16742bee03fe5457b39d97b76850cf12430 Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 17 Sep 2022 23:35:12 -0700 Subject: [PATCH 12/38] go install puts things in /root/go/bin/ --- 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 d77afabe1..4a99f941e 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -1234,7 +1234,7 @@ if prompt_yn "" N; then sed --in-place '/.*GOPATH*/d' $HOME/.bash_profile echo 'GOPATH=$HOME/go' >> $HOME/.bash_profile echo 'export GOPATH' >> $HOME/.bash_profile - echo 'PATH=$PATH:/usr/local/go/bin:$GOROOT/bin:$GOPATH/bin' >> $HOME/.bash_profile + echo 'PATH=$PATH:/usr/local/go/bin:$GOROOT/bin:$GOPATH/bin:/root/go/bin/' >> $HOME/.bash_profile sed --in-place '/.*export PATH*/d' $HOME/.bash_profile echo 'export PATH' >> $HOME/.bash_profile fi From d08c86fd2191ce783e32656efdcded17a3d0df9f Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 17 Sep 2022 23:47:21 -0700 Subject: [PATCH 13/38] have to comment out if clause if it has no uncommented contents --- bin/oref0-cron-every-minute.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/oref0-cron-every-minute.sh b/bin/oref0-cron-every-minute.sh index f84f79e52..843d5d801 100755 --- a/bin/oref0-cron-every-minute.sh +++ b/bin/oref0-cron-every-minute.sh @@ -128,9 +128,9 @@ if [[ ! -z "$BT_PEB" || ! -z "$BT_MAC" ]]; then fi fi -if [[ ! -z "$PUSHOVER_TOKEN" && ! -z "$PUSHOVER_USER" ]]; then +#if [[ ! -z "$PUSHOVER_TOKEN" && ! -z "$PUSHOVER_USER" ]]; then #oref0-pushover $PUSHOVER_TOKEN $PUSHOVER_USER 2>&1 >> /var/log/openaps/pushover.log & -fi +#fi # if disk has less than 10MB free, delete something and logrotate cd /var/log/openaps/ && df . | awk '($4 < 10000) {print $4}' | while read line; do From f6ac4514cae8055605abc757a3ce086c430a8526 Mon Sep 17 00:00:00 2001 From: Scott Date: Sun, 18 Sep 2022 00:34:30 -0700 Subject: [PATCH 14/38] use ... to install all medtronic commands --- bin/oref0-setup.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index 4a99f941e..c871e0936 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -1268,13 +1268,7 @@ if prompt_yn "" N; then #Build Go binaries #go get -u -v -tags "$radiotags" github.com/ecc1/medtronic/... || die "Couldn't go get medtronic" - go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/mdt@latest || die "Couldn't go get medtronic mdt" - go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/mmtune@latest || die "Couldn't go get medtronic mmtune" - go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/pumphistory@latest || die "Couldn't go get medtronic pumphistory" - go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/fakemeter@latest || die "Couldn't go get medtronic fakemeter" - go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/setbasals@latest || die "Couldn't go get medtronic setbasals" - go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/listen@latest || die "Couldn't go get medtronic listen" - go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/sniff@latest || die "Couldn't go get medtronic sniff" + go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/...@latest || die "Couldn't go get medtronic" ln -sf $HOME/go/src/github.com/ecc1/medtronic/cmd/pumphistory/openaps.jq $directory/ || die "Couldn't softlink openaps.jq" else #TODO: write validate_ttyport and support non-SPI ports From 4248d6877ec74f4254c2ed404a1df120eb367efc Mon Sep 17 00:00:00 2001 From: Scott Date: Sun, 18 Sep 2022 00:44:46 -0700 Subject: [PATCH 15/38] don't die if Go-mmtune symlink already exists --- 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 c871e0936..0ad3650eb 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -286,7 +286,7 @@ function copy_go_binaries () { function move_mmtune () { request_stop_local_binary Go-mmtune if [ -f /root/go/bin/mmtune ]; then - ln -s /root/go/bin/mmtune /usr/local/bin/Go-mmtune || die "Couldn't move mmtune to Go-mmtune" + ln -s /root/go/bin/mmtune /usr/local/bin/Go-mmtune else echo "Couldn't move_mmtune()" fi From 12d6024c2e55122ea6e9fd205157108088bf0c3c Mon Sep 17 00:00:00 2001 From: Scott Date: Sun, 18 Sep 2022 01:28:56 -0700 Subject: [PATCH 16/38] fix path to openaps.jq --- 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 0ad3650eb..08ace406f 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -1269,7 +1269,7 @@ if prompt_yn "" N; then #Build Go binaries #go get -u -v -tags "$radiotags" github.com/ecc1/medtronic/... || die "Couldn't go get medtronic" go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/...@latest || die "Couldn't go get medtronic" - ln -sf $HOME/go/src/github.com/ecc1/medtronic/cmd/pumphistory/openaps.jq $directory/ || die "Couldn't softlink openaps.jq" + ln -sf /root/go/pkg/mod/github.com/ecc1/medtronic@v0.0.0-20210712211734-b8431dc5211b/cmd/pumphistory/openaps.jq $directory/ || die "Couldn't softlink openaps.jq" else #TODO: write validate_ttyport and support non-SPI ports die "Unsupported ttyport. Exiting." From 7c85d3237335f639ae2d5157c2c713794facb07b Mon Sep 17 00:00:00 2001 From: Scott Date: Sun, 18 Sep 2022 22:05:09 -0700 Subject: [PATCH 17/38] wget openaps.jq instead of symlinking to the 20210712211734 version --- bin/oref0-setup.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index 08ace406f..1c098cd8c 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -1269,7 +1269,12 @@ if prompt_yn "" N; then #Build Go binaries #go get -u -v -tags "$radiotags" github.com/ecc1/medtronic/... || die "Couldn't go get medtronic" go install -v -tags "$radiotags" github.com/ecc1/medtronic/cmd/...@latest || die "Couldn't go get medtronic" - ln -sf /root/go/pkg/mod/github.com/ecc1/medtronic@v0.0.0-20210712211734-b8431dc5211b/cmd/pumphistory/openaps.jq $directory/ || die "Couldn't softlink openaps.jq" + #ln -sf /root/go/pkg/mod/github.com/ecc1/medtronic@v0.0.0-20210712211734-b8431dc5211b/cmd/pumphistory/openaps.jq $directory/ || die "Couldn't softlink openaps.jq" + if [[ -f $directory/openaps.jq ]]; then + ls -la $directory/openaps.jq + else + cd $directory && wget https://raw.githubusercontent.com/ecc1/medtronic/master/cmd/pumphistory/openaps.jq || die "Couldn't wget openaps.jq" + fi else #TODO: write validate_ttyport and support non-SPI ports die "Unsupported ttyport. Exiting." From 80493da410ff9c102c02794c08a706af02fabc3b Mon Sep 17 00:00:00 2001 From: Chance Harrison Date: Sat, 22 Oct 2022 14:50:19 -0700 Subject: [PATCH 18/38] fix(lib/iob): Move value checks up to index.js --- lib/iob/calculate.js | 42 ++----------------- lib/iob/index.js | 96 ++++++++++++++++++++++++++++++++++++++++---- lib/iob/total.js | 52 ++---------------------- 3 files changed, 96 insertions(+), 94 deletions(-) diff --git a/lib/iob/calculate.js b/lib/iob/calculate.js index 904e953f4..15051824d 100644 --- a/lib/iob/calculate.js +++ b/lib/iob/calculate.js @@ -1,6 +1,6 @@ 'use strict'; -function iobCalc(treatment, time, curve, dia, peak, profile) { +function iobCalc(treatment, time, curve, dia, peak) { // iobCalc returns two variables: // activityContrib = units of treatment.insulin used in previous minute // iobContrib = units of treatment.insulin still remaining at a given point in time @@ -24,7 +24,7 @@ function iobCalc(treatment, time, curve, dia, peak, profile) { if (curve === 'bilinear') { return iobCalcBilinear(treatment, minsAgo, dia); // no user-specified peak with this model } else { - return iobCalcExponential(treatment, minsAgo, dia, peak, profile); + return iobCalcExponential(treatment, minsAgo, dia, peak); } } else { // empty return if (treatment.insulin) == False @@ -80,43 +80,9 @@ function iobCalcBilinear(treatment, minsAgo, dia) { } -function iobCalcExponential(treatment, minsAgo, dia, peak, profile) { - - // Use custom peak time (in minutes) if value is valid - if ( profile.curve === "rapid-acting" ) { - if (profile.useCustomPeakTime === true && profile.insulinPeakTime !== undefined) { - if ( profile.insulinPeakTime > 120 ) { - console.error('Setting maximum Insulin Peak Time of 120m for',profile.curve,'insulin'); - peak = 120; - } else if ( profile.insulinPeakTime < 50 ) { - console.error('Setting minimum Insulin Peak Time of 50m for',profile.curve,'insulin'); - peak = 50; - } else { - peak = profile.insulinPeakTime; - } - } else { - peak = 75; - } - } else if ( profile.curve === "ultra-rapid" ) { - if (profile.useCustomPeakTime === true && profile.insulinPeakTime !== undefined) { - if ( profile.insulinPeakTime > 100 ) { - console.error('Setting maximum Insulin Peak Time of 100m for',profile.curve,'insulin'); - peak = 100; - } else if ( profile.insulinPeakTime < 35 ) { - console.error('Setting minimum Insulin Peak Time of 35m for',profile.curve,'insulin'); - peak = 35; - } else { - peak = profile.insulinPeakTime; - } - } else { - peak = 55; - } - } else { - console.error('Curve of',profile.curve,'is not supported.'); - } - var end = dia * 60; // end of insulin activity, in minutes - +function iobCalcExponential(treatment, minsAgo, dia, peak) { + var end = dia * 60; // end of insulin activity, in minutes var activityContrib = 0; var iobContrib = 0; diff --git a/lib/iob/index.js b/lib/iob/index.js index fd64e3473..7334fc485 100644 --- a/lib/iob/index.js +++ b/lib/iob/index.js @@ -17,19 +17,99 @@ function generate (inputs, currentIOBOnly, treatments) { //console.error(treatments.length, treatmentsWithZeroTemp.length); //console.error(treatments[treatments.length-1], treatmentsWithZeroTemp[treatmentsWithZeroTemp.length-1]) + // Determine peak, curve, and DIA values once and put them in opts to be consumed by ./total + var profile_data = inputs.profile + + var curveDefaults = { + 'bilinear': { + requireLongDia: false, + peak: 75 // not really used, but prevents having to check later + }, + 'rapid-acting': { + requireLongDia: true, + peak: 75, + tdMin: 300 + }, + 'ultra-rapid': { + requireLongDia: true, + peak: 55, + tdMin: 300 + }, + }; + + var curve = "rapid-acting"; // start as 'rapid-acting' + var dia = profile_data.dia; + var peak = 0; + + if (profile_data.curve !== undefined) { + curve = profile_data.curve.toLowerCase(); // replace it with profile value, if it exists + } + + if (!(curve in curveDefaults)) { // check that the profile value is one of three expected values, else put it back to 'rapid-acting' + console.error('Unsupported curve function: "' + curve + '". Supported curves: "bilinear", "rapid-acting" (Novolog, Novorapid, Humalog, Apidra) and "ultra-rapid" (Fiasp, Lyumjev). Defaulting to "rapid-acting".'); + curve = 'rapid-acting'; + } + + var defaults = curveDefaults[curve]; + + // force minimum DIA of 3h + if (dia < 3) { + console.error("Warning: adjusting DIA from",dia,"to minimum of 3 hours for bilinear curve"); + dia = 3; + } + + // Force minimum of 5 hour DIA when default requires a Long DIA. + if (defaults.requireLongDia && dia < 5) { + console.error("Warning: adjusting DIA from",dia,"to minimum of 5 hours for non-bilinear curve"); + dia = 5; + } + + // Use custom insulinPeakTime, if value is sensible + if ( curve === "rapid-acting" ) { + if (profile_data.useCustomPeakTime === true && profile_data.insulinPeakTime !== undefined) { + if ( profile_data.insulinPeakTime > 120 ) { + console.error("Warning: adjusting insulin peak time from",profile_data.insulinPeakTime,"to a maximum of 120m for",profile_data.curve,"insulin"); + peak = 120; + } else if ( profile_data.insulinPeakTime < 50 ) { + console.error("Warning: adjusting insulin peak time from",profile_data.insulinPeakTime,"to a minimum of 50m for",profile_data.curve,"insulin"); + peak = 50; + } else { + peak = profile_data.insulinPeakTime; + } + } else { + peak = curveDefaults[curve].peak; + } + } else if ( curve === "ultra-rapid" ) { + if (profile_data.useCustomPeakTime === true && profile_data.insulinPeakTime !== undefined) { + if ( profile_data.insulinPeakTime > 100 ) { + console.error("Warning: adjusting insulin peak time from",profile_data.insulinPeakTime,"to a maximum of 100m for",profile_data.curve,"insulin"); + peak = 100; + } else if ( profile_data.insulinPeakTime < 35 ) { + console.error("Warning: adjusting insulin peak time from",profile_data.insulinPeakTime,"to a minimum of 30m for",profile_data.curve,"insulin"); + peak = 35; + } else { + peak = profile_data.insulinPeakTime; + } + } + else { + peak = curveDefaults[curve].peak; + } + } // any other curve (e.g., bilinear) does not use 'peak' + var opts = { - treatments: treatments - , profile: inputs.profile - , calculate: calculate + treatments: treatments, + calculate: calculate, + peak: peak, + curve: curve, + dia: dia, }; + + var optsWithZeroTemp = opts; + optsWithZeroTemp.treatments = treatmentsWithZeroTemp; + if ( inputs.autosens ) { opts.autosens = inputs.autosens; } - var optsWithZeroTemp = { - treatments: treatmentsWithZeroTemp - , profile: inputs.profile - , calculate: calculate - }; var iobArray = []; //console.error(inputs.clock); diff --git a/lib/iob/total.js b/lib/iob/total.js index bc2c39bc1..6ab6e3573 100644 --- a/lib/iob/total.js +++ b/lib/iob/total.js @@ -5,9 +5,9 @@ function iobTotal(opts, time) { var now = time.getTime(); var iobCalc = opts.calculate; var treatments = opts.treatments; - var profile_data = opts.profile; - var dia = profile_data.dia; - var peak = 0; + var dia = opts.dia; + var peak = opts.peak; + var curve = opts.curve; var iob = 0; var basaliob = 0; var bolusiob = 0; @@ -20,56 +20,12 @@ function iobTotal(opts, time) { //var time = new Date(); //} - // force minimum DIA of 3h - if (dia < 3) { - //console.error("Warning; adjusting DIA from",dia,"to minimum of 3 hours"); - dia = 3; - } - - var curveDefaults = { - 'bilinear': { - requireLongDia: false, - peak: 75 // not really used, but prevents having to check later - }, - 'rapid-acting': { - requireLongDia: true, - peak: 75, - tdMin: 300 - }, - 'ultra-rapid': { - requireLongDia: true, - peak: 55, - tdMin: 300 - }, - }; - - var curve = 'bilinear'; - - if (profile_data.curve !== undefined) { - curve = profile_data.curve.toLowerCase(); - } - - if (!(curve in curveDefaults)) { - console.error('Unsupported curve function: "' + curve + '". Supported curves: "bilinear", "rapid-acting" (Novolog, Novorapid, Humalog, Apidra) and "ultra-rapid" (Fiasp). Defaulting to "rapid-acting".'); - curve = 'rapid-acting'; - } - - var defaults = curveDefaults[curve]; - - // Force minimum of 5 hour DIA when default requires a Long DIA. - if (defaults.requireLongDia && dia < 5) { - //console.error('Pump DIA must be set to 5 hours or more with the new curves, please adjust your pump. Defaulting to 5 hour DIA.'); - dia = 5; - } - - peak = defaults.peak; - treatments.forEach(function(treatment) { if( treatment.date <= now ) { var dia_ago = now - dia*60*60*1000; if( treatment.date > dia_ago ) { // tIOB = total IOB - var tIOB = iobCalc(treatment, time, curve, dia, peak, profile_data); + var tIOB = iobCalc(treatment, time, curve, dia, peak); if (tIOB && tIOB.iobContrib) { iob += tIOB.iobContrib; } if (tIOB && tIOB.activityContrib) { activity += tIOB.activityContrib; } // basals look like either of these: From 1a25d534cdc5da9dc2189bf1e13a433861e73631 Mon Sep 17 00:00:00 2001 From: tzachi-dar Date: Thu, 29 Dec 2022 21:17:55 +0200 Subject: [PATCH 19/38] Use compression for operations that go to nightscout. (#1443) --- bin/ns-upload-entries.sh | 2 +- bin/ns-upload.sh | 4 ++-- bin/oref0-get-ns-entries.js | 2 ++ bin/oref0-pushover.sh | 12 ++++++------ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bin/ns-upload-entries.sh b/bin/ns-upload-entries.sh index e63bf234e..43be261a0 100755 --- a/bin/ns-upload-entries.sh +++ b/bin/ns-upload-entries.sh @@ -28,7 +28,7 @@ fi # requires API_SECRET and NIGHTSCOUT_HOST to be set in calling environment (i.e. in crontab) ( -curl -m 30 -s -X POST --data-binary @${ENTRIES} \ +curl --compressed -m 30 -s -X POST --data-binary @${ENTRIES} \ ${API_SECRET_HEADER} -H "content-type: application/json" \ ${REST_ENDPOINT} ) && ( test -n "${OUTPUT}" && touch ${OUTPUT} ; logger "Uploaded ${ENTRIES} to ${NIGHTSCOUT_HOST}" ) || logger "Unable to upload to ${NIGHTSCOUT_HOST}" diff --git a/bin/ns-upload.sh b/bin/ns-upload.sh index b70adb734..010292359 100755 --- a/bin/ns-upload.sh +++ b/bin/ns-upload.sh @@ -38,13 +38,13 @@ fi if [[ "${API_SECRET,,}" =~ "token=" ]]; then REST_ENDPOINT="${REST_ENDPOINT}?${API_SECRET}" (test "$ENTRIES" != "-" && cat $ENTRIES || cat )| ( - curl -m 30 -s -X POST --data-binary @- \ + curl --compressed -m 30 -s -X POST --data-binary @- \ -H "content-type: application/json" \ $REST_ENDPOINT ) && ( test -n "$OUTPUT" && touch $OUTPUT ; logger "Uploaded $ENTRIES to $NIGHTSCOUT_HOST" ) || ( logger "Unable to upload to $NIGHTSCOUT_HOST"; exit 2 ) else (test "$ENTRIES" != "-" && cat $ENTRIES || cat )| ( - curl -m 30 -s -X POST --data-binary @- \ + curl --compressed -m 30 -s -X POST --data-binary @- \ -H "API-SECRET: $API_SECRET" \ -H "content-type: application/json" \ $REST_ENDPOINT diff --git a/bin/oref0-get-ns-entries.js b/bin/oref0-get-ns-entries.js index 6e855fec8..4932aac31 100755 --- a/bin/oref0-get-ns-entries.js +++ b/bin/oref0-get-ns-entries.js @@ -180,12 +180,14 @@ var oref0_get_ns_engtires = function oref0_get_ns_engtires(argv_params, print_ca headers["If-Modified-Since"] = lastDate.toISOString(); } + headers["User-Agent"] = 'openaps'; var uri = nsurl + '/api/v1/entries/sgv.json?count=' + records + tokenAuth; var options = { uri: uri , json: true , timeout: 90000 , headers: headers + , gzip : true }; request(options, function(error, res, data) { diff --git a/bin/oref0-pushover.sh b/bin/oref0-pushover.sh index d31859870..5820b39c6 100755 --- a/bin/oref0-pushover.sh +++ b/bin/oref0-pushover.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env bash source $(dirname $0)/oref0-bash-common-functions.sh || (echo "ERROR: Failed to run oref0-bash-common-functions.sh. Is oref0 correctly installed?"; exit 1) @@ -87,7 +87,7 @@ fi CURL_AUTH='-H api-secret:'${API_SECRET} fi - if snooze=$(curl -s ${CURL_AUTH} ${URL} | jq '.[] | select(.snooze=="carbsReq") | select(.date>'$(date +%s -d "10 minutes ago")')' | jq -s .[0].date | noquotes | grep -v null); then + if snooze=$(curl --compressed -s ${CURL_AUTH} ${URL} | jq '.[] | select(.snooze=="carbsReq") | select(.date>'$(date +%s -d "10 minutes ago")')' | jq -s .[0].date | noquotes | grep -v null); then #echo $snooze #echo date -Is -d @$snooze; echo touch -d $(date -Is -d @$snooze) monitor/pushover-sent @@ -107,7 +107,7 @@ elif [[ $ONLYFOR =~ "insulin" ]] && ! cat $FILE | egrep "maxBolus" > /dev/null; elif file_is_recent monitor/pushover-sent $SNOOZE; then echo -n "Last pushover sent less than $SNOOZE minutes ago. " else - curl -s -F token=$TOKEN -F user=$USER $SOUND_OPTION -F priority=$PRIORITY $PRIORITY_OPTIONS -F "message=$(jq -c "{bg, tick, carbsReq, insulinReq, reason}|del(.[] | nulls)" $FILE) - $(hostname)" https://api.pushover.net/1/messages.json | jq .status| grep 1 >/dev/null && touch monitor/pushover-sent && echo '{"date":'$(epochtime_now)',"device":"openaps://'$(hostname)'","snooze":"carbsReq"}' > /tmp/snooze.json && ns-upload $NIGHTSCOUT_HOST $API_SECRET devicestatus.json /tmp/snooze.json >/dev/null && echo "carbsReq pushover sent." + curl ---compressed s -F token=$TOKEN -F user=$USER $SOUND_OPTION -F priority=$PRIORITY $PRIORITY_OPTIONS -F "message=$(jq -c "{bg, tick, carbsReq, insulinReq, reason}|del(.[] | nulls)" $FILE) - $(hostname)" https://api.pushover.net/1/messages.json | jq .status| grep 1 >/dev/null && touch monitor/pushover-sent && echo '{"date":'$(epochtime_now)',"device":"openaps://'$(hostname)'","snooze":"carbsReq"}' > /tmp/snooze.json && ns-upload $NIGHTSCOUT_HOST $API_SECRET devicestatus.json /tmp/snooze.json >/dev/null && echo "carbsReq pushover sent." echo fi @@ -152,7 +152,7 @@ else touch $GLANCES && touch -r $GLANCES -d '-60 mins' $GLANCES fi - if snooze=$(curl -s ${CURL_AUTH} ${URL} | jq '.[] | select(.snooze=="glance") | select(.date>'$(date +%s -d "$glanceDelay minutes ago")')' | jq -s .[0].date | noquotes | grep -v null); then + if snooze=$(curl --compressed -s ${CURL_AUTH} ${URL} | jq '.[] | select(.snooze=="glance") | select(.date>'$(date +%s -d "$glanceDelay minutes ago")')' | jq -s .[0].date | noquotes | grep -v null); then #echo $snooze #echo date -Is -d @$snooze; echo touch -d $(date -Is -d @$snooze) $GLANCES @@ -195,7 +195,7 @@ else subtext="$carbsMsg${rate}U/h ${duration}m" # echo "pushover glance text=${text} subtext=${subtext} delta=${delta} title=${title} battery percent=${battery}" - curl -s -F "token=$TOKEN" -F "user=$USER" -F "text=${text}" -F "subtext=${subtext}" -F "count=$bgNow" -F "percent=${battery}" -F "title=${title}" https://api.pushover.net/1/glances.json | jq .status| grep 1 >/dev/null && echo '{"date":'$(epochtime_now)',"device":"openaps://'$(hostname)'","snooze":"glance"}' > /tmp/snooze.json && ns-upload $NIGHTSCOUT_HOST $API_SECRET devicestatus.json /tmp/snooze.json >/dev/null && echo "Glance uploaded and snoozed" + curl --compressed -s -F "token=$TOKEN" -F "user=$USER" -F "text=${text}" -F "subtext=${subtext}" -F "count=$bgNow" -F "percent=${battery}" -F "title=${title}" https://api.pushover.net/1/glances.json | jq .status| grep 1 >/dev/null && echo '{"date":'$(epochtime_now)',"device":"openaps://'$(hostname)'","snooze":"glance"}' > /tmp/snooze.json && ns-upload $NIGHTSCOUT_HOST $API_SECRET devicestatus.json /tmp/snooze.json >/dev/null && echo "Glance uploaded and snoozed" touch $GLANCES else echo -n "Pushover glance last updated less than $glanceDelay minutes ago @ " @@ -223,7 +223,7 @@ if ! [ -z "$MAKER_KEY" ] && [[ "$MAKER_KEY" != "null" ]] && cat $FILE | egrep "a echo $values > $ifttt - curl --request POST \ + curl --compressed --request POST \ --header 'Content-Type: application/json' \ -d @$ifttt \ https://maker.ifttt.com/trigger/carbs-required/with/key/${key} && touch monitor/ifttt-sent From 673dbc66b966dbd567953dc9a22c949601a8ae4d Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 16 Jan 2023 04:45:32 +0100 Subject: [PATCH 20/38] convert_bg missing in many statements for rT (#1438) This commit calls convert_bg on various console.error() print statements, which should improve readability for mmol/L users and leave mg/dL users' experience unaffected. --- lib/determine-basal/determine-basal.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/determine-basal/determine-basal.js b/lib/determine-basal/determine-basal.js index 74fa25b76..5e3ee78b8 100644 --- a/lib/determine-basal/determine-basal.js +++ b/lib/determine-basal/determine-basal.js @@ -695,7 +695,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ } // set eventualBG based on COB or UAM predBGs - rT.eventualBG = eventualBG; + rT.eventualBG = eventualBG; // for FreeAPS-X needs to be in mg/dL } console.error("UAM Impact:",uci,"mg/dL per 5m; UAM Duration:",UAMduration,"hours"); @@ -894,7 +894,7 @@ var maxDelta_bg_threshold; var carbsReq = (bgUndershoot - zeroTempEffect) / csf - COBforCarbsReq; zeroTempEffect = round(zeroTempEffect); carbsReq = round(carbsReq); - console.error("naive_eventualBG:",naive_eventualBG,"bgUndershoot:",bgUndershoot,"zeroTempDuration:",zeroTempDuration,"zeroTempEffect:",zeroTempEffect,"carbsReq:",carbsReq); + console.error("naive_eventualBG: " + convert_bg(naive_eventualBG,profile) + ", bgUndershoot: " + convert_bg(bgUndershoot,profile) + ", zeroTempDuration: " + zeroTempDuration + ", zeroTempEffect: " + zeroTempEffect +", carbsReq: " + carbsReq); if ( meal_data.reason == "Could not parse clock data" ) { console.error("carbsReq unknown: Could not parse clock data"); } else if ( carbsReq >= profile.carbsReqThreshold && minutesAboveThreshold <= 45 ) { @@ -1138,7 +1138,7 @@ var maxDelta_bg_threshold; var nextBolusMins = round(SMBInterval-lastBolusAge,0); var nextBolusSeconds = round((SMBInterval - lastBolusAge) * 60, 0) % 60; //console.error(naive_eventualBG, insulinReq, worstCaseInsulinReq, durationReq); - console.error("naive_eventualBG",naive_eventualBG+",",durationReq+"m "+smbLowTempReq+"U/h temp needed; last bolus",lastBolusAge+"m ago; maxBolus: "+maxBolus); + console.error("naive_eventualBG " + convert_bg(naive_eventualBG,profile) +", " + durationReq + "m " + smbLowTempReq + "U/h temp needed; last bolus " + lastBolusAge + "m ago; maxBolus: "+maxBolus); if (lastBolusAge > SMBInterval) { if (microBolus > 0) { From 10f9e2745a2a3d7de0176fe16275a58e178d07ab Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 4 Mar 2023 19:25:55 -0800 Subject: [PATCH 21/38] Revert "fix(lib/iob): Move value checks up to index.js" This reverts commit 80493da410ff9c102c02794c08a706af02fabc3b. This is causing future IOB predictions to be incorrect (highly negative). That causes the predBG lines to swoop up and to the right. That results in (slightly) too much insulin being dosed in some situations. --- lib/iob/calculate.js | 42 +++++++++++++++++-- lib/iob/index.js | 96 ++++---------------------------------------- lib/iob/total.js | 52 ++++++++++++++++++++++-- 3 files changed, 94 insertions(+), 96 deletions(-) diff --git a/lib/iob/calculate.js b/lib/iob/calculate.js index 15051824d..904e953f4 100644 --- a/lib/iob/calculate.js +++ b/lib/iob/calculate.js @@ -1,6 +1,6 @@ 'use strict'; -function iobCalc(treatment, time, curve, dia, peak) { +function iobCalc(treatment, time, curve, dia, peak, profile) { // iobCalc returns two variables: // activityContrib = units of treatment.insulin used in previous minute // iobContrib = units of treatment.insulin still remaining at a given point in time @@ -24,7 +24,7 @@ function iobCalc(treatment, time, curve, dia, peak) { if (curve === 'bilinear') { return iobCalcBilinear(treatment, minsAgo, dia); // no user-specified peak with this model } else { - return iobCalcExponential(treatment, minsAgo, dia, peak); + return iobCalcExponential(treatment, minsAgo, dia, peak, profile); } } else { // empty return if (treatment.insulin) == False @@ -80,9 +80,43 @@ function iobCalcBilinear(treatment, minsAgo, dia) { } -function iobCalcExponential(treatment, minsAgo, dia, peak) { - +function iobCalcExponential(treatment, minsAgo, dia, peak, profile) { + + // Use custom peak time (in minutes) if value is valid + if ( profile.curve === "rapid-acting" ) { + if (profile.useCustomPeakTime === true && profile.insulinPeakTime !== undefined) { + if ( profile.insulinPeakTime > 120 ) { + console.error('Setting maximum Insulin Peak Time of 120m for',profile.curve,'insulin'); + peak = 120; + } else if ( profile.insulinPeakTime < 50 ) { + console.error('Setting minimum Insulin Peak Time of 50m for',profile.curve,'insulin'); + peak = 50; + } else { + peak = profile.insulinPeakTime; + } + } else { + peak = 75; + } + } else if ( profile.curve === "ultra-rapid" ) { + if (profile.useCustomPeakTime === true && profile.insulinPeakTime !== undefined) { + if ( profile.insulinPeakTime > 100 ) { + console.error('Setting maximum Insulin Peak Time of 100m for',profile.curve,'insulin'); + peak = 100; + } else if ( profile.insulinPeakTime < 35 ) { + console.error('Setting minimum Insulin Peak Time of 35m for',profile.curve,'insulin'); + peak = 35; + } else { + peak = profile.insulinPeakTime; + } + } else { + peak = 55; + } + } else { + console.error('Curve of',profile.curve,'is not supported.'); + } var end = dia * 60; // end of insulin activity, in minutes + + var activityContrib = 0; var iobContrib = 0; diff --git a/lib/iob/index.js b/lib/iob/index.js index 7334fc485..fd64e3473 100644 --- a/lib/iob/index.js +++ b/lib/iob/index.js @@ -17,99 +17,19 @@ function generate (inputs, currentIOBOnly, treatments) { //console.error(treatments.length, treatmentsWithZeroTemp.length); //console.error(treatments[treatments.length-1], treatmentsWithZeroTemp[treatmentsWithZeroTemp.length-1]) - // Determine peak, curve, and DIA values once and put them in opts to be consumed by ./total - var profile_data = inputs.profile - - var curveDefaults = { - 'bilinear': { - requireLongDia: false, - peak: 75 // not really used, but prevents having to check later - }, - 'rapid-acting': { - requireLongDia: true, - peak: 75, - tdMin: 300 - }, - 'ultra-rapid': { - requireLongDia: true, - peak: 55, - tdMin: 300 - }, - }; - - var curve = "rapid-acting"; // start as 'rapid-acting' - var dia = profile_data.dia; - var peak = 0; - - if (profile_data.curve !== undefined) { - curve = profile_data.curve.toLowerCase(); // replace it with profile value, if it exists - } - - if (!(curve in curveDefaults)) { // check that the profile value is one of three expected values, else put it back to 'rapid-acting' - console.error('Unsupported curve function: "' + curve + '". Supported curves: "bilinear", "rapid-acting" (Novolog, Novorapid, Humalog, Apidra) and "ultra-rapid" (Fiasp, Lyumjev). Defaulting to "rapid-acting".'); - curve = 'rapid-acting'; - } - - var defaults = curveDefaults[curve]; - - // force minimum DIA of 3h - if (dia < 3) { - console.error("Warning: adjusting DIA from",dia,"to minimum of 3 hours for bilinear curve"); - dia = 3; - } - - // Force minimum of 5 hour DIA when default requires a Long DIA. - if (defaults.requireLongDia && dia < 5) { - console.error("Warning: adjusting DIA from",dia,"to minimum of 5 hours for non-bilinear curve"); - dia = 5; - } - - // Use custom insulinPeakTime, if value is sensible - if ( curve === "rapid-acting" ) { - if (profile_data.useCustomPeakTime === true && profile_data.insulinPeakTime !== undefined) { - if ( profile_data.insulinPeakTime > 120 ) { - console.error("Warning: adjusting insulin peak time from",profile_data.insulinPeakTime,"to a maximum of 120m for",profile_data.curve,"insulin"); - peak = 120; - } else if ( profile_data.insulinPeakTime < 50 ) { - console.error("Warning: adjusting insulin peak time from",profile_data.insulinPeakTime,"to a minimum of 50m for",profile_data.curve,"insulin"); - peak = 50; - } else { - peak = profile_data.insulinPeakTime; - } - } else { - peak = curveDefaults[curve].peak; - } - } else if ( curve === "ultra-rapid" ) { - if (profile_data.useCustomPeakTime === true && profile_data.insulinPeakTime !== undefined) { - if ( profile_data.insulinPeakTime > 100 ) { - console.error("Warning: adjusting insulin peak time from",profile_data.insulinPeakTime,"to a maximum of 100m for",profile_data.curve,"insulin"); - peak = 100; - } else if ( profile_data.insulinPeakTime < 35 ) { - console.error("Warning: adjusting insulin peak time from",profile_data.insulinPeakTime,"to a minimum of 30m for",profile_data.curve,"insulin"); - peak = 35; - } else { - peak = profile_data.insulinPeakTime; - } - } - else { - peak = curveDefaults[curve].peak; - } - } // any other curve (e.g., bilinear) does not use 'peak' - var opts = { - treatments: treatments, - calculate: calculate, - peak: peak, - curve: curve, - dia: dia, + treatments: treatments + , profile: inputs.profile + , calculate: calculate }; - - var optsWithZeroTemp = opts; - optsWithZeroTemp.treatments = treatmentsWithZeroTemp; - if ( inputs.autosens ) { opts.autosens = inputs.autosens; } + var optsWithZeroTemp = { + treatments: treatmentsWithZeroTemp + , profile: inputs.profile + , calculate: calculate + }; var iobArray = []; //console.error(inputs.clock); diff --git a/lib/iob/total.js b/lib/iob/total.js index 6ab6e3573..bc2c39bc1 100644 --- a/lib/iob/total.js +++ b/lib/iob/total.js @@ -5,9 +5,9 @@ function iobTotal(opts, time) { var now = time.getTime(); var iobCalc = opts.calculate; var treatments = opts.treatments; - var dia = opts.dia; - var peak = opts.peak; - var curve = opts.curve; + var profile_data = opts.profile; + var dia = profile_data.dia; + var peak = 0; var iob = 0; var basaliob = 0; var bolusiob = 0; @@ -20,12 +20,56 @@ function iobTotal(opts, time) { //var time = new Date(); //} + // force minimum DIA of 3h + if (dia < 3) { + //console.error("Warning; adjusting DIA from",dia,"to minimum of 3 hours"); + dia = 3; + } + + var curveDefaults = { + 'bilinear': { + requireLongDia: false, + peak: 75 // not really used, but prevents having to check later + }, + 'rapid-acting': { + requireLongDia: true, + peak: 75, + tdMin: 300 + }, + 'ultra-rapid': { + requireLongDia: true, + peak: 55, + tdMin: 300 + }, + }; + + var curve = 'bilinear'; + + if (profile_data.curve !== undefined) { + curve = profile_data.curve.toLowerCase(); + } + + if (!(curve in curveDefaults)) { + console.error('Unsupported curve function: "' + curve + '". Supported curves: "bilinear", "rapid-acting" (Novolog, Novorapid, Humalog, Apidra) and "ultra-rapid" (Fiasp). Defaulting to "rapid-acting".'); + curve = 'rapid-acting'; + } + + var defaults = curveDefaults[curve]; + + // Force minimum of 5 hour DIA when default requires a Long DIA. + if (defaults.requireLongDia && dia < 5) { + //console.error('Pump DIA must be set to 5 hours or more with the new curves, please adjust your pump. Defaulting to 5 hour DIA.'); + dia = 5; + } + + peak = defaults.peak; + treatments.forEach(function(treatment) { if( treatment.date <= now ) { var dia_ago = now - dia*60*60*1000; if( treatment.date > dia_ago ) { // tIOB = total IOB - var tIOB = iobCalc(treatment, time, curve, dia, peak); + var tIOB = iobCalc(treatment, time, curve, dia, peak, profile_data); if (tIOB && tIOB.iobContrib) { iob += tIOB.iobContrib; } if (tIOB && tIOB.activityContrib) { activity += tIOB.activityContrib; } // basals look like either of these: From 9ac3910b57c7dcf03eb9097d4b9babb467ffed44 Mon Sep 17 00:00:00 2001 From: Scott Leibrand Date: Sun, 20 Aug 2023 11:17:48 -0700 Subject: [PATCH 22/38] wait upto45s and try preflight; if successful, refresh pumphistory, else mmtune (#1457) * on loop failure, retry preflight; if successful, refresh pumphistory, else mmtune * wait_for_silence before retrying preflight * need to return, not keep invoking fail() * only try preflight one more time before mmtuning --- bin/oref0-pump-loop.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/oref0-pump-loop.sh b/bin/oref0-pump-loop.sh index 3ff08fa50..a3ec33b00 100755 --- a/bin/oref0-pump-loop.sh +++ b/bin/oref0-pump-loop.sh @@ -169,8 +169,13 @@ function fail { refresh_after_bolus_or_enact echo "Incomplete oref0-pump-loop (pump suspended) at $(date)" else - pumphistory_daily_refresh - maybe_mmtune + # wait upto45s and try preflight; if successful, refresh pumphistory, else mmtune + wait_for_silence $upto45s + if try_return preflight; then + pumphistory_daily_refresh + else + maybe_mmtune + fi echo "If pump and rig are close enough, this error usually self-resolves. Stand by for the next loop." echo Unsuccessful oref0-pump-loop at $(date) fi From bc376010f63b07e0990b3a7be262b10dbc6d0f46 Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 18 Jun 2022 19:18:47 -0700 Subject: [PATCH 23/38] 0.7.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c7cbcb33b..bffeac98a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oref0", - "version": "0.7.0", + "version": "0.7.1", "description": "openaps oref0 reference implementation of the reference design", "scripts": { "test": "make test", From 8cae7b3195c60b57d5c178790edbdd29b0d162a9 Mon Sep 17 00:00:00 2001 From: hpeuscher <59748955+hpeuscher@users.noreply.github.com> Date: Thu, 14 Sep 2023 15:51:56 +0200 Subject: [PATCH 24/38] fix missing declaration --- lib/determine-basal/determine-basal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/determine-basal/determine-basal.js b/lib/determine-basal/determine-basal.js index 5e3ee78b8..54f9b986e 100644 --- a/lib/determine-basal/determine-basal.js +++ b/lib/determine-basal/determine-basal.js @@ -474,7 +474,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ // use autosens-adjusted sens to counteract autosens meal insulin dosing adjustments so that // autotuned CR is still in effect even when basals and ISF are being adjusted by TT or autosens // this avoids overdosing insulin for large meals when low temp targets are active - csf = sens / profile.carb_ratio; + var csf = sens / profile.carb_ratio; console.error("profile.sens:",profile.sens,"sens:",sens,"CSF:",csf); var maxCarbAbsorptionRate = 30; // g/h; maximum rate to assume carbs will absorb if no CI observed From 9585e5a6ae6e66e57b037c81ab105186c75235ac Mon Sep 17 00:00:00 2001 From: Caleb Hornbeck Date: Mon, 25 Mar 2024 03:27:20 -0600 Subject: [PATCH 25/38] Fixed NS perms checking --- bin/oref0_nightscout_check.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/bin/oref0_nightscout_check.py b/bin/oref0_nightscout_check.py index 90b6edcc2..519f3ff6e 100755 --- a/bin/oref0_nightscout_check.py +++ b/bin/oref0_nightscout_check.py @@ -92,21 +92,27 @@ def startup_checks(args): def check_permissions(): global token_dict - pg=token_dict['permissionGroups'][0] + pg=[] + missing=[] + + for perm_group in token_dict['permissionGroups']: + pg.extend(perm_group) + if pg==["*"]: # admin role logging.warning("The use of the admin role for token based authentication is not recommended, see https://openaps.readthedocs.io/en/master/docs/walkthrough/phase-1/nightscout-setup.md#switching-from-api_secret-to-token-based-authentication-for-your-rig") + missing = [] else: - missing=[] for perm in ["api:treatments:read", "api:treatments:create", "api:treatments:read", "api:treatments:create", "api:devicestatus:read", "api:devicestatus:create"]: logging.debug("Checking %s" % perm) if perm not in pg: - missing.append(perm) + missing.append(perm) - if len(missing)>0: - logging.error("The following permissions are missing in Nightscout: %s" % missing) - logging.error("Please follow instructions at https://openaps.readthedocs.io/en/master/docs/walkthrough/phase-1/nightscout-setup.md#switching-from-api_secret-to-token-based-authentication-for-your-rig") - sys.exit(1) - logging.info("All permissions in Nightscout are ok") + if len(missing)>0: + logging.error("The following permissions are missing in Nightscout: %s" % missing) + logging.error("Please follow instructions at https://openaps.readthedocs.io/en/master/docs/walkthrough/phase-1/nightscout-setup.md#switching-from-api_secret-to-token-based-authentication-for-your-rig") + sys.exit(1) + + logging.info("All permissions in Nightscout are ok") if __name__ == '__main__': From c0578dc29268a47f013929b50c9ae102341939c2 Mon Sep 17 00:00:00 2001 From: Caleb Hornbeck Date: Mon, 25 Mar 2024 03:38:05 -0600 Subject: [PATCH 26/38] Removed duplicate line --- bin/oref0_nightscout_check.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/oref0_nightscout_check.py b/bin/oref0_nightscout_check.py index 519f3ff6e..9bd8ff464 100755 --- a/bin/oref0_nightscout_check.py +++ b/bin/oref0_nightscout_check.py @@ -100,7 +100,6 @@ def check_permissions(): if pg==["*"]: # admin role logging.warning("The use of the admin role for token based authentication is not recommended, see https://openaps.readthedocs.io/en/master/docs/walkthrough/phase-1/nightscout-setup.md#switching-from-api_secret-to-token-based-authentication-for-your-rig") - missing = [] else: for perm in ["api:treatments:read", "api:treatments:create", "api:treatments:read", "api:treatments:create", "api:devicestatus:read", "api:devicestatus:create"]: logging.debug("Checking %s" % perm) From edf8bf6141e0df8d57dd161626c1a9069fe4b4fe Mon Sep 17 00:00:00 2001 From: Caleb Hornbeck Date: Mon, 25 Mar 2024 03:27:20 -0600 Subject: [PATCH 27/38] Fixed NS perms checking --- bin/oref0_nightscout_check.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/oref0_nightscout_check.py b/bin/oref0_nightscout_check.py index 9bd8ff464..519f3ff6e 100755 --- a/bin/oref0_nightscout_check.py +++ b/bin/oref0_nightscout_check.py @@ -100,6 +100,7 @@ def check_permissions(): if pg==["*"]: # admin role logging.warning("The use of the admin role for token based authentication is not recommended, see https://openaps.readthedocs.io/en/master/docs/walkthrough/phase-1/nightscout-setup.md#switching-from-api_secret-to-token-based-authentication-for-your-rig") + missing = [] else: for perm in ["api:treatments:read", "api:treatments:create", "api:treatments:read", "api:treatments:create", "api:devicestatus:read", "api:devicestatus:create"]: logging.debug("Checking %s" % perm) From 2595ecaf6a30f7c0b5ca3dd15a3c1edfbfc55ffb Mon Sep 17 00:00:00 2001 From: Caleb Hornbeck Date: Mon, 25 Mar 2024 03:38:05 -0600 Subject: [PATCH 28/38] Removed duplicate line --- bin/oref0_nightscout_check.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/oref0_nightscout_check.py b/bin/oref0_nightscout_check.py index 519f3ff6e..9bd8ff464 100755 --- a/bin/oref0_nightscout_check.py +++ b/bin/oref0_nightscout_check.py @@ -100,7 +100,6 @@ def check_permissions(): if pg==["*"]: # admin role logging.warning("The use of the admin role for token based authentication is not recommended, see https://openaps.readthedocs.io/en/master/docs/walkthrough/phase-1/nightscout-setup.md#switching-from-api_secret-to-token-based-authentication-for-your-rig") - missing = [] else: for perm in ["api:treatments:read", "api:treatments:create", "api:treatments:read", "api:treatments:create", "api:devicestatus:read", "api:devicestatus:create"]: logging.debug("Checking %s" % perm) From 9b57b0633a8ead913cb85bf3201c477ae17f7945 Mon Sep 17 00:00:00 2001 From: Caleb Hornbeck Date: Mon, 25 Mar 2024 19:42:10 -0600 Subject: [PATCH 29/38] Revert scope promotion --- bin/oref0_nightscout_check.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/oref0_nightscout_check.py b/bin/oref0_nightscout_check.py index 9bd8ff464..6d640da4d 100755 --- a/bin/oref0_nightscout_check.py +++ b/bin/oref0_nightscout_check.py @@ -93,7 +93,6 @@ def startup_checks(args): def check_permissions(): global token_dict pg=[] - missing=[] for perm_group in token_dict['permissionGroups']: pg.extend(perm_group) @@ -101,15 +100,16 @@ def check_permissions(): if pg==["*"]: # admin role logging.warning("The use of the admin role for token based authentication is not recommended, see https://openaps.readthedocs.io/en/master/docs/walkthrough/phase-1/nightscout-setup.md#switching-from-api_secret-to-token-based-authentication-for-your-rig") else: + missing=[] for perm in ["api:treatments:read", "api:treatments:create", "api:treatments:read", "api:treatments:create", "api:devicestatus:read", "api:devicestatus:create"]: logging.debug("Checking %s" % perm) if perm not in pg: missing.append(perm) - if len(missing)>0: - logging.error("The following permissions are missing in Nightscout: %s" % missing) - logging.error("Please follow instructions at https://openaps.readthedocs.io/en/master/docs/walkthrough/phase-1/nightscout-setup.md#switching-from-api_secret-to-token-based-authentication-for-your-rig") - sys.exit(1) + if len(missing)>0: + logging.error("The following permissions are missing in Nightscout: %s" % missing) + logging.error("Please follow instructions at https://openaps.readthedocs.io/en/master/docs/walkthrough/phase-1/nightscout-setup.md#switching-from-api_secret-to-token-based-authentication-for-your-rig") + sys.exit(1) logging.info("All permissions in Nightscout are ok") From 3430f6bf542956574ac65f07f46912ac67bcf9e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:35:29 +0200 Subject: [PATCH 30/38] rT.reason missing colons (:) In some places a space is used instead of a colon. --- lib/determine-basal/determine-basal.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/determine-basal/determine-basal.js b/lib/determine-basal/determine-basal.js index 54f9b986e..1a1a286cc 100644 --- a/lib/determine-basal/determine-basal.js +++ b/lib/determine-basal/determine-basal.js @@ -808,12 +808,12 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ rT.ISF=convert_bg(sens, profile); rT.CR=round(profile.carb_ratio, 2); rT.target_bg=convert_bg(target_bg, profile); - rT.reason="COB: " + rT.COB + ", Dev: " + rT.deviation + ", BGI: " + rT.BGI+ ", ISF: " + rT.ISF + ", CR: " + rT.CR + ", minPredBG " + convert_bg(minPredBG, profile) + ", minGuardBG " + convert_bg(minGuardBG, profile) + ", IOBpredBG " + convert_bg(lastIOBpredBG, profile); + rT.reason="COB: " + rT.COB + ", Dev: " + rT.deviation + ", BGI: " + rT.BGI+ ", ISF: " + rT.ISF + ", CR: " + rT.CR + ", minPredBG: " + convert_bg(minPredBG, profile) + ", minGuardBG: " + convert_bg(minGuardBG, profile) + ", IOBpredBG: " + convert_bg(lastIOBpredBG, profile); if (lastCOBpredBG > 0) { - rT.reason += ", COBpredBG " + convert_bg(lastCOBpredBG, profile); + rT.reason += ", COBpredBG: " + convert_bg(lastCOBpredBG, profile); } if (lastUAMpredBG > 0) { - rT.reason += ", UAMpredBG " + convert_bg(lastUAMpredBG, profile) + rT.reason += ", UAMpredBG: " + convert_bg(lastUAMpredBG, profile) } rT.reason += "; "; @@ -910,7 +910,7 @@ var maxDelta_bg_threshold; rT.reason += " and minDelta " + convert_bg(minDelta, profile) + " > " + "expectedDelta " + convert_bg(expectedDelta, profile) + "; "; // predictive low glucose suspend mode: BG is / is projected to be < threshold } else if ( bg < threshold || minGuardBG < threshold ) { - rT.reason += "minGuardBG " + convert_bg(minGuardBG, profile) + "<" + convert_bg(threshold, profile); + rT.reason += "minGuardBG: " + convert_bg(minGuardBG, profile) + "<" + convert_bg(threshold, profile); bgUndershoot = target_bg - minGuardBG; var worstCaseInsulinReq = bgUndershoot / sens; var durationReq = round(60*worstCaseInsulinReq / profile.current_basal); From 13a8dec4638942a8e14ea3fae0153d86113b19c3 Mon Sep 17 00:00:00 2001 From: Scott Leibrand Date: Thu, 17 Aug 2023 18:35:45 -0700 Subject: [PATCH 31/38] =?UTF-8?q?#1455:=20Don=E2=80=99t=20cancel=20a=20hig?= =?UTF-8?q?h=20temp=20due=20to=20lack=20of=20BG=20data=20if=20the=20temp?= =?UTF-8?q?=20has=20been=20running=20for=20less=20than=2010m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/determine-basal/determine-basal.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/determine-basal/determine-basal.js b/lib/determine-basal/determine-basal.js index 1a1a286cc..eec14b66a 100644 --- a/lib/determine-basal/determine-basal.js +++ b/lib/determine-basal/determine-basal.js @@ -184,7 +184,12 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ } } - if (minAgo > 12 || minAgo < -5) { // Dexcom data is too old, or way in the future + var lastTempAge = 0; + if (typeof iob_data.lastTemp !== 'undefined' ) { + lastTempAge = round(( new Date(systemTime).getTime() - iob_data.lastTemp.date ) / 60000); // in minutes + } + + if ((minAgo > 12 || minAgo < -5) && lastTempAge >= 10) { // Dexcom data is too old, or way in the future rT.reason = "If current system time "+systemTime+" is correct, then BG data is too old. The last BG data was read "+minAgo+"m ago at "+bgTime; // if BG is too old/noisy, or is changing less than 1 mg/dL/5m for 45m, cancel any high temps and shorten any long zero temps } else if ( tooflat ) { @@ -195,7 +200,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ } } // Then, for all such error conditions, cancel any running high temp or shorten any long zero temp, and return. - if (bg <= 10 || bg === 38 || noise >= 3 || minAgo > 12 || minAgo < -5 || tooflat ) { + if (bg <= 10 || bg === 38 || noise >= 3 || ((minAgo > 12 || minAgo < -5) && lastTempAge >= 10) || tooflat ) { if (currenttemp.rate > basal) { // high temp is running rT.reason += ". Replacing high temp basal of "+currenttemp.rate+" with neutral temp of "+basal; rT.deliverAt = deliverAt; From fce44473d22514fb1f2a69069c0c9f7d7ef6c7ec Mon Sep 17 00:00:00 2001 From: Scott Leibrand Date: Thu, 17 Aug 2023 19:04:25 -0700 Subject: [PATCH 32/38] don't modify temp if lastTempAge < 10, just print why not --- lib/determine-basal/determine-basal.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/determine-basal/determine-basal.js b/lib/determine-basal/determine-basal.js index eec14b66a..93511e64e 100644 --- a/lib/determine-basal/determine-basal.js +++ b/lib/determine-basal/determine-basal.js @@ -189,7 +189,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ lastTempAge = round(( new Date(systemTime).getTime() - iob_data.lastTemp.date ) / 60000); // in minutes } - if ((minAgo > 12 || minAgo < -5) && lastTempAge >= 10) { // Dexcom data is too old, or way in the future + if (minAgo > 12 || minAgo < -5) { // Dexcom data is too old, or way in the future rT.reason = "If current system time "+systemTime+" is correct, then BG data is too old. The last BG data was read "+minAgo+"m ago at "+bgTime; // if BG is too old/noisy, or is changing less than 1 mg/dL/5m for 45m, cancel any high temps and shorten any long zero temps } else if ( tooflat ) { @@ -200,7 +200,10 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ } } // Then, for all such error conditions, cancel any running high temp or shorten any long zero temp, and return. - if (bg <= 10 || bg === 38 || noise >= 3 || ((minAgo > 12 || minAgo < -5) && lastTempAge >= 10) || tooflat ) { + if ((minAgo > 12 || minAgo < -5) && lastTempAge < 10) { + rT.reason += "lastTempAge of " + lastTempAge + " < 10m; doing nothing. "; + return rT; + } else if (bg <= 10 || bg === 38 || noise >= 3 || minAgo > 12 || minAgo < -5 || tooflat ) { if (currenttemp.rate > basal) { // high temp is running rT.reason += ". Replacing high temp basal of "+currenttemp.rate+" with neutral temp of "+basal; rT.deliverAt = deliverAt; @@ -224,7 +227,6 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ return rT; } } - // Get configured target, and return if unable to do so. // This should occur after checking that we're not in one of the CGM-data-related error conditions handled above, // and before using target_bg to adjust sensitivityRatio below. From 43be7059dd6efb0aa792cef736cca020f36f96f7 Mon Sep 17 00:00:00 2001 From: Scott Leibrand Date: Sat, 19 Aug 2023 19:54:06 -0700 Subject: [PATCH 33/38] add ', but' to make reason more readable --- lib/determine-basal/determine-basal.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/determine-basal/determine-basal.js b/lib/determine-basal/determine-basal.js index 93511e64e..62cab4095 100644 --- a/lib/determine-basal/determine-basal.js +++ b/lib/determine-basal/determine-basal.js @@ -201,7 +201,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ } // Then, for all such error conditions, cancel any running high temp or shorten any long zero temp, and return. if ((minAgo > 12 || minAgo < -5) && lastTempAge < 10) { - rT.reason += "lastTempAge of " + lastTempAge + " < 10m; doing nothing. "; + rT.reason += ", but lastTempAge of " + lastTempAge + " < 10m; doing nothing. "; return rT; } else if (bg <= 10 || bg === 38 || noise >= 3 || minAgo > 12 || minAgo < -5 || tooflat ) { if (currenttemp.rate > basal) { // high temp is running @@ -227,6 +227,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ return rT; } } + // Get configured target, and return if unable to do so. // This should occur after checking that we're not in one of the CGM-data-related error conditions handled above, // and before using target_bg to adjust sensitivityRatio below. From 45810636ca11b17ee6c5cfae2b0ec8a1cfe0d68f Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 19 Aug 2023 19:30:57 -0700 Subject: [PATCH 34/38] remove suprious BOM introduced in #1443 causing /usr/bin/env: No such file --- bin/oref0-pushover.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/oref0-pushover.sh b/bin/oref0-pushover.sh index 5820b39c6..2df11e33b 100755 --- a/bin/oref0-pushover.sh +++ b/bin/oref0-pushover.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env bash source $(dirname $0)/oref0-bash-common-functions.sh || (echo "ERROR: Failed to run oref0-bash-common-functions.sh. Is oref0 correctly installed?"; exit 1) From 0cf223c7b36f256185b2a52b618e50cda794b7e3 Mon Sep 17 00:00:00 2001 From: Scott Leibrand Date: Sat, 19 Aug 2023 20:44:45 -0700 Subject: [PATCH 35/38] if iob_data.lastTemp is undefined, calculate lastTempAge from currenttemp.duration % 30 --- lib/determine-basal/determine-basal.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/determine-basal/determine-basal.js b/lib/determine-basal/determine-basal.js index 62cab4095..49a8276d1 100644 --- a/lib/determine-basal/determine-basal.js +++ b/lib/determine-basal/determine-basal.js @@ -184,9 +184,12 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ } } - var lastTempAge = 0; + var lastTempAge; if (typeof iob_data.lastTemp !== 'undefined' ) { lastTempAge = round(( new Date(systemTime).getTime() - iob_data.lastTemp.date ) / 60000); // in minutes + } else if (typeof currenttemp.duration !== 'undefined' ) { + // the second % 30 converts any lastTempAge of 30 to 0 + lastTempAge = (30 - currenttemp.duration % 30) % 30; } if (minAgo > 12 || minAgo < -5) { // Dexcom data is too old, or way in the future From 7d151b306dc92df1bdd6970d8315565fa20c0378 Mon Sep 17 00:00:00 2001 From: Scott Leibrand Date: Sun, 27 Aug 2023 22:11:32 -0700 Subject: [PATCH 36/38] use archive.debian.org for stretch now that it's EOL --- bin/openaps-install.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bin/openaps-install.sh b/bin/openaps-install.sh index 0e77d85d8..0ea3b557a 100755 --- a/bin/openaps-install.sh +++ b/bin/openaps-install.sh @@ -46,6 +46,16 @@ if cat /etc/os-release | grep 'PRETTY_NAME="Debian GNU/Linux 8 (jessie)"' &> /de echo "Jubilinux 0.2.0, based on Debian Jessie, is no longer receiving security or software updates!" fi +# Workaround for Debian Stretch migration to LTS +if cat /etc/os-release | grep 'PRETTY_NAME="Debian GNU/Linux 9 (stretch)"' &> /dev/null; then + # Disable valid-until check for archived Debian repos (expired certs) + echo "Acquire::Check-Valid-Until false;" | tee -a /etc/apt/apt.conf.d/10-nocheckvalid + # Replace apt sources.list with archive.debian.org locations + echo "deb http://archive.debian.org/debian/ stretch main contrib non-free" > /etc/apt/sources.list + echo "deb http://archive.debian.org/debian/ stretch-proposed-updates main contrib non-free" >> /etc/apt/sources.list + echo "deb http://archive.debian.org/debian-security stretch/updates main contrib non-free" >> /etc/apt/sources.list +fi + # TODO: remove the `-o Acquire::ForceIPv4=true` once Debian's mirrors work reliably over IPv6 apt-get -o Acquire::ForceIPv4=true update && apt-get -o Acquire::ForceIPv4=true -y dist-upgrade && apt-get -o Acquire::ForceIPv4=true -y autoremove apt-get -o Acquire::ForceIPv4=true update && apt-get -o Acquire::ForceIPv4=true install -y sudo strace tcpdump screen acpid vim locate ntpdate ntp From 052c3832fe2f22bf41c30220fcd440f1d652ea17 Mon Sep 17 00:00:00 2001 From: Scott Leibrand Date: Sun, 27 Aug 2023 22:14:00 -0700 Subject: [PATCH 37/38] IPv6 should be fine, but let's use defaults to preserve conf files --- bin/openaps-install.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/openaps-install.sh b/bin/openaps-install.sh index 0ea3b557a..b4da1c394 100755 --- a/bin/openaps-install.sh +++ b/bin/openaps-install.sh @@ -56,9 +56,8 @@ if cat /etc/os-release | grep 'PRETTY_NAME="Debian GNU/Linux 9 (stretch)"' &> /d echo "deb http://archive.debian.org/debian-security stretch/updates main contrib non-free" >> /etc/apt/sources.list fi -# TODO: remove the `-o Acquire::ForceIPv4=true` once Debian's mirrors work reliably over IPv6 -apt-get -o Acquire::ForceIPv4=true update && apt-get -o Acquire::ForceIPv4=true -y dist-upgrade && apt-get -o Acquire::ForceIPv4=true -y autoremove -apt-get -o Acquire::ForceIPv4=true update && apt-get -o Acquire::ForceIPv4=true install -y sudo strace tcpdump screen acpid vim locate ntpdate ntp +apt-get update && apt-get -o Dpkg::Options::="--force-confdef" -y dist-upgrade && apt-get -y autoremove +apt-get update && apt-get install -y sudo strace tcpdump screen acpid vim locate ntpdate ntp #check if edison user exists before trying to add it to groups grep "PermitRootLogin yes" /etc/ssh/sshd_config || echo "PermitRootLogin yes" >>/etc/ssh/sshd_config From d219baf9559d62a8bb0bd42014192a2d7c0839ef Mon Sep 17 00:00:00 2001 From: Scott Leibrand Date: Mon, 9 Mar 2026 10:46:50 -0700 Subject: [PATCH 38/38] Fix Stretch archived apt installs Rewrite Stretch sources to archive.debian.org only, remove dead Stretch entries, and add archive apt settings so later apt-get install steps succeed on archived repos. --- bin/openaps-install.sh | 30 ++++++++++++++++++++++++------ bin/openaps-packages.sh | 25 +++++++++++++++++++++++++ bin/oref0-setup.sh | 20 ++++++++++++++++++++ 3 files changed, 69 insertions(+), 6 deletions(-) diff --git a/bin/openaps-install.sh b/bin/openaps-install.sh index b4da1c394..6fb1ced6b 100755 --- a/bin/openaps-install.sh +++ b/bin/openaps-install.sh @@ -1,6 +1,29 @@ #!/usr/bin/env bash set -e +configure_archived_debian_repos() { + if grep 'PRETTY_NAME="Debian GNU/Linux 9 (stretch)"' /etc/os-release >/dev/null 2>&1; then + cat >/etc/apt/apt.conf.d/99stretch-archive <<'EOF' +Acquire::Check-Valid-Until "false"; +Acquire::AllowInsecureRepositories "true"; +Acquire::AllowDowngradeToInsecureRepositories "true"; +APT::Get::AllowUnauthenticated "true"; +EOF + cat >/etc/apt/sources.list <<'EOF' +deb [trusted=yes] http://archive.debian.org/debian stretch main contrib non-free +deb [trusted=yes] http://archive.debian.org/debian-security stretch/updates main contrib non-free +EOF + if [ -d /etc/apt/sources.list.d ]; then + find /etc/apt/sources.list.d -type f -name '*.list' -exec sed -i \ + -e '/deb\.debian\.org/d' \ + -e '/security\.debian\.org/d' \ + -e '/stretch-updates/d' \ + -e '/stretch-proposed-updates/d' \ + {} + + fi + fi +} + BRANCH=${1:-dev} read -p "Enter your rig's new hostname (this will be your rig's "name" in the future, so make sure to write it down): " -r myrighostname=$REPLY @@ -48,12 +71,7 @@ fi # Workaround for Debian Stretch migration to LTS if cat /etc/os-release | grep 'PRETTY_NAME="Debian GNU/Linux 9 (stretch)"' &> /dev/null; then - # Disable valid-until check for archived Debian repos (expired certs) - echo "Acquire::Check-Valid-Until false;" | tee -a /etc/apt/apt.conf.d/10-nocheckvalid - # Replace apt sources.list with archive.debian.org locations - echo "deb http://archive.debian.org/debian/ stretch main contrib non-free" > /etc/apt/sources.list - echo "deb http://archive.debian.org/debian/ stretch-proposed-updates main contrib non-free" >> /etc/apt/sources.list - echo "deb http://archive.debian.org/debian-security stretch/updates main contrib non-free" >> /etc/apt/sources.list + configure_archived_debian_repos fi apt-get update && apt-get -o Dpkg::Options::="--force-confdef" -y dist-upgrade && apt-get -y autoremove diff --git a/bin/openaps-packages.sh b/bin/openaps-packages.sh index 0fdb15242..ddbf117b7 100755 --- a/bin/openaps-packages.sh +++ b/bin/openaps-packages.sh @@ -5,9 +5,34 @@ die() { exit 1 } +configure_archived_debian_repos() { + if grep 'PRETTY_NAME="Debian GNU/Linux 9 (stretch)"' /etc/os-release >/dev/null 2>&1; then + cat >/etc/apt/apt.conf.d/99stretch-archive <<'EOF' +Acquire::Check-Valid-Until "false"; +Acquire::AllowInsecureRepositories "true"; +Acquire::AllowDowngradeToInsecureRepositories "true"; +APT::Get::AllowUnauthenticated "true"; +EOF + cat >/etc/apt/sources.list <<'EOF' +deb [trusted=yes] http://archive.debian.org/debian stretch main contrib non-free +deb [trusted=yes] http://archive.debian.org/debian-security stretch/updates main contrib non-free +EOF + if [ -d /etc/apt/sources.list.d ]; then + find /etc/apt/sources.list.d -type f -name '*.list' -exec sed -i \ + -e '/deb\.debian\.org/d' \ + -e '/security\.debian\.org/d' \ + -e '/stretch-updates/d' \ + -e '/stretch-proposed-updates/d' \ + {} + + fi + fi +} + # TODO: remove the `Acquire::ForceIPv4=true` once Debian's mirrors work reliably over IPv6 echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4 +configure_archived_debian_repos + apt-get install -y sudo sudo apt-get update && sudo apt-get -y upgrade ## Debian Bullseye (Raspberry Pi OS 64bit, etc) is python3 by default and does not support python2-pip. diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index 1c098cd8c..d457dff14 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -717,6 +717,26 @@ if prompt_yn "" N; then # Replace apt sources.list with archive.debian.org locations echo -e "deb http://security.debian.org/ jessie/updates main\n#deb-src http://security.debian.org/ jessie/updates main\n\ndeb http://archive.debian.org/debian/ jessie-backports main\n#deb-src http://archive.debian.org/debian/ jessie-backports main\n\ndeb http://archive.debian.org/debian/ jessie main contrib non-free\n#deb-src http://archive.debian.org/debian/ jessie main contrib non-free" > /etc/apt/sources.list fi + if grep 'PRETTY_NAME="Debian GNU/Linux 9 (stretch)"' /etc/os-release >/dev/null 2>&1; then + cat >/etc/apt/apt.conf.d/99stretch-archive <<'EOF' +Acquire::Check-Valid-Until "false"; +Acquire::AllowInsecureRepositories "true"; +Acquire::AllowDowngradeToInsecureRepositories "true"; +APT::Get::AllowUnauthenticated "true"; +EOF + cat >/etc/apt/sources.list <<'EOF' +deb [trusted=yes] http://archive.debian.org/debian stretch main contrib non-free +deb [trusted=yes] http://archive.debian.org/debian-security stretch/updates main contrib non-free +EOF + if [ -d /etc/apt/sources.list.d ]; then + find /etc/apt/sources.list.d -type f -name '*.list' -exec sed -i \ + -e '/deb\.debian\.org/d' \ + -e '/security\.debian\.org/d' \ + -e '/stretch-updates/d' \ + -e '/stretch-proposed-updates/d' \ + {} + + fi + fi #Mount the Edison's fat32 partition at /usr/local/go to give us lots of room to install golang if is_edison && [ -e /dev/mmcblk0p9 ] && ! mount | grep -qa mmcblk0p9 ; then