How to auto connect FartiVPN with Python in MacOS

Pre-requirements

brew install openfortivpn

brew install pinentry-mac

python3 -m pip install auto_everything

Python Script

#config.file

host = ***.your_company.com
port = 443
username = yingshaoxo
set-dns = 0
pppd-use-peerdns = 0
#trusted-cert = 38ed44ef076ccadfacfade08f164ca0ceb2fbac0ae9cb74fd183e3e8(you will get it later
sudo openfortivpn --pinentry=pinentry-mac -c config.file
#autoConnect.py

from auto_everything.terminal import Terminal

t = Terminal()

while True:
    t.run("""
sudo openfortivpn --pinentry=pinentry-mac -c config.file
    """.strip())
sudo python3 autoConnect.py

More info

https://github.com/adrienverge/openfortivpn