#!/bin/sh

#
# Copyright (C) 2026 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-2.0-only
#


> /etc/modules.d/ns-nathelpers

# Enable all conntrack/NAT helper modules shipped by the kmod-nf-nathelper* packages
/usr/bin/apk query --installed --format json --fields contents 'kmod-nf-nathelper*' 2>/dev/null \
    | jq -r '.[].contents[] | select(endswith(".ko")) | split("/")[-1] | rtrimstr(".ko")' \
    >> /etc/modules.d/ns-nathelpers

# Load all helpers
for m in $(cat /etc/modules.d/ns-nathelpers); do
    modprobe $m
done
