Merge pull request #1339 from aliaksei135/garmin-grafana

Garmin Grafana Updates
This commit is contained in:
CanbiZ (MickLesk) 2026-02-02 10:09:48 +01:00 committed by GitHub
commit 56625b1c76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 33 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/raw/main/misc/build.func)
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func)
# Copyright (c) 2021-2026 community-scripts ORG
# Author: aliaksei135
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE

View File

@ -17,19 +17,19 @@ update_os
# Installing Dependencies
msg_info "Installing Dependencies"
$STD apt-get install -y \
apt-transport-https \
software-properties-common \
lsb-base \
lsb-release \
python3 \
python3-requests \
python3-dotenv
apt-transport-https \
software-properties-common \
lsb-base \
lsb-release \
python3 \
python3-requests \
python3-dotenv
setup_uv
msg_ok "Installed Dependencies"
msg_info "Setting up InfluxDB Repository"
curl -fsSL "https://repos.influxdata.com/influxdata-archive_compat.key" | gpg --dearmor >/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg
echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main" >/etc/apt/sources.list.d/influxdata.list
curl -fsSL "https://repos.influxdata.com/influxdata-archive.key" | gpg --dearmor >/etc/apt/trusted.gpg.d/influxdata-archive.gpg
echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive.gpg] https://repos.influxdata.com/debian stable main" >/etc/apt/sources.list.d/influxdata.list
msg_ok "Set up InfluxDB Repository"
# garmin-grafana recommends influxdb v1
@ -37,8 +37,8 @@ msg_ok "Set up InfluxDB Repository"
msg_info "Installing InfluxDB"
$STD apt-get update
$STD apt-get install -y influxdb
curl -fsSL "https://dl.influxdata.com/chronograf/releases/chronograf_1.10.7_amd64.deb" -o "$(basename "https://dl.influxdata.com/chronograf/releases/chronograf_1.10.7_amd64.deb")"
$STD dpkg -i chronograf_1.10.7_amd64.deb
curl -fsSL "https://dl.influxdata.com/chronograf/releases/chronograf_1.10.9_amd64.deb" -o "$(basename "https://dl.influxdata.com/chronograf/releases/chronograf_1.10.9_amd64.deb")"
$STD dpkg -i chronograf_1.10.9_amd64.deb
msg_ok "Installed InfluxDB"
msg_info "Setting up InfluxDB"
@ -77,9 +77,9 @@ $STD grafana-cli plugins install marcusolsson-hourly-heatmap-panel
$STD systemctl restart grafana-server
# Output credentials to file
{
echo "Grafana Credentials"
echo "Grafana User: ${GRAFANA_USER}"
echo "Grafana Password: ${GRAFANA_PASS}"
echo "Grafana Credentials"
echo "Grafana User: ${GRAFANA_USER}"
echo "Grafana Password: ${GRAFANA_PASS}"
} >>~/garmin-grafana.creds
msg_ok "Set up Grafana"
@ -90,7 +90,7 @@ curl -fsSL -o "${RELEASE}.zip" "https://github.com/arpanghosh8453/garmin-grafana
unzip -q "${RELEASE}.zip"
# Remove the v prefix to RELEASE if it exists
if [[ "${RELEASE}" == v* ]]; then
RELEASE="${RELEASE:1}"
RELEASE="${RELEASE:1}"
fi
mv "garmin-grafana-${RELEASE}/" "/opt/garmin-grafana"
mkdir -p /opt/garmin-grafana/.garminconnect
@ -110,10 +110,11 @@ msg_ok "Installed garmin-grafana"
msg_info "Setting up garmin-grafana"
# Check if using Chinese garmin servers
if prompt_confirm "Are you using Garmin in mainland China?" "n" 60; then
GARMIN_CN="True"
read -rp "Are you using Garmin in mainland China? (y/N): " prompt
if [[ "${prompt,,}" =~ ^(y|yes|Y)$ ]]; then
GARMIN_CN="True"
else
GARMIN_CN="False"
GARMIN_CN="False"
fi
cat <<EOF >/opt/garmin-grafana/.env
@ -130,24 +131,24 @@ EOF
# garmin-grafana usually prompts the user for email and password (and MFA) on first run,
# then stores a refreshable token. We try to avoid storing user credentials in the env vars
if [ -z "$(ls -A /opt/garmin-grafana/.garminconnect)" ]; then
GARMIN_EMAIL=$(prompt_input "Please enter your Garmin Connect Email:" "" 120)
GARMIN_PASSWORD=$(prompt_password "Please enter your Garmin Connect Password (used to generate token, NOT stored):" "" 120)
GARMIN_MFA=$(prompt_input "Please enter your MFA Code (leave blank if not applicable):" "" 60)
# Run the script once to prompt for credential
msg_info "Creating Garmin credentials, this will timeout in 60 seconds"
timeout 60s uv run --env-file /opt/garmin-grafana/.env --project /opt/garmin-grafana/ /opt/garmin-grafana/src/garmin_grafana/garmin_fetch.py <<EOF
read -r -p "Please enter your Garmin Connect Email: " GARMIN_EMAIL
read -r -p "Please enter your Garmin Connect Password (this is used to generate a token and NOT stored): " GARMIN_PASSWORD
read -r -p "Please enter your MFA Code (if applicable, leave blank if not): " GARMIN_MFA
# Run the script once to prompt for credential
msg_info "Creating Garmin credentials, this will timeout in 60 seconds"
timeout 60s uv run --env-file /opt/garmin-grafana/.env --project /opt/garmin-grafana/ /opt/garmin-grafana/src/garmin_grafana/garmin_fetch.py <<EOF
${GARMIN_EMAIL}
${GARMIN_PASSWORD}
${GARMIN_MFA}
EOF
unset GARMIN_EMAIL
unset GARMIN_PASSWORD
unset GARMIN_MFA
# Check if there is anything in the token dir now
if [ -z "$(ls -A /opt/garmin-grafana/.garminconnect)" ]; then
msg_error "Failed to create a token"
exit
fi
unset GARMIN_EMAIL
unset GARMIN_PASSWORD
unset GARMIN_MFA
# Check if there is anything in the token dir now
if [ -z "$(ls -A /opt/garmin-grafana/.garminconnect)" ]; then
msg_error "Failed to create a token"
exit
fi
fi
$STD systemctl restart grafana-server