From 8d9ef8b17dae6db5e30dfed5620d52ccc9a192f9 Mon Sep 17 00:00:00 2001 From: Francesco Vattiato Date: Mon, 19 Jan 2026 23:29:45 +0100 Subject: [PATCH] feat: Generate a random Nightscout API_SECRET during installation, save it to `~/nightscout.creds`, and update related documentation. --- frontend/public/json/nightscout.json | 4 ++-- install/nightscout-install.sh | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/frontend/public/json/nightscout.json b/frontend/public/json/nightscout.json index f4030da4a..05116582e 100644 --- a/frontend/public/json/nightscout.json +++ b/frontend/public/json/nightscout.json @@ -33,7 +33,7 @@ }, "notes": [ { - "text": "Nightscout requires configuring `my.env` with your Mongo connection string and API_SECRET. Default API_SECRET is `yoursecret123`.", + "text": "Nightscout requires configuring `my.env` with your Mongo connection string. API_SECRET has been generated and saved to `~/nightscout.creds`.", "type": "info" }, { @@ -41,7 +41,7 @@ "type": "info" }, { - "text": "Official Configuration Guide: [Nightscout Documentation](https://nightscout.github.io/nightscout/setup_variables/)", + "text": "Official Configuration Guide: https://nightscout.github.io/nightscout/setup_variables/", "type": "info" }, { diff --git a/install/nightscout-install.sh b/install/nightscout-install.sh index 98ea6c857..b8a1baa1c 100644 --- a/install/nightscout-install.sh +++ b/install/nightscout-install.sh @@ -14,9 +14,9 @@ update_os msg_info "Installing Dependencies" $STD apt install -y \ - git \ build-essential \ - libssl-dev + libssl-dev \ + openssl msg_ok "Installed Dependencies" MONGO_VERSION="8.0" setup_mongodb @@ -30,10 +30,11 @@ 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=yoursecret123 +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 @@ -58,6 +59,11 @@ 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