#!/bin/bash

# Gluetun install hooks — post-start provider snapshot refresh + reattach
# any apps routed through gluetun (their network_mode holds a stale
# container ID after gluetun was just recreated) + offer to onboard
# existing apps.

gluetun_install_post_start()
{
    local app_name="$1"

    ((menu_number++))
    echo ""
    echo "---- $menu_number. Refreshing Gluetun provider snapshot."
    echo ""

    appWebuiRefresh_gluetun

    ((menu_number++))
    echo ""
    echo "---- $menu_number. Re-attaching gluetun-routed apps (post-recreate)."
    echo ""

    # Gluetun was just (re)created — every existing routed app holds a
    # stale container ID in its network_mode. Reattach them now so the
    # user doesn't have to chase silent netns drift later.
    appGluetunRoutedRecreate

    ((menu_number++))
    echo ""
    echo "---- $menu_number. Routing existing apps through Gluetun (optional)."
    echo ""

    gluetunRouteExistingAppsPrompt
}
