Skip to content

Commit b07b495

Browse files
authored
Merge pull request #204 from kylemanna/docs_systemd
Document systemd service usage
2 parents 5e95b64 + 4725f36 commit b07b495

File tree

3 files changed

+74
-6
lines changed

3 files changed

+74
-6
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ a corresponding [Digital Ocean Community Tutorial](http://bit.ly/1AGUZkq).
5656
$ dig google.com # won't use the search directives in resolv.conf
5757
$ nslookup google.com # will use search
5858

59+
* Consider setting up a [systemd service](/docs/systemd.md) for automatic
60+
start-up at boot time and restart in the event the OpenVPN daemon or Docker
61+
crashes.
62+
5963
## How Does It Work?
6064

6165
Initialize the volume container using the `kylemanna/openvpn` image with the
@@ -166,7 +170,7 @@ of a guarantee in the future.
166170
volume for re-use across containers
167171
* Addition of tls-auth for HMAC security
168172

169-
## Tested On
173+
## Originally Tested On
170174

171175
* Docker hosts:
172176
* server a [Digital Ocean](https://www.digitalocean.com/?refcode=d19f7fe88c94) Droplet with 512 MB RAM running Ubuntu 14.04
@@ -175,8 +179,3 @@ of a guarantee in the future.
175179
* OpenVPN core 3.0 android armv7a thumb2 32-bit
176180
* OS X Mavericks with Tunnelblick 3.4beta26 (build 3828) using openvpn-2.3.4
177181
* ArchLinux OpenVPN pkg 2.3.4-1
178-
*
179-
180-
## Having permissions issues with Selinux enabled?
181-
182-
See [this](docs/selinux.md)

docs/systemd.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Docker + OpenVPN systemd Service
2+
3+
The systemd service aims to make the update and invocation of the
4+
`docker-openvpn` container seamless. It automatically downloads the latest
5+
`docker-openvpn` image and instantiates a Docker container with that image. At
6+
shutdown it cleans-up the old container.
7+
8+
In the event the service dies (crashes, or is killed) systemd will attempt to
9+
restart the service every 10 seconds until the service is stopped with
10+
`systemctl stop [email protected]`.
11+
12+
A number of IPv6 hacks are incorporated to workaround Docker shortcomings and
13+
are harmless for those not using IPv6.
14+
15+
To use and enable automatic start by systemd:
16+
17+
1. Create a Docker volume container named `ovpn-data-NAME` where `NAME` is the
18+
user's choice to describe the use of the container. In the example
19+
configuration given in the [README](/README.md) `NAME=data`.
20+
2. Initialize the data container according to the [docker-openvpn
21+
README](/README.md), but don't start the container. Stop the Docker
22+
container if started.
23+
3. Download the [[email protected]](https://raw.githubusercontent.com/kylemanna/docker-openvpn/master/init/docker-openvpn%40.service)
24+
file to `/etc/systemd/system`:
25+
26+
curl -L https://raw.githubusercontent.com/kylemanna/docker-openvpn/master/init/docker-openvpn%40.service | sudo tee /etc/systemd/system/[email protected]
27+
28+
4. Enable and start the service with:
29+
30+
systemctl enable --now [email protected]
31+
32+
5. Verify service start-up with:
33+
34+
systemctl status [email protected]
35+
journalctl --unit [email protected]
36+
37+
For more information, see the [systemd manual pages](https://www.freedesktop.org/software/systemd/man/index.html).

init/[email protected]

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
#
2+
# Docker + OpenVPN systemd service
3+
#
4+
# Author: Kyle Manna <[email protected]>
5+
# Source: https://github.com/kylemanna/docker-openvpn
6+
#
7+
# This service aims to make the update and invocation of the docker-openvpn
8+
# container seemless. It automatically downloads the latest docker-openvpn
9+
# image and instantiates a Docker container with that image. At shutdown it
10+
# cleans-up the old container.
11+
#
12+
# In the event the service dies (crashes, or is killed) systemd will attempt
13+
# to restart the service every 10 seconds until the service is stopped with
14+
# `systemctl stop docker-openvpn@NAME`.
15+
#
16+
# A number of IPv6 hacks are incorporated to workaround Docker shortcomings and
17+
# are harmless for those not using IPv6.
18+
#
19+
# To use:
20+
# 1. Create a Docker volume container named `ovpn-data-NAME` where NAME is the
21+
# user's choice to describe the use of the container.
22+
# 2. Initialize the data container according to the docker-openvpn README, but
23+
# don't start the container. Stop the docker container if started.
24+
# 3. Download this service file to /etc/systemd/service/[email protected]
25+
# 4. Enable and start the service template with:
26+
# `systemctl enable --now [email protected]`
27+
# 5. Verify service start-up with:
28+
# `systemctl status [email protected]`
29+
# `journalctl --unit [email protected]`
30+
#
31+
# For more information, see the systemd manual pages.
32+
#
133
[Unit]
234
Description=OpenVPN Docker Container
335
Documentation=https://github.com/kylemanna/docker-openvpn

0 commit comments

Comments
 (0)