#!/bin/sh
#
# Univention Setup
#  proxy 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 proxy")"

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

var="$(get_profile_var proxy/http)" ||
	exit 0

old_proxy="$(univention-config-registry get proxy/http)"

if [ -z "$var" ]; then
	univention-config-registry unset proxy/http proxy/https
else
	univention-config-registry set proxy/http="$var" proxy/https="$var"
fi

if [ -d "/var/lib/univention-system-setup/httpproxy.post" ]; then
	run-parts /var/lib/univention-system-setup/httpproxy.post --arg="$old_proxy" --arg="$var"
fi

exit 0
