You can try it by disconnecting the VPN connection and it should be activated automatically again. Now the bash script will run at startup and will keep checking if the VPN connection is active. "VPN Auto Connector", and for the command choose the. Open Applications->System Tools->Preferences->Startup Applications. run_interval="60" is the time interval in seconds for when to repeat the script. In my case connection="Auto Ethernet" is my active wired connection (haven't tested with wireless) and vpn_connection="My VPN connection" is the name of my VPN connection. They can be found by opening the network manager. Replace the values of the following three variables: (You may have to store the file somewhere else and/or alter the read/write/execture permissions as well if your computer has multiple users.)Ĭopy the code from above to the file you created. Right click file and choose Properties->Permissions and check "Allow executing file as program". vpn-auto-connector.sh (I saved it in my home folder. #! /bin/bashĪctive_connection=$(nmcli dev status | grep "$" ] Ĭreate a blank text file named e.g. 1 minute, and repeat the process indefinitely. If it is connected it will sleep for a given time, e.g. It checks if a given VPN connection is active, and will connect if not. I researched it a bit and combined some existing code to make my first bash script. Vpnautoconnect did not work for me in 12.04 LTS, and I dont seem to be the only one. To find out the value of YourVPNUUID for $VPNNAME simply run the following nmcli con list | grep -i vpn #not yet 3 falures - try starting normal way #TRY to knock hard way, resetting the network-manager (sometimes it happens in my kubuntu 12.04). Tested=$(nmcli con status uuid $VPNNAME | grep -c UUID) # enter desired time between checks here (in seconds) # YourVPN here is the name of desired vpn connection to monitor I would recommend checking out the script in this article: #!/bin/bash NetworkManager will now store the VPN password itself (see man nm-settings for details), and the network autoconnect will work once again.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |