Created
June 12, 2018 18:58
-
-
Save guyromm/f6eeaeac9ef7e84645bb741d8f42fbf7 to your computer and use it in GitHub Desktop.
fabric 1.x script to install an openvpn router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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