From f9d3ecec6acd6bf869ad6c68d02b26f7d939f754 Mon Sep 17 00:00:00 2001 From: Francesco Vattiato Date: Sun, 18 Jan 2026 14:43:15 +0100 Subject: [PATCH] feat: Refactor Nightscout update logic to use `fetch_and_deploy_gh_release`, streamline dependency installation, and update post-install messages and CT tags. --- ct/nightscout.sh | 46 ++++++++++++++++------------ frontend/public/json/nightscout.json | 8 +++-- install/nightscout-install.sh | 12 +++++--- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/ct/nightscout.sh b/ct/nightscout.sh index 105a9fbd8..d2a934f02 100644 --- a/ct/nightscout.sh +++ b/ct/nightscout.sh @@ -6,7 +6,7 @@ source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/ # Source: https://github.com/nightscout/cgm-remote-monitor APP="Nightscout" -var_tags="${var_tags:-arr;health}" +var_tags="${var_tags:-health}" var_cpu="${var_cpu:-2}" var_ram="${var_ram:-2048}" var_disk="${var_disk:-10}" @@ -20,31 +20,39 @@ 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 - git pull - npm install - systemctl start nightscout - msg_ok "Updated ${APP}" + 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 ${APP}" + cd /opt/nightscout + $STD npm install + msg_ok "Updated ${APP}" + + 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" +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 index a2c820352..a6f72d28e 100644 --- a/frontend/public/json/nightscout.json +++ b/frontend/public/json/nightscout.json @@ -36,13 +36,17 @@ "text": "Nightscout requires configuring `my.env` with your Mongo connection string and API_SECRET. Default API_SECRET is `yoursecret123`.", "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: [Nightscout Documentation](https://nightscout.github.io/nightscout/setup_variables/)", - "type": "link" + "type": "info" }, { "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" } ] -} +} \ No newline at end of file diff --git a/install/nightscout-install.sh b/install/nightscout-install.sh index 111fcb62c..f04dc7593 100644 --- a/install/nightscout-install.sh +++ b/install/nightscout-install.sh @@ -13,14 +13,18 @@ network_check update_os msg_info "Installing Dependencies" -$STD apt install -y git build-essential libssl-dev +$STD apt install -y \ + git \ + build-essential \ + libssl-dev msg_ok "Installed Dependencies" MONGO_VERSION="8.0" setup_mongodb NODE_VERSION="22" setup_nodejs -msg_info "Installing Nightscout (Patience)" 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" @@ -28,7 +32,7 @@ msg_info "Creating Service" useradd -s /bin/bash -m nightscout chown -R nightscout:nightscout /opt/nightscout -cat > /opt/nightscout/my.env </opt/nightscout/my.env MONGO_CONNECTION=mongodb://127.0.0.1:27017/nightscout BASE_URL=http://localhost:1337 API_SECRET=yoursecret123 @@ -38,7 +42,7 @@ INSECURE_USE_HTTP=true EOF chown nightscout:nightscout /opt/nightscout/my.env -cat > /etc/systemd/system/nightscout.service </etc/systemd/system/nightscout.service [Unit] Description=Nightscout CGM Service After=network.target mongodb.service