├── nightscout ├── start_nightscout.sh ├── start_nightscout-mg.sh ├── Readme.md └── ns-local-install.sh /nightscout: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # /etc/init.d/nightscout 3 | 4 | if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then 5 | set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script 6 | fi 7 | 8 | ### BEGIN INIT INFO 9 | # Provides: nightscout 10 | # Required-Start: $all 11 | # Required-Stop: $all 12 | # Default-Start: 2 3 4 5 13 | # Default-Stop: 0 1 6 14 | # Short-Description: Starts the DAEMON_PATH/DAEMONOPTS server 15 | # Description: Starts the DAEMON_PATH/DAEMONOPTS server 16 | ### END INIT INFO 17 | 18 | export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games 19 | 20 | DAEMON_PATH="/home/pi/cgm-remote-monitor" 21 | 22 | DAEMON=/usr/bin/sudo 23 | DAEMONOPTS="-u pi /home/pi/start_nightscout.sh" 24 | NAME=nightscout 25 | DESC="nightscout pi local script" 26 | PIDFILE=/var/run/$NAME.pid 27 | SCRIPTNAME=/etc/init.d/$NAME 28 | 29 | case "$1" in 30 | start) 31 | printf "%-50s" "Starting $NAME..." 32 | cd $DAEMON_PATH 33 | PID=`$DAEMON $DAEMONOPTS > /var/log/nightscout.log 2>&1 & echo $!` 34 | #echo "Saving PID" $PID " to " $PIDFILE 35 | if [ -z $PID ]; then 36 | printf "%s\n" "Fail" 37 | else 38 | echo $PID > $PIDFILE 39 | printf "%s\n" "Ok" 40 | fi 41 | ;; 42 | status) 43 | printf "%-50s" "Checking $NAME..." 44 | if [ -f $PIDFILE ]; then 45 | PID=`cat $PIDFILE` 46 | if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then 47 | printf "%s\n" "Process dead but pidfile exists" 48 | else 49 | echo "Running" 50 | fi 51 | else 52 | printf "%s\n" "Service not running" 53 | fi 54 | ;; 55 | stop) 56 | printf "%-50s" "Stopping $NAME" 57 | PID=`cat $PIDFILE` 58 | cd $DAEMON_PATH 59 | if [ -f $PIDFILE ]; then 60 | kill -HUP $PID 61 | printf "%s\n" "Ok" 62 | rm -f $PIDFILE 63 | else 64 | printf "%s\n" "pidfile not found" 65 | fi 66 | ;; 67 | restart) 68 | $0 stop 69 | $0 start 70 | ;; 71 | 72 | *) 73 | echo "Usage: $0 {status|start|stop|restart}" 74 | exit 1 75 | esac 76 | 77 | exit 0 -------------------------------------------------------------------------------- /start_nightscout.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd /home/pi/cgm-remote-monitor 3 | 4 | # See https://github.com/nightscout/cgm-remote-monitor#environment for a description of the fields 5 | # Required by Nightscout, please edit 6 | export CUSTOM_TITLE="my site name" 7 | export API_SECRET=my_12_characters_or_more_password 8 | 9 | # 10 | # Required by Nightscout 11 | # Used for building links to your sites api, ie pushover callbacks, usually the URL of your Nightscout site 12 | # TODO: get the FQDN here 13 | BASE_URL="http://`hostname`:1337/" 14 | 15 | # Required by Nightscout 16 | # Your mongo uri, for example: mongodb://sally:sallypass@ds099999.mongolab.com:99999/nightscout 17 | # TODO: secure mongo collection with generated username / password 18 | export MONGO_CONNECTION=mongodb://localhost:27017/nightscout 19 | 20 | # DISPLAY_UNITS. Choices: mg/dl and mmol. Setting to mmol puts the entire server into mmol mode by default, no further settings needed 21 | export DISPLAY_UNITS=mmol 22 | #export DISPLAY_UNITS=mg/dl 23 | 24 | export ENABLE="delta direction timeago devicestatus ar2 profile careportal boluscalc food rawbg iob cob bwp cage sage iage treatmentnotify basal pump openaps" 25 | export DISABLE="upbat errorcodes simplealarms bridge mmconnect loop" 26 | 27 | export TIME_FORMAT=24 28 | export NIGHT_MODE=off 29 | export SHOW_RAWBG=always 30 | 31 | export THEME=colors 32 | 33 | export ALARM_TIMEAGO_WARN=on 34 | export ALARM_TIMEAGO_WARN_MINS=15 35 | export ALARM_TIMEAGO_URGENT=on 36 | export ALARM_TIMEAGO_URGENT_MINS=30 37 | 38 | export PROFILE_HISTORY=off 39 | export PROFILE_MULTIPLE=off 40 | 41 | export BWP_WARN=0.50 42 | export BWP_URGENT=1.00 43 | export BWP_SNOOZE_MINS=10 44 | export BWP_SNOOZE=0.10 45 | 46 | export CAGE_ENABLE_ALERTS=true 47 | export export CAGE_INFO=44 48 | export CAGE_WARN=48 49 | export CAGE_URGENT=72 50 | export CAGE_DISPLAY=hours 51 | 52 | export SAGE_ENABLE_ALERTS=false 53 | export SAGE_INFO=144 54 | export SAGE_WARN=164 55 | export SAGE_URGENT=166 56 | 57 | export IAGE_ENABLE_ALERTS=false 58 | export IAGE_INFO=44 59 | export IAGE_WARN=48 60 | export IAGE_URGENT=72 61 | 62 | export TREATMENTNOTIFY_SNOOZE_MINS=10 63 | 64 | export BASAL_RENDER=default 65 | 66 | export BRIDGE_USER_NAME= 67 | export BRIDGE_PASSWORD= 68 | export BRIDGE_INTERVAL=150000 69 | export BRIDGE_MAX_COUNT=1 70 | export BRIDGE_FIRST_FETCH_COUNT=3 71 | export BRIDGE_MAX_FAILURES=3 72 | export BRIDGE_MINUTES=1400 73 | 74 | export MMCONNECT_USER_NAME= 75 | export MMCONNECT_PASSWORD= 76 | export MMCONNECT_INTERVAL=60000 77 | export MMCONNECT_MAX_RETRY_DURATION=32 78 | export MMCONNECT_SGV_LIMIT=24 79 | export MMCONNECT_VERBOSE=false 80 | export MMCONNECT_STORE_RAW_DATA=false 81 | 82 | export DEVICESTATUS_ADVANCED="true" 83 | 84 | export PUMP_ENABLE_ALERTS=true 85 | export PUMP_FIELDS="reservoir battery clock status" 86 | export PUMP_RETRO_FIELDS="reservoir battery clock" 87 | export PUMP_WARN_CLOCK=30 88 | export PUMP_URGENT_CLOCK=60 89 | export PUMP_WARN_RES=50 90 | export PUMP_URGENT_RES=10 91 | export PUMP_WARN_BATT_P=30 92 | export PUMP_URGENT_BATT_P=20 93 | export PUMP_WARN_BATT_V=1.35 94 | export PUMP_URGENT_BATT_V=1.30 95 | 96 | export OPENAPS_ENABLE_ALERTS=false 97 | export OPENAPS_WARN=30 98 | export OPENAPS_URGENT=60 99 | export OPENAPS_FIELDS="status-symbol status-label iob meal-assist rssi freq" 100 | export OPENAPS_RETRO_FIELDS="status-symbol status-label iob meal-assist rssi" 101 | 102 | export LOOP_ENABLE_ALERTS=false 103 | export LOOP_WARN=30 104 | export LOOP_URGENT=60 105 | 106 | export SHOW_PLUGINS=careportal 107 | export SHOW_FORECAST="ar2 openaps" 108 | 109 | export LANGUAGE=en 110 | export SCALE_Y=log 111 | export EDIT_MODE=on 112 | 113 | npm start 114 | -------------------------------------------------------------------------------- /start_nightscout-mg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd /home/pi/cgm-remote-monitor 3 | 4 | # See https://github.com/nightscout/cgm-remote-monitor#environment for a description of the fields 5 | # Required by Nightscout, please edit 6 | export CUSTOM_TITLE="my site name" 7 | export API_SECRET=my_12_characters_or_more_password 8 | 9 | # 10 | # Required by Nightscout 11 | # Used for building links to your sites api, ie pushover callbacks, usually the URL of your Nightscout site 12 | # TODO: get the FQDN here 13 | BASE_URL="http://`hostname`:1337/" 14 | 15 | # Required by Nightscout 16 | # Your mongo uri, for example: mongodb://sally:sallypass@ds099999.mongolab.com:99999/nightscout 17 | # TODO: secure mongo collection with generated username / password 18 | export MONGO_CONNECTION=mongodb://localhost:27017/nightscout 19 | 20 | # DISPLAY_UNITS. Choices: mg/dl and mmol. Setting to mmol puts the entire server into mmol mode by default, no further settings needed 21 | #export DISPLAY_UNITS=mmol 22 | export DISPLAY_UNITS=mg/dl 23 | 24 | export ENABLE="delta direction timeago devicestatus ar2 profile careportal boluscalc food rawbg iob cob bwp cage sage iage treatmentnotify basal pump openaps" 25 | export DISABLE="upbat errorcodes simplealarms bridge mmconnect loop" 26 | 27 | export TIME_FORMAT=24 28 | export NIGHT_MODE=off 29 | export SHOW_RAWBG=always 30 | 31 | export THEME=colors 32 | 33 | export ALARM_TIMEAGO_WARN=on 34 | export ALARM_TIMEAGO_WARN_MINS=15 35 | export ALARM_TIMEAGO_URGENT=on 36 | export ALARM_TIMEAGO_URGENT_MINS=30 37 | 38 | export PROFILE_HISTORY=off 39 | export PROFILE_MULTIPLE=off 40 | 41 | export BWP_WARN=0.50 42 | export BWP_URGENT=1.00 43 | export BWP_SNOOZE_MINS=10 44 | export BWP_SNOOZE=0.10 45 | 46 | export CAGE_ENABLE_ALERTS=true 47 | export export CAGE_INFO=44 48 | export CAGE_WARN=48 49 | export CAGE_URGENT=72 50 | export CAGE_DISPLAY=hours 51 | 52 | export SAGE_ENABLE_ALERTS=false 53 | export SAGE_INFO=144 54 | export SAGE_WARN=164 55 | export SAGE_URGENT=166 56 | 57 | export IAGE_ENABLE_ALERTS=false 58 | export IAGE_INFO=44 59 | export IAGE_WARN=48 60 | export IAGE_URGENT=72 61 | 62 | export TREATMENTNOTIFY_SNOOZE_MINS=10 63 | 64 | export BASAL_RENDER=default 65 | 66 | export BRIDGE_USER_NAME= 67 | export BRIDGE_PASSWORD= 68 | export BRIDGE_INTERVAL=150000 69 | export BRIDGE_MAX_COUNT=1 70 | export BRIDGE_FIRST_FETCH_COUNT=3 71 | export BRIDGE_MAX_FAILURES=3 72 | export BRIDGE_MINUTES=1400 73 | 74 | export MMCONNECT_USER_NAME= 75 | export MMCONNECT_PASSWORD= 76 | export MMCONNECT_INTERVAL=60000 77 | export MMCONNECT_MAX_RETRY_DURATION=32 78 | export MMCONNECT_SGV_LIMIT=24 79 | export MMCONNECT_VERBOSE=false 80 | export MMCONNECT_STORE_RAW_DATA=false 81 | 82 | export DEVICESTATUS_ADVANCED="true" 83 | 84 | export PUMP_ENABLE_ALERTS=true 85 | export PUMP_FIELDS="reservoir battery clock status" 86 | export PUMP_RETRO_FIELDS="reservoir battery clock" 87 | export PUMP_WARN_CLOCK=30 88 | export PUMP_URGENT_CLOCK=60 89 | export PUMP_WARN_RES=50 90 | export PUMP_URGENT_RES=10 91 | export PUMP_WARN_BATT_P=30 92 | export PUMP_URGENT_BATT_P=20 93 | export PUMP_WARN_BATT_V=1.35 94 | export PUMP_URGENT_BATT_V=1.30 95 | 96 | export OPENAPS_ENABLE_ALERTS=false 97 | export OPENAPS_WARN=30 98 | export OPENAPS_URGENT=60 99 | export OPENAPS_FIELDS="status-symbol status-label iob meal-assist rssi freq" 100 | export OPENAPS_RETRO_FIELDS="status-symbol status-label iob meal-assist rssi" 101 | 102 | export LOOP_ENABLE_ALERTS=false 103 | export LOOP_WARN=30 104 | export LOOP_URGENT=60 105 | 106 | export SHOW_PLUGINS=careportal 107 | export SHOW_FORECAST="ar2 openaps" 108 | 109 | export LANGUAGE=en 110 | export SCALE_Y=log 111 | export EDIT_MODE=on 112 | 113 | npm start 114 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | __Brief:__ 2 | 3 | Use this script to setup a complete local running Nightscout instance. This script can either install: 4 | - a local MongoDB instance or 5 | - work without MongoDB and use static OpenAPS report files (recommended for tiny rigs) 6 | 7 | __Tested with:__ 8 | 9 | - Raspberry Pi Zero (rpi0): Working with Raspian Jessie Lite (Release date: 2016-09-23) 10 | - Raspberry Pi 1 Model B (rpi1): Working with Raspian Jessie Lite with PIXEL (Release date: 2016-09-23) 11 | - Raspberry Pi 3 (rpi3): Everything works nicely with or without PIXEL (Release date: 2016-09-23 and 2016-11-25) 12 | 13 | __Prerequisites__ 14 | 15 | 0. Install Raspberry Pi SD kart with Rasbian. Download Raspbian at https://www.raspberrypi.org/downloads/raspbian/ 16 | You can you choose to use: 17 | - Rasbian Jessie with PIXEL: This has a graphical user interface, called PIXEL desktop 18 | - Raspbian Jessie Lite: A minimal image based on Debian Jessie. No desktop included. 19 | 20 | 1. Make sure your Raspberry kernel is up to date 21 | `$ sudo apt-get install rpi-update && sudo rpi-update ` 22 | and reboot. 23 | 24 | 2. Configure your Rasberry Pi 25 | `$ sudo raspi-config` 26 | ``` 27 | 1. Expand Filesystem ==> Make use of the whole SD-CARD 28 | 2. Change User Password 29 | 3. Bootoptions ==> Choose what you want 30 | 4. Wait for Network at Boot ==> Set to No 31 | 5. Internationalisation Options => Change Locale, Timezone, Keyboard Layout, Wi-Fi country to your needs 32 | 7. Advanced Options 33 | A2. Hostname ==> Set your hostname. This will be used for the URL of your Nightscout 34 | A4. SSH ==> Enable SSH for remote access 35 | ``` 36 | 3. Tweak your Raspberry Pi. 37 | See for example: https://openaps.readthedocs.io/en/latest/docs/walkthrough/phase-0/rpi.html for information on setting up your Raspberry Pi: 38 | - Configure WiFi Settings 39 | - Wifi reliability tweaks [optional] 40 | - Watchdog [optional] 41 | - Disable HDMI to conserve power [optional] 42 | - Configure Bluetooth Low Energy tethering [optional] 43 | 44 | __Usage:__ 45 | 46 | 1. open console on your raspi eg `ssh pi@192.168.10.4` default-password `raspberry` and run ns-local-install script for an interactive install: 47 | ``` 48 | curl -s https://raw.githubusercontent.com/SandraK82/deploy-ns-local-raspi/master/ns-local-install.sh | bash - 49 | ``` 50 | 51 | relax and drink some :coffee: - script runtime *over 1.5 hour* on clean and fresh raspi 1 or 2, and about 30 minutes on a raspi 3. 52 | 53 | You can also use a non-interactive install: 54 | ``` 55 | mkdir src 56 | cd src 57 | git clone https://github.com/SandraK82/deploy-ns-local-raspi.git 58 | cd deploy-ns-local-raspi 59 | ``` 60 | You can then use 61 | ``` 62 | bash ns-local-install.sh [--mongo=[yes|no]] [--units=[mmol|mg]] [--storage=[openaps|mongodb]] [--oref0=[yes|no]] [--units=[mmol|mg]] 63 | ``` 64 | For example: 65 | ``` 66 | bash ns-local-install.sh --mongo=yes --units=mmol --storage=mongo --oref0=yes 67 | ``` 68 | 69 | 2. after running the script you will have a running nightscout local installation. Now open editor with your config for nightscout. 70 | `nano /home/pi/cgm-remote-monitor/start-nightscout.sh` 71 | You need to configure at least the lines at the top of the file: 72 | `CUSTOM_TITLE=mysitename_without_spaces` 73 | `API_SECRET=my_12_characters_or_more_password`` 74 | 75 | Put your personal password (at least 12 characters long) and the name of your site (just for display) there! 76 | 77 | 3. once finished, restart nightscout with: `sudo /etc/init.d/nightscout stop && sudo /etc/init.d/nightscout start` 78 | 4. navigate to http://192.168.10.4:1337/ complete nightscout profile settings 79 | 5. Have fun :smiley: 80 | 81 | __Troubleshooting:__ 82 | 83 | * nodejs manual start: `pi@raspberrypi:~/cgm-remote-monitor $ start-nightscout.sh` (must be in cgm-remote-monitor directory) 84 | * nodejs / nightscout log: check `cat /var/log/openaps/nightscout.log` 85 | * mongodb check `cat /var/log/mongodb/mongodb.log` should contain: `[initandlisten] waiting for connections on port 27017` 86 | 87 | __Changelog:__ 88 | 89 | 2016-11-13: 90 | 91 | - upgrade nightscout to 0.9.1-dev-20161112, in order to support openaps-storage, see https://github.com/nightscout/cgm-remote-monitor/pull/2114 92 | 93 | 2016-10-14: 94 | 95 | - change to nightscout 0.9.0 stable ()Grilled Cheese) 96 | - add start_nightscout.sh instead of my.env 97 | 98 | 2016-09: 99 | ~~I forked the current dev-branch of nightscout/cgm-remote-monitor and changed the mongodb compatibility problems. Now it runs smoothly with mongodb 2.x on a raspi! 100 | Maybe the pull request gets accepted soon. As soon as I´m notified, I will change the script again to use the current dev-branch again.~~ 101 | The patches for mongo2.x compatibility are now merged back into the official dev branch. 102 | 103 | __With help from:__ 104 | 105 | - https://c-ville.gitbooks.io/test/content/ 106 | - http://yannickloriot.com/2016/04/install-mongodb-and-node-js-on-a-raspberry-pi/ 107 | - https://www.einplatinencomputer.com/raspberry-pi-node-js-installieren/ 108 | - contributions from PieterGit 109 | 110 | __Whishlist/To Do:__ 111 | - seperate username/password for Mongo 112 | - Nginx to use for https / letsencrypt certificate 113 | - Script to create wifi hotspot on the raspberry pi 114 | - Always install latest Node (now 6.8.0 instead of 6.7.0 what is being installed) 115 | - ... -------------------------------------------------------------------------------- /ns-local-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## from https://raw.githubusercontent.com/SandraK82/deploy-ns-local-raspi/master/ns-local-install.sh 4 | 5 | ## TODO: set /etc/domainname 6 | 7 | # make me current 8 | sudo apt-get update && sudo apt-get upgrade -y 9 | 10 | # parse command line options 11 | for i in "$@" 12 | do 13 | case $i in 14 | --mongo=*) 15 | INSTALL_MONGO="${i#*=}" 16 | shift # past argument=value 17 | ;; 18 | --units=*) 19 | UNITS="${i#*=}" 20 | shift # past argument=value 21 | ;; 22 | --storage=*) 23 | STORAGE="${i#*=}" 24 | shift # past argument=value 25 | ;; 26 | --oref0=*) 27 | INSTALL_OREF0="${i#*=}" 28 | shift # past argument=value 29 | ;; 30 | *) 31 | # unknown option 32 | echo "Option ${i#*=} unknown" 33 | ;; 34 | esac 35 | done 36 | 37 | if ! [[ ${INSTALL_MONGO,,} =~ "yes" || ${INSTALL_MONGO,,} =~ "no" ]]; then 38 | echo "" 39 | echo "Unsupported value for --mongo. Choose either 'yes' or 'no'. " 40 | echo 41 | INSTALL_MONGO="" # to force a Usage prompt 42 | fi 43 | 44 | if ! [[ ${UNITS,,} =~ "mmol" || ${UNITS,,} =~ "mg" ]]; then 45 | echo "" 46 | echo "Unsupported value for --units. Choose either 'mmol' or 'mg'" 47 | echo 48 | UNITS="" # to force a Usage prompt 49 | fi 50 | 51 | if ! [[ ${STORAGE,,} =~ "openaps" || ${STORAGE,,} =~ "mongo" ]]; then 52 | echo "" 53 | echo "Unsupported value for --storage. Choose either 'openaps' (Nightscout will use OpenAPS files) or 'mongo' (MongoDB backend store)" 54 | echo 55 | STORAGE="" # to force a Usage prompt 56 | fi 57 | 58 | 59 | if ! [[ ${INSTALL_OREF0,,} =~ "yes" || ${INSTALL_OREF0,,} =~ "no" ]]; then 60 | echo "" 61 | echo "Unsupported value for --oref0. Choose either 'yes' or 'no'. " 62 | echo 63 | INSTALL_OREF0="" # to force a Usage prompt 64 | fi 65 | 66 | 67 | if [[ -z "$INSTALL_MONGO" || -z "$UNITS" || -z "$STORAGE" || -z "$INSTALL_OREF0" ]]; then 68 | echo "Usage: ns-local-install.sh [--mongo=[yes|no]] [--units=[mmol|mg]] [--storage=[openaps|mongo]] [--oref0=[yes|no]]" 69 | read -p "Start interactive setup? [Y]/n " -r 70 | if [[ $REPLY =~ ^[Nn]$ ]]; then 71 | exit 72 | fi 73 | 74 | while true; do 75 | read -p "Do you want to install MongoDB? [Y]/n" -r 76 | case $REPLY in 77 | "") INSTALL_MONGO="yes" ; break;; 78 | [Yy]* ) INSTALL_MONGO="yes" ; break;; 79 | [Nn]* ) INSTALL_MONGO="no" ; break;; 80 | * ) echo "Please answer yes or no";; 81 | esac 82 | done 83 | 84 | while true; do 85 | read -p "Do you want to use mmol or mg [mmol]/mg]? " unit 86 | case $unit in 87 | "") UNITS="mmol" ; break;; 88 | mmol) UNITS="mmol"; break;; 89 | mg) UNITS="mg"; break;; 90 | * ) echo "Please answer mmol or mg.";; 91 | esac 92 | done 93 | 94 | echo "Nightscout has two options for storage:" 95 | echo "openaps: Nightscout will use the OpenAPS files" 96 | echo "mongodb: Nightscout will use a MongoDB" 97 | while true; do 98 | read -p "What storage do you want to use? Choose [mongodb] / openaps " storage 99 | case $storage in 100 | "") STORAGE="mongo" ; break;; 101 | mongodb) STORAGE="mongo"; break;; 102 | openaps) STORAGE="openaps"; break;; 103 | * ) echo "Please answer mongo or openaps. ";; 104 | esac 105 | done 106 | 107 | read -p " " -r 108 | =$REPLY 109 | 110 | while true; do 111 | read -p "Do you wish to install OpenAPS basic oref0? [Y]/n" yn 112 | case $yn in 113 | [Yy]* ) break;; 114 | [Nn]* ) break;; 115 | esac 116 | done 117 | INSTALL_OREF0=$yn 118 | 119 | fi 120 | 121 | # get the right node 122 | CPU_MODEL=$( awk '/model name/ {print $4}' < /proc/cpuinfo ) 123 | if [ "$CPU_MODEL" = "ARMv6-compatible" ] 124 | then 125 | echo "ARMv6 detected" 126 | # install node (on ARMv6 eg. Raspberry Model A/B/B+/A+/Zero) 127 | wget https://nodejs.org/dist/v6.7.0/node-v6.7.0-linux-armv6l.tar.xz 128 | tar -xvf node-v6.7.0-linux-armv6l.tar.xz 129 | cd node-v6.7.0-linux-armv6l 130 | sudo cp -R * /usr/local/ 131 | # check version should be v6.7.0 132 | node -v 133 | cd .. 134 | # clean up 135 | rm node-v6.7.0-linux-armv6l.tar.xz 136 | rm -r node-v6.7.0-linux-armv6l 137 | else 138 | echo "Assuming ARMv8 (Raspi 3))" 139 | # install node (on ARMv8 eg Raspberry 3 Model B) 140 | curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - 141 | sudo apt-get install -y nodejs 142 | fi 143 | 144 | # install dependencies 145 | # get git, mongodb 2.x from apt for now,and npm 146 | # optional extra packages to easily debug stuff or to do better maintenance 147 | EXTRAS="etckeeper tcsh lsof" 148 | sudo apt-get install --assume-yes git npm $EXTRAS 149 | 150 | if [[ ${INSTALL_MONGO,,} =~ "yes" || ${INSTALL_MONGO,,} =~ "y" ]]; then 151 | sudo apt-get install --assume-yes git mongodb-server 152 | # enable mongo 153 | sudo systemctl enable mongodb.service 154 | # check mongo status 155 | sudo systemctl status mongodb.service 156 | # get log of mongo 157 | #cat /var/log/mongodb/mongodb.log -> should contain: [initandlisten] waiting for connections on port 27017 158 | fi 159 | 160 | sudo npm cache clean -f 161 | sudo npm install npm -g 162 | sudo npm install n -g 163 | 164 | # select matching node 165 | sudo n 4.6 166 | 167 | # go home 168 | cd 169 | 170 | # get start script 171 | case $UNITS in 172 | mmol) curl -o start_nightscout.sh https://raw.githubusercontent.com/SandraK82/deploy-ns-local-raspi/master/start_nightscout.sh; break;; 173 | mg) curl -o start_nightscout.sh https://raw.githubusercontent.com/SandraK82/deploy-ns-local-raspi/master/start_nightscout-mg.sh; break;; 174 | esac 175 | 176 | chmod +rx start_nightscout.sh 177 | 178 | git clone https://github.com/nightscout/cgm-remote-monitor.git 179 | 180 | # switching to cgm-remote-monitor directory 181 | cd cgm-remote-monitor/ 182 | 183 | # switch to dev (latest development version) 184 | git checkout dev 185 | 186 | # setup ns 187 | ./setup.sh 188 | 189 | 190 | # make autoboot 191 | cd 192 | curl -o nightscout https://raw.githubusercontent.com/SandraK82/deploy-ns-local-raspi/master/nightscout 193 | sudo mv nightscout /etc/init.d/nightscout 194 | sudo chmod +x /etc/init.d/nightscout 195 | sudo /etc/init.d/nightscout start 196 | sudo /etc/init.d/nightscout status 197 | sudo insserv -d nightscout 198 | 199 | echo "deploy nightscout on raspi done :)" 200 | echo "Dont forget to edit: /home/pi/cgm-remote-monitor/start_nightscout.sh" 201 | echo "Nightscout logging can be found at: /var/log/openaps/nightscout.log" 202 | 203 | case $OREF0 in 204 | [Yy]* ) break;; 205 | [Nn]* ) exit;; 206 | esac 207 | 208 | # Setup basis oref0 stuff 209 | # https://openaps.readthedocs.io/en/master/docs/walkthrough/phase-2/oref0-setup.html 210 | curl -s https://raw.githubusercontent.com/openaps/docs/master/scripts/quick-packages.sh | bash - 211 | 212 | mkdir -p ~/src; cd ~/src && git clone -b dev git://github.com/openaps/oref0.git || (cd oref0 && git checkout dev && git pull) 213 | 214 | echo "Please continue with step 2 of https://openaps.readthedocs.io/en/master/docs/walkthrough/phase-2/oref0-setup.html" 215 | echo "cd && ~/src/oref0/bin/oref0-setup.sh" 216 | --------------------------------------------------------------------------------