Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh -e
- script_dir="`dirname $0`"
- vpnconfig="client.conf"
- vpnlog="openvpn.log"
- vpnpidfile="openvpn.pid"
- vpnconnecttime="5" # seconds
- vpnresolvconf="resolv.conf"
- systemresolvconf="/etc/resolv.conf"
- if ! cd $script_dir ; then
- echo "Cannot cd to $script_dir." 1>&2
- exit 1
- fi
- sudo echo "Launching OpenVPN..."
- sudo openvpn $vpnconfig > $vpnlog &
- sleep 1 # wait for sudo to launch command
- vpnpid=$(ps --ppid $! -o pid=)
- echo $vpnpid > $vpnpidfile
- sleep $vpnconnecttime
- sudo cp $vpnresolvconf $systemresolvconf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement