#!/bin/sh
#
# Univention Setup
#  gateway change script
#
# SPDX-FileCopyrightText: 2004-2025 Univention GmbH
# SPDX-License-Identifier: AGPL-3.0-only

# shellcheck source=../setup_utils.sh
. /usr/lib/univention-system-setup/scripts/setup_utils.sh

info_header "$0" "$(gettext "Setting IPv6 gateway")"

[ "$check_ldap_access" = "1" ] &&
	exit 0

gateway6="$(get_profile_var ipv6/gateway)" ||
	exit 0

if [ -z "$gateway6" ]; then
	univention-config-registry unset ipv6/gateway
else
	univention-config-registry set ipv6/gateway="$gateway6"
fi

if [ -d "/var/lib/univention-system-setup/gateway.post" ]; then
	old_gateway6="$(univention-config-registry get ipv6/gateway)"
	run-parts /var/lib/univention-system-setup/gateway6.post --arg="$old_gateway6" --arg="$gateway6"
fi

exit 0
