> ## Content Index
> Fetch the complete content index at: https://ostreff.info/llms.txt
> Use this file to discover other available public pages before exploring further.

# Automating Netdata Dashboard Updates: A Custom Bash Script for Seamless UI Upgrades
- URL: https://ostreff.info/automating-netdata-dashboard-updates-a-custom-bash-script-for-seamless-ui-upgrades/
- Published: 2026-10-28T19:49:33.000Z
- Updated: 2026-10-28T19:49:33.000Z
- Description: Netdata is an exceptional real-time performance and health monitoring tool. While its automated installation and update scripts handle most things out of the box, there are times when you want precise control over specific components - like keeping your web dashboard UI up to date.
- Author: Jordan Ostreff
- Tags: #netdata, #FreeBSD

To solve this, I put together a robust, production-ready Bash script that automates checking, downloading, backing up, and updating the Netdata web dashboard directly from Netdata Cloud's official tarball release.  
The Script  
Here is the complete script. 

```bash
#!/usr/bin/env bash
set -e

# Configuration
WEB_DIR="/usr/local/share/netdata/web"
[ ! -d "$WEB_DIR" ] && [ -d "/usr/share/netdata/web" ] && WEB_DIR="/usr/share/netdata/web"

DASHBOARD_URL="https://app.netdata.cloud/agent.tar.gz"
TMP_DIR="/tmp/netdata_dashboard_update"

# 1. Check root privileges
if [ "${EUID:-$(id -u)}" -ne 0 ]; then
  echo "Error: This script must be run as root (sudo)."
  exit 1
fi

# 2. Check required tools
for cmd in curl tar sed sort tail find; do
  if ! command -v $cmd &> /dev/null; then
    echo "Error: Tool '$cmd' is not installed."
    exit 1
  fi
done

# 3. Get installed dashboard version
get_installed_version() {
    ls "${WEB_DIR}/v3"/allFiles.*.json 2>/dev/null | \
        sed 's|.*/allFiles\.\(.*\)\.json|\1|' | \
        sort -V | tail -n 1
}

# 4. Get remote dashboard version directly from the archive
get_remote_version() {
    curl -sL "${DASHBOARD_URL}" | \
        tar -tzf - 2>/dev/null | \
        grep 'allFiles\..*\.json' | \
        sed -n 's/.*allFiles\.\(.*\)\.json/\1/p' | \
        sort -V | tail -n 1
}

CURRENT_VERSION=$(get_installed_version)
[ -z "$CURRENT_VERSION" ] && CURRENT_VERSION="none"

echo "--- Checking dashboard version ---"
echo "Current installed version: $CURRENT_VERSION"

echo "Fetching remote version from Netdata Cloud..."
REMOTE_VERSION=$(get_remote_version)

if [ -z "$REMOTE_VERSION" ]; then
    echo "Error: Could not retrieve remote dashboard version from $DASHBOARD_URL."
    exit 1
fi

echo "Latest remote version:    $REMOTE_VERSION"

# 5. Version comparison
if [ "$CURRENT_VERSION" == "$REMOTE_VERSION" ]; then
    echo "--> Dashboard is already up to date ($CURRENT_VERSION). No action needed."
    exit 0
fi

echo "--> New version detected ($REMOTE_VERSION)! Updating..."

# 6. Download and extract
rm -rf "$TMP_DIR"
mkdir -p "$TMP_DIR/extracted"

echo "Downloading $DASHBOARD_URL..."
curl -sL "$DASHBOARD_URL" -o "$TMP_DIR/agent.tar.gz"

echo "Extracting archive..."
tar -xzf "$TMP_DIR/agent.tar.gz" -C "$TMP_DIR/extracted"

# Locate the actual root folder containing the 'v3' directory
SRC_DIR="$TMP_DIR/extracted"
if [ ! -d "$SRC_DIR/v3" ]; then
    V3_PATH=$(find "$TMP_DIR/extracted" -mindepth 1 -maxdepth 3 -type d -name "v3" -print -quit)
    if [ -n "$V3_PATH" ]; then
        SRC_DIR=$(dirname "$V3_PATH")
    fi
fi

if [ ! -d "$SRC_DIR/v3" ]; then
    echo "Error: Could not locate 'v3' directory in extracted archive."
    rm -rf "$TMP_DIR"
    exit 1
fi

# 7. Create backup
BACKUP_DIR="${WEB_DIR}_backup_$(date +%Y%m%d_%H%M%S)"
echo "Creating backup in: $BACKUP_DIR"
cp -r "$WEB_DIR" "$BACKUP_DIR"

# 8. Replace web files
echo "Updating web files in $WEB_DIR..."
rm -rf "${WEB_DIR:?}"/*
cp -r "$SRC_DIR"/* "$WEB_DIR/"

# 9. Set permissions
if id "netdata" &>/dev/null; then
    chown -R netdata:netdata "$WEB_DIR"
fi

# Cleanup
rm -rf "$TMP_DIR"

echo "=== Successfully updated dashboard to $REMOTE_VERSION ==="
echo "Refresh your browser (Ctrl + F5) to use the new dashboard."
```

How It Works Under the Hood  
The script is engineered with several safeguards to ensure zero downtime issues or broken states:

1. Dynamic Path Resolution: It automatically checks standard web directory paths (`/usr/local/share/netdata/web` vs `/usr/share/netdata/web`) to fit different Linux distributions and installation methods.
2. Prerequisite Validation: It checks for essential command-line tools (`curl`, `tar`, `sed`, `sort`, `tail`, `find`) before doing anything else.
3. Smart Version Parsing: Instead of relying on a manifest API, it inspects file names (`allFiles.*.json`) in both the local directory and the remote `.tar.gz` archive, sorting them properly using `sort -V` (version sorting). If the versions match, it gracefully exits without touching the file system.
4. Automatic Safety Backups: Before making any destructive changes, the script creates a timestamped backup of your current dashboard files (e.g., `/usr/local/share/netdata/web_backup_20261028_214500`).
5. Permissions & Ownership: It automatically detects if the `netdata` system user exists and ensures proper ownership recursively (`chown -R netdata:netdata`).

How to Use It

Save the script to your server:

```bash
sudo nano /usr/local/bin/update_netdata_dashboard.sh
```

*(Paste the code above and save the file)*

Make it executable:

```bash
sudo chmod +x /usr/local/bin/update_netdata_dashboard.sh
```

Run the script:

```bash
sudo update_netdata_dashboard.sh
```

You can also automate this via Cron if you want your dashboard checked and updated weekly or monthly. Just remember to clear your browser cache (`Ctrl + F5`) after an update to load the latest UI assets cleanly!