#!/bin/bash
#
# Bash script for upgrading Nagios Network Analyzer
# Copyright 2014-2025 Nagios Enterprises, LLC. All Rights reserved.
#
# Upgrade Nagios Network Analyzer
#

NAVERSION_FILE="/var/www/html/nagiosna/naversion"

if [ -f "$NAVERSION_FILE" ]; then
    VERSION="$(grep '^VERSION=' "$NAVERSION_FILE" | cut -d '=' -f2)"
    
    if [ "$VERSION" -lt 500 ]; then
        echo "You are currently on a pre 2026R1 version of Nagios Network Analyzer. Please run use the migration script to upgrade to NNA 2026R1. From there you can continue to upgrade to the latest version. For more information see the documentation at https://assets.nagios.com/downloads/nagios-network-analyzer/docs/Migrating-from-Network-Analyzer-2024-to-2026.pdf"
    else
        echo "No upgrade needed, you are already on the latest version."
    fi
    
    exit 1
fi

echo "$NAVERSION_FILE does not exist, something went wrong."
exit 1