#!/bin/sh

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

# Execute all connection scripts
for f in $(find /usr/libexec/ns-openvpn/connect-scripts/ -type f)
do
    if [ -x "$f" ]; then
        "$f" "$@"

	# if exit code is non-zero just exit with it
	exit_code=$?
        if [ $exit_code -gt 0 ]; then
            exit $exit_code
        fi
    fi
done

exit 0
