diff --git a/ct/nightscout.sh b/ct/nightscout.sh new file mode 100644 index 000000000..c88f61861 --- /dev/null +++ b/ct/nightscout.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2026 community-scripts ORG +# Author: aendel +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/nightscout/cgm-remote-monitor + +APP="Nightscout" +var_tags="${var_tags:-arr;health}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-2048}" +var_disk="${var_disk:-10}" +var_os="${var_os:-debian}" +var_version="${var_version:-12}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + if [[ ! -d /opt/nightscout ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + msg_info "Updating ${APP}" + systemctl stop nightscout + cd /opt/nightscout || exit + git pull + npm install + systemctl start nightscout + msg_ok "Updated ${APP}" + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:1337${CL}" +echo -e "${INFO}${YW} Configuration:${CL}" +echo -e "${TAB} Edit /opt/nightscout/my.env to configure your CGM source (Dexcom/CareLink)" +echo -e "${TAB} Then run: ${BGN}systemctl restart nightscout${CL}" diff --git a/frontend/public/json/nightscout.json b/frontend/public/json/nightscout.json new file mode 100644 index 000000000..a2c820352 --- /dev/null +++ b/frontend/public/json/nightscout.json @@ -0,0 +1,48 @@ +{ + "name": "Nightscout", + "slug": "nightscout", + "categories": [ + 0 + ], + "date_created": "2025-01-17", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 1337, + "documentation": "https://nightscout.github.io/", + "website": "http://www.nightscout.info/", + "logo": "https://raw.githubusercontent.com/nightscout/cgm-remote-monitor/master/static/images/large.png", + "config_path": "/opt/nightscout/my.env", + "description": "Nightscout is an open source, DIY project that allows real time access to a CGM data via personal website, smartwatch watchers, or apps and widgets available for smartphones.", + "install_methods": [ + { + "type": "default", + "script": "ct/nightscout.sh", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 10, + "os": "debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [ + { + "text": "Nightscout requires configuring `my.env` with your Mongo connection string and API_SECRET. Default API_SECRET is `yoursecret123`.", + "type": "info" + }, + { + "text": "Official Configuration Guide: [Nightscout Documentation](https://nightscout.github.io/nightscout/setup_variables/)", + "type": "link" + }, + { + "text": "Nightscout requires HTTPS for many features (security, tokens, PWA). Usage of a reverse proxy (e.g. Nginx Proxy Manager) is highly recommended.", + "type": "warning" + } + ] +} diff --git a/install/nightscout-install.sh b/install/nightscout-install.sh new file mode 100644 index 000000000..4d64de7b2 --- /dev/null +++ b/install/nightscout-install.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +# Copyright (c) 2021-2026 community-scripts ORG +# Author: aendel +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/nightscout/cgm-remote-monitor + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y git curl build-essential libssl-dev +msg_ok "Installed Dependencies" + +MONGO_VERSION="8.0" setup_mongodb +NODE_VERSION="22" setup_nodejs + +msg_info "Installing Nightscout (Patience)" +cd /opt || exit +git clone https://github.com/nightscout/cgm-remote-monitor.git nightscout +cd nightscout || exit +$STD npm install +msg_ok "Installed Nightscout" + +msg_info "Creating Service" +useradd -s /bin/bash -m nightscout +chown -R nightscout:nightscout /opt/nightscout + +# Create a default my.env file if it doesn't exist, to prevent crash on start if user doesn't configure it immediately? +# Nightscout needs env vars to run. We will create a template. +cat < /opt/nightscout/my.env +# DB connection string. +# MongoDB is installed locally on port 27017. +# You should create a DB and user in Mongo, or trust localhost auth. +# For simplicity in this script we assume localhost with no auth for local binding or the user must configure it. +# However, the installation guide recommends creating a user. +# For now, we point to localhost test DB. +MONGO_CONNECTION=mongodb://127.0.0.1:27017/nightscout +BASE_URL=http://localhost:1337 +API_SECRET=yoursecret123 +DISPLAY_UNITS=mg/dl +ENABLE=careportal boluscalc food bwp cage sage iage iob cob basal ar2 rawbg pushover bgi pump openaps pvb linear custom +# Allow HTTP (avoids redirect loops with reverse proxies) +INSECURE_USE_HTTP=true +EOF +chown nightscout:nightscout /opt/nightscout/my.env + +cat </etc/systemd/system/nightscout.service +[Unit] +Description=Nightscout CGM Service +After=network.target mongodb.service + +[Service] +Type=simple +User=nightscout +WorkingDirectory=/opt/nightscout +EnvironmentFile=/opt/nightscout/my.env +# Some deployments use 'npm start', others 'node server.js'. npm start is safer. +ExecStart=/usr/bin/npm start +Restart=always + +[Install] +WantedBy=multi-user.target +EOF + +systemctl enable -q --now nightscout +msg_ok "Created Service" + +motd_ssh +customize +cleanup_lxc