#! /bin/bash

# Early firewall stage; not a complete firewall configuration.
# This script must not call the routing script or wait for networking.

# Set to yes only after adding and reviewing your own rules below.
RULES_REVIEWED=no

run() {
    "$@" || {
        status=$?
        printf 'Failed (%s): %s\n' "$status" "$*" >&2
        exit "$status"
    }
}

if [ "$RULES_REVIEWED" != yes ]; then
    printf 'Add and review your firewall rules before running this outline.\n' >&2
    exit 1
fi

apply_firewall_rules() {
    # Replace this stub with your server-specific firewall rules and checks.
    # Use run for required commands; verify existing rules before adding them.
    # Treat inspection errors as failures, not as proof a rule is absent.
    # Limit cleanup to entries this script manages.
    # Do not require DNS, a configured address, or a reachable remote host.
    # Allow necessary setup traffic and cover every enabled address family.
    printf 'No firewall policy has been supplied.\n' >&2
    return 1
}

run apply_firewall_rules

exit 0
