Skip to main content
fixed return code
Source Link
Zip
  • 1.1k
  • 8
  • 16

You can specify a script to be run as you connect to your vpn through openvpn with the up directive (among a few others that will run on different times during initalization). You may need to set script security too for that. Just append the following to your foo.ovpn file:

script-security 2
up /path/to/script.sh

In your case, this should be the latest possible before the disconnection sequence, as you'll need connectivity through the VPN:

script-security 2
route-up /path/to/script.sh

Note that openvpn won't process any packets as this command runs, so this script needs to be a caller script for your snaggle.sh, like this:

#!/bin/bash

nohup /path/to/snaggle.sh &

exit 10

As you also need to choose if you will run the script or not upon connecting, you can either use 2 different .ovpn files or use the command line parameter form (openvpn --config xxx.ovpn --script-security 2 --route-up /path/to/script.sh) instead of having these options inside the .ovpn file. You can even create an alias for that like openvpnsnaggle if typing is an issue.

To find out more about the other available options for running commands (after authentication, on ip changes, on disconnection, etc...), you can read about them on the documentation.

You can specify a script to be run as you connect to your vpn through openvpn with the up directive (among a few others that will run on different times during initalization). You may need to set script security too for that. Just append the following to your foo.ovpn file:

script-security 2
up /path/to/script.sh

In your case, this should be the latest possible before the disconnection sequence, as you'll need connectivity through the VPN:

script-security 2
route-up /path/to/script.sh

Note that openvpn won't process any packets as this command runs, so this script needs to be a caller script for your snaggle.sh, like this:

#!/bin/bash

nohup /path/to/snaggle.sh &

exit 1

As you also need to choose if you will run the script or not upon connecting, you can either use 2 different .ovpn files or use the command line parameter form (openvpn --config xxx.ovpn --script-security 2 --route-up /path/to/script.sh) instead of having these options inside the .ovpn file. You can even create an alias for that like openvpnsnaggle if typing is an issue.

To find out more about the other available options for running commands (after authentication, on ip changes, on disconnection, etc...), you can read about them on the documentation.

You can specify a script to be run as you connect to your vpn through openvpn with the up directive (among a few others that will run on different times during initalization). You may need to set script security too for that. Just append the following to your foo.ovpn file:

script-security 2
up /path/to/script.sh

In your case, this should be the latest possible before the disconnection sequence, as you'll need connectivity through the VPN:

script-security 2
route-up /path/to/script.sh

Note that openvpn won't process any packets as this command runs, so this script needs to be a caller script for your snaggle.sh, like this:

#!/bin/bash

nohup /path/to/snaggle.sh &

exit 0

As you also need to choose if you will run the script or not upon connecting, you can either use 2 different .ovpn files or use the command line parameter form (openvpn --config xxx.ovpn --script-security 2 --route-up /path/to/script.sh) instead of having these options inside the .ovpn file. You can even create an alias for that like openvpnsnaggle if typing is an issue.

To find out more about the other available options for running commands (after authentication, on ip changes, on disconnection, etc...), you can read about them on the documentation.

Grammar
Source Link
Zip
  • 1.1k
  • 8
  • 16

You can specify a script to be run as you connect to your vpn through openvpn with the up directive (among a few others that will run on different times during initalization). You may need to set script security too for that. Just append the following to your foo.ovpn file:

script-security 2
up /path/to/script.sh

In your case, this should be the latest possible before the disconnection sequence, as you'll need connectivity through the VPN:

script-security 2
route-up /path/to/script.sh

Note that openvpn won't process any packets as this command runs, so this script needs to be a caller script for your snaggle.sh, like this:

#!/bin/bash

nohup /path/to/snaggle.sh &

exit 1

As you also need to choose if you will run the script or not upon connecting, you can either use 2 different .ovpn files or use the command line parameter form (openvpn --config xxx.ovpn --script-security 2 --route-up /path/to/script.sh) instead of having these options inside the .ovpn file. You can even create an alias for that like openvpnsnaggle if typing is an issue.

To find out more about the other available options for running commands (after authentication, on ip changes, on disconnection, etc...). You, you can read about them on the documentation.

You can specify a script to be run as you connect to your vpn through openvpn with the up directive (among a few others that will run on different times during initalization). You may need to set script security too for that. Just append the following to your foo.ovpn file:

script-security 2
up /path/to/script.sh

In your case, this should be the latest possible before the disconnection sequence, as you'll need connectivity through the VPN:

script-security 2
route-up /path/to/script.sh

Note that openvpn won't process any packets as this command runs, so this script needs to be a caller script for your snaggle.sh, like this:

#!/bin/bash

nohup /path/to/snaggle.sh &

exit 1

