diff --git a/ct/nightscout.sh b/ct/nightscout.sh new file mode 100644 index 000000000..227342f2c --- /dev/null +++ b/ct/nightscout.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) +# Copyright (c) 2021-2026 community-scripts ORG +# Author: aendel +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE +# Source: https://github.com/nightscout/cgm-remote-monitor + +APP="Nightscout" +var_tags="${var_tags:-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:-13}" +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 + + if check_for_gh_release "nightscout" "nightscout/cgm-remote-monitor"; then + msg_info "Stopping Service" + systemctl stop nightscout + msg_ok "Stopped Service" + + fetch_and_deploy_gh_release "nightscout" "nightscout/cgm-remote-monitor" "source" + + msg_info "Updating Nightscout" + cd /opt/nightscout + $STD npm install + msg_ok "Updated Nightscout" + + msg_info "Starting Service" + systemctl start nightscout + msg_ok "Started Service" + msg_ok "Updated successfully!" + fi + 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}" diff --git a/frontend/public/json/nightscout.json b/frontend/public/json/nightscout.json new file mode 100644 index 000000000..05116582e --- /dev/null +++ b/frontend/public/json/nightscout.json @@ -0,0 +1,52 @@ +{ + "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. API_SECRET has been generated and saved to `~/nightscout.creds`.", + "type": "info" + }, + { + "text": "Edit `/opt/nightscout/my.env` to configure your CGM source (Dexcom/CareLink). Then run: `systemctl restart nightscout`", + "type": "info" + }, + { + "text": "Official Configuration Guide: https://nightscout.github.io/nightscout/setup_variables/", + "type": "info" + }, + { + "text": "Nightscout requires HTTPS for many features (security, tokens, PWA). Usage of a reverse proxy (e.g. Nginx Proxy Manager, Traefik, Caddy) is highly recommended.", + "type": "warning" + } + ] +} \ No newline at end of file diff --git a/install/nightscout-install.sh b/install/nightscout-install.sh new file mode 100644 index 000000000..b8a1baa1c --- /dev/null +++ b/install/nightscout-install.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +# Copyright (c) 2021-2026 community-scripts ORG +# Author: aendel +# License: MIT | https://github.com/community-scripts/ProxmoxVED/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 install -y \ + build-essential \ + libssl-dev \ + openssl +msg_ok "Installed Dependencies" + +MONGO_VERSION="8.0" setup_mongodb +NODE_VERSION="22" setup_nodejs +fetch_and_deploy_gh_release "nightscout" "nightscout/cgm-remote-monitor" "source" + +msg_info "Installing Nightscout" +$STD npm install --prefix /opt/nightscout +msg_ok "Installed Nightscout" + +msg_info "Creating Service" +useradd -s /bin/bash -m nightscout +chown -R nightscout:nightscout /opt/nightscout +API_SECRET=$(openssl rand -hex 16) +cat </opt/nightscout/my.env +MONGO_CONNECTION=mongodb://127.0.0.1:27017/nightscout +BASE_URL=http://localhost:1337 +API_SECRET=${API_SECRET} +DISPLAY_UNITS=mg/dl +ENABLE=careportal boluscalc food bwp cage sage iage iob cob basal ar2 rawbg pushover bgi pump openaps pvb linear custom +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 +ExecStart=/usr/bin/npm start +Restart=always + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now nightscout +msg_ok "Created Service" + +{ + echo "Nightscout Credentials" + echo "API_SECRET: ${API_SECRET}" +} >> ~/nightscout.creds + +motd_ssh +customize +cleanup_lxc