Skip to content

Instantly share code, notes, and snippets.

@jaytaylor
Created November 3, 2011 19:02
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jaytaylor/1337457 to your computer and use it in GitHub Desktop.
Save jaytaylor/1337457 to your computer and use it in GitHub Desktop.
Make OpenVPN run automatically as a service on Ubuntu. This includes an Upstart job and an expect script to automate OpenVPN private key password entry
# openvpn
#
description "OpenVPN - virtual private network daemon(s)"
author "Jay"
version "1.0.0"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
#exec /usr/sbin/openvpn --status /var/run/openvpn.client.status 10 --cd /etc/openvpn --config /etc/openvpn/client.conf --syslog openvpn
exec /etc/openvpn/autovpn
#!/usr/bin/expect -f
set force_conservative 0
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout -1
spawn /usr/sbin/openvpn --config /etc/openvpn/klout.conf
match_max 100000
expect -exact "Enter Private Key Password:"
send -- "PASSWORD_GOES_HERE\r"
expect eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment