add setup script

pull/4/head v1.0.1
dadevel 3 years ago
parent c383e75597
commit c4c272b2eb
No known key found for this signature in database
GPG Key ID: 1A8A9735430193D5

1
.gitignore vendored

@ -1,2 +1 @@
__pycache__/

@ -1,21 +1,21 @@
# wg-netns
[wg-quick](https://git.zx2c4.com/wireguard-tools/about/src/man/wg-quick.8) with support for linux network namespaces.
It's a simple python script that implements the steps described at [wireguard.com/netns](https://www.wireguard.com/netns/#ordinary-containerization).
[wg-quick](https://git.zx2c4.com/wireguard-tools/about/src/man/wg-quick.8) with support for Linux network namespaces.
A simple Python script that implements the steps described at [wireguard.com/netns](https://www.wireguard.com/netns/#ordinary-containerization).
## Setup
Requirements:
- Linux
- Python 3.7 or newer
- `ip` from `iproute2`
- `wg` from `wireguard-tools`
- `ip` from iproute2
- `wg` from wireguard-tools
Just download the script and make it executable.
Installation:
~~~ bash
mkdir -p ~/.local/bin/ && curl -o ~/.local/bin/wg-netns https://raw.githubusercontent.com/dadevel/wg-netns/master/wg-netns.py && chmod 0755 ~/.local/bin/wg-netns
git clone --depth 1 https://github.com/dadevel/wg-netns.git
sudo ./wg-netns/setup.sh
~~~
## Usage
@ -144,4 +144,3 @@ socat tcp-listen:1234,reuseaddr,fork "exec:ip netns exec ns-example socat stdio
# terminal 3, test access
curl http://127.0.0.1:1234/hello.txt
~~~

@ -0,0 +1,9 @@
#!/bin/sh
PS4='> '
set -eux
PREFIX="${PREFIX:-/usr/local}"
cd "$(dirname "$0")"
install -m 0755 -D ./wg-netns.py "$PREFIX/bin/wg-netns"
install -m 0644 -D ./wg-netns@.service "$PREFIX/lib/systemd/system/wg-netns@.service"

@ -211,4 +211,3 @@ if __name__ == '__main__':
raise
print(f'error: {e} ({e.__class__.__name__})', file=sys.stderr)
sys.exit(2)

@ -9,9 +9,10 @@ Environment=WG_ENDPOINT_RESOLUTION_RETRIES=infinity
Environment=DEBUG_LEVEL=1
ExecStart=wg-netns up ./%i.json
ExecStop=wg-netns down ./%i.json
WorkingDirectory=%E/wg-netns
RemainAfterExit=yes
WorkingDirectory=%E/wg-netns
ConfigurationDirectory=wg-netns
[Install]
WantedBy=multi-user.target

Loading…
Cancel
Save