As you also need to choose if you will run the script or not upon connecting, you can either use 2 different .ovpn files or use the command line parameter form (openvpn --config xxx.ovpn --script-security 2 --route-up /path/to/script.sh) instead of having these options inside the .ovpn file. You can even create an alias for that like openvpnsnaggle if typing is an issue.

To find out more about the other available options for running commands (after authentication, on ip changes, on disconnection, etc...). You can read about them on the documentation.

You can specify a script to be run as you connect to your vpn through openvpn with the up directive (among a few others that will run on different times during initalization). You may need to set script security too for that. Just append the following to your foo.ovpn file:

script-security 2
up /path/to/script.sh

In your case, this should be the latest possible before the disconnection sequence, as you'll need connectivity through the VPN:

script-security 2
route-up /path/to/script.sh

Note that openvpn won't process any packets as this command runs, so this script needs to be a caller script for your snaggle.sh, like this:

#!/bin/bash

nohup /path/to/snaggle.sh &

exit 1

As you also need to choose if you will run the script or not upon connecting, you can either use 2 different .ovpn files or use the command line parameter form (openvpn --config xxx.ovpn --script-security 2 --route-up /path/to/script.sh) instead of having these options inside the .ovpn file. You can even create an alias for that like openvpnsnaggle if typing is an issue.

To find out more about the other available options for running commands (after authentication, on ip changes, on disconnection, etc...), you can read about them on the documentation.

Reformulated the answer to accomodate more details added to the question.
Source Link
Zip
  • 1.1k
  • 8
  • 16

You can specify a script to be run as you connect to your vpn through openvpn with the up directive (among a few others that will run on different times during initalization). You may need to set script security too for that. Just append the following to your foo.ovpn file:

script-security 2
up /path/to/script.sh

In your case, this should be the latest possible before the disconnection sequence, as you'll need connectivity through the VPN:

script-security 2
route-up /path/to/script.sh

Note that openvpn won't process any packets as this command runs, so this script needs to be a caller script for your snaggle.sh, like this:

#!/bin/bash

nohup /path/to/snaggle.sh &

exit 1

As you also need to choose if you will run the script or not upon connecting, you can either use 2 different .ovpn files or use the command line parameter form (openvpn --config xxx.ovpn --script-security 2 --route-up /path/to/script.sh) instead of having these options inside the .ovpn file. You can even create an alias for that like openvpnsnaggle if typing is an issue.

To find out more about the other available options for running commands (after authentication, on ip changes, on disconnection, etc...). You can read about them on the documentation.

You can specify a script to be run as you connect to your vpn through openvpn with the up directive (among a few others that will run on different times during initalization). You may need to set script security too for that. Just append the following to your foo.ovpn file:

script-security 2
up /path/to/script.sh

In your case, this should be the latest possible before the disconnection sequence, as you'll need connectivity through the VPN:

script-security 2
route-up /path/to/script.sh

Note that openvpn won't process any packets as this command runs, so this script needs to be a caller script for your snaggle.sh, like this:

#!/bin/bash

nohup /path/to/snaggle.sh &

exit 1

As you also need to choose if you will run the script or not upon connecting, you can either use 2 different .ovpn files or use the command line parameter form (openvpn --config xxx.ovpn --script-security 2 --route-up /path/to/script.sh) instead of having these options inside the .ovpn file.

To find out more about the other available options for running commands (after authentication, on ip changes, on disconnection, etc...). You can read about them on the documentation.

You can specify a script to be run as you connect to your vpn through openvpn with the up directive (among a few others that will run on different times during initalization). You may need to set script security too for that. Just append the following to your foo.ovpn file:

script-security 2
up /path/to/script.sh

In your case, this should be the latest possible before the disconnection sequence, as you'll need connectivity through the VPN:

script-security 2
route-up /path/to/script.sh

Note that openvpn won't process any packets as this command runs, so this script needs to be a caller script for your snaggle.sh, like this:

#!/bin/bash

nohup /path/to/snaggle.sh &

exit 1

As you also need to choose if you will run the script or not upon connecting, you can either use 2 different .ovpn files or use the command line parameter form (openvpn --config xxx.ovpn --script-security 2 --route-up /path/to/script.sh) instead of having these options inside the .ovpn file. You can even create an alias for that like openvpnsnaggle if typing is an issue.

To find out more about the other available options for running commands (after authentication, on ip changes, on disconnection, etc...). You can read about them on the documentation.

Reformulated the answer to accomodate more details added to the question.
Source Link
Zip
  • 1.1k
  • 8
  • 16
Loading
Added information covering the "sometimes I need to connect and NOT run the script" part.
Source Link
Zip
  • 1.1k
  • 8
  • 16
Loading
Added more command options from openvpn regarding new information.; added 191 characters in body
Source Link
Zip
  • 1.1k
  • 8
  • 16
Loading
Source Link
Zip
  • 1.1k
  • 8
  • 16
Loading