From fce34cdff06c2aabbc597bb6838b46f6d3e4c81c Mon Sep 17 00:00:00 2001 From: redxef Date: Sun, 28 Nov 2021 03:03:09 +0100 Subject: [PATCH] Improve readme, automatically fix up and down scripts in configuration. --- Makefile | 8 +++++--- README.md | 14 ++++++++++---- docker-compose.yml | 15 --------------- start-openvpn.sh | 6 +++++- 4 files changed, 20 insertions(+), 23 deletions(-) delete mode 100644 docker-compose.yml diff --git a/Makefile b/Makefile index 5988b02..b3fc02d 100644 --- a/Makefile +++ b/Makefile @@ -7,16 +7,18 @@ TAG = openvpn-aria2 build: build-docker $(START_SCRIPT) build-docker: $(DOCKERFILE) start-openvpn.sh + docker pull alpine docker build --tag=$(TAG) . - echo "This is a marker for the docker build." > $@ + @echo "This is a marker for the docker build." > $@ $(START_SCRIPT): $(START_SCRIPT_SRC) sed -e "s/{TAG}/$(TAG)/g" -e "s/{INSTALLATION_NAME}/$(INSTALLATION_NAME)/g" $< > $@ chmod +x $@ - clean: $(RM) build-docker $(START_SCRIPT) -install: +install: build install -D --mode=755 $(START_SCRIPT) /usr/local/bin/$(INSTALLATION_NAME) + +.PHONY: clean diff --git a/README.md b/README.md index 17998d4..55a2b85 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,13 @@ # Openvpn with torrent client -Just add your openvpn configuration `config.ovpn` and the authorization file -`auth.txt` and modify `config.ovpn` to use the auth file: `auth-user-pass /opt/auth.txt` +Put configuration files into `/etc/openvpn/client` and create +a file `/etc/openvpn-aria2.conf`: -Next run `./start` to drop into a shell as your user in your home directory. -Now you can use aria2 to download everything over a VPN. +``` +OVPN_CONFIGURATION_FILE=#name of file in /etc/openvpn/client, NOT the full path +``` + +Run `make build` to generate the docker image and `./start` to start +connect to the vpn inside the image. + +`make install` installs the start script under `/usr/local/bin/openvpn-aria2`. diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 8890e61..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,15 +0,0 @@ -version: '2.0' -services: - openvpn: - restart: never - build: - context: ./ - dockerfile: Dockerfile - volumes: - - ./config.ovpn:/opt/config.ovpn - - ./ovpn_config:/opt/ovpn_config - - ./auth.txt:/opt/auth.txt - - /etc/passwd:/etc/passwd - cap_add: - - NET_ADMIN - env_file: ./configuration.env diff --git a/start-openvpn.sh b/start-openvpn.sh index bfd6597..4a26512 100644 --- a/start-openvpn.sh +++ b/start-openvpn.sh @@ -13,7 +13,11 @@ create_net_dev() { } connect_vpn() { - openvpn --config "$OVPN_CONFIGURATION_FILE" --daemon + sed -e 's|^up .*$|up /etc/openvpn/up.sh|' \ + -e 's|^down .*$|down /etc/openvpn/down.sh|' \ + -e 's|^auth-user-pass.*$|auth-user-pass|' \ + "$OVPN_CONFIGURATION_FILE" > /tmp/ovpn.conf + openvpn --config /tmp/ovpn.conf --daemon } get_ip() {