strange behavior with the --import-profile command

Official client software for OpenVPN Access Server and OpenVPN Cloud.
Post Reply
gallakos
OpenVpn Newbie
Posts: 2
Joined: Fri Jan 27, 2023 7:25 pm

strange behavior with the --import-profile command

Post by gallakos » Fri Jan 27, 2023 7:52 pm

Hello,

I created a bash script to add the VPN profiles, and randomly, I have the command --import-profile which does not run correctly.
On some computers, I have no response message.

On computers without output message. The profile is added in ~/Library/Application Support/OpenVPN Connect/profiles but it is not listed in the application or when I do a

Code: Select all

--list-profiles
Even when restarting the OpenVPN, they are not listed.
The only thing in common is that a command does not create output. I have both M1 and Intel or computers that already have a profile installed and the gdpr is well accepted before any order.

Code: Select all

local OVPN="/Applications/OpenVPN Connect/OpenVPN Connect.app/contents/MacOS/OpenVPN Connect"

echo "User : $currentUser"

# https://openvpn.net/vpn-server-resources/command-line-functionality-for-openvpn-connect/
"$OVPN" --minimize --accept-gdpr 2>/dev/null

local profiles=$("$OVPN" --list-profiles 2>/dev/null)

if ! /usr/bin/grep -iEq '(?:"|\[)office_v2(?:"|\])' <<<"$profiles"; then

    create_vpn
    download_profile

    if [ -e "$vpn_file" ]; then
        echo "Import..."
        result=$("$OVPN" --import-profile="$vpn_file" --name="office_v2" --pkp="$passphrase" 2>/dev/null)
        [[ "$result" =~ "success" ]] && echo "Import done" || echo "Error :" "$result"
        sleep 5
        "$OVPN" --list-profiles 2>/dev/null
    else
        die ".ovpn file not exists"
    fi
else
    die "office_v2 is already done"

fi


gallakos
OpenVpn Newbie
Posts: 2
Joined: Fri Jan 27, 2023 7:25 pm

Re: strange behavior with the --import-profile command

Post by gallakos » Mon Jan 30, 2023 1:32 pm

Small update, after several attempts, I found how to bypass the bug.
The user has to manually quit the app and restart it. If I quit the app with --quit it doesn't work

Post Reply