Skip to content

Instantly share code, notes, and snippets.

@guyromm
Created June 12, 2018 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guyromm/f6eeaeac9ef7e84645bb741d8f42fbf7 to your computer and use it in GitHub Desktop.
Save guyromm/f6eeaeac9ef7e84645bb741d8f42fbf7 to your computer and use it in GitHub Desktop.
fabric 1.x script to install an openvpn router
#!/usr/bin/env python
from fabric.api import *
from fabric.contrib.files import exists,append,comment,upload_template,sed
def openvpn_router_client(cfgpath):
sysctlcmd='net.ipv4.ip_forward=1'
run('sysctl -w %s'%sysctlcmd)
run('echo "%s" > /etc/sysctl.d/90-openvpn-router-ip-forward.conf'%sysctlcmd)
run('apt install -q -y openvpn ufw')
put(cfgpath+'/*','/etc/openvpn/')
append('/etc/default/openvpn','AUTOSTART=client')
run('systemctl daemon-reload')
run('service openvpn restart')
sed('/etc/default/ufw','DEFAULT_FORWARD_POLICY="DROP"','DEFAULT_FORWARD_POLICY="ACCEPT"')
run('ufw allow 22')
run('ufw enable')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment