ah

🧩 Syntax:
#!/bin/bash

echo "==== Proxmox Wi-Fi Setup Tool ===="
echo "1) Prepare USB on ONLINE machine"
echo "2) Install packages and connect on Proxmox (OFFLINE)"
read -p "Choose an option [1 or 2]: " choice

# Common packages needed
PACKAGES="wpasupplicant iw wireless-tools"

if [[ "$choice" == "1" ]]; then
    echo "[*] Preparing offline install packages..."
    mkdir -p offline-wifi-packages
    cd offline-wifi-packages || exit 1

    # Install apt-rdepends if not already installed
    if ! command -v apt-rdepends >/dev/null 2>&1; then
        echo "[*] Installing apt-rdepends..."
        sudo apt update && sudo apt install -y apt-rdepends
    fi

    # Get all dependencies (excluding virtuals like debconf-2.0)
    echo "[*] Resolving package dependencies..."
    DEPS=$(apt-rdepends $PACKAGES | grep -v '^ ' | grep -v debconf-2.0 | sort -u)

    echo "[*] Downloading packages..."
    for pkg in $DEPS; do
        apt download "$pkg"
    done

    echo "[✓] Done! Copy the 'offline-wifi-packages' folder to your USB drive."
    exit 0
fi

if [[ "$choice" == "2" ]]; then
    echo "[*] Installing offline Wi-Fi packages..."
    read -p "Enter the full path to the USB folder with .deb packages: " debpath

    if [[ ! -d "$debpath" ]]; then
        echo "[!] Folder not found: $debpath"
        exit 1
    fi

    sudo dpkg -i "$debpath"/*.deb

    echo "[✓] Packages installed."

    echo
    echo "Now let's connect to Wi-Fi using iwctl:"
    echo "----------------------------------------"
    echo "Run these commands in the iwctl shell:"
    echo "  > station wlan0 scan"
    echo "  > station wlan0 get-networks"
    echo "  > station wlan0 connect YOUR_SSID"
    echo "----------------------------------------"
    echo
    echo "Starting iwctl..."
    iwctl
    exit 0
fi

echo "[!] Invalid option. Please choose 1 or 2."
exit 1