Skip to content

Instantly share code, notes, and snippets.

@habedi
Forked from jaytaylor/etc.init.openvpn.conf
Created October 12, 2015 07:41
Show Gist options
  • Save habedi/62bf68cbd960c637c300 to your computer and use it in GitHub Desktop.
Save habedi/62bf68cbd960c637c300 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