Skip to content

Commit 870815d

Browse files
authored
Merge pull request #4 from SloCompTech/develop
Partial rewrite
2 parents 669e1cc + 3aca21b commit 870815d

File tree

98 files changed

+2151
-1424
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+2151
-1424
lines changed

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog
22

3+
### 2.0.0 - Partial rewrite
4+
5+
- Moved `/config/hooks` to `/config/openvpn/hooks`
6+
- Renamed `/config/openvpn/server` to `config`
7+
- Changed base image to [slocomptech/baseimage-alpine](https://github.com/SloCompTech/docker-baseimage-alpine)
8+
- Moved all helper scripts to `/root/usr/local/bin`
9+
- Got rid of bash lib files
10+
- Hiearhicaly moved all commands under the hood of `ovpn` command
11+
- Improved backup command
12+
- Added restore command
13+
- Changed base image
14+
- Added **armhf** build
15+
316
### 1.0.6 - Bugfix
417

518
- Added missing `DNS` keyword to **dhcp-option** in example configs

CONTRIBUTING.md

+49-55
Original file line numberDiff line numberDiff line change
@@ -6,76 +6,70 @@ Feel free to contribute to this project.
66

77
Sections:
88

9-
- [Example configs & hooks](root/defaults/example/README.md)
9+
- [Example configs & hooks](root/defaults/example/README.md)
1010
- [Guides](docs/README.md)
1111
- [Helper Scripts](root/app/README.md)
1212
- [Modules](root/defaults/module/README.md)
1313

1414
## Syntax
1515

16-
- Identation: tab (4 spaces width)
16+
- Identation: space (2 spaces width)
1717
- Javadoc style documentation
1818

1919
## Directory structure of project
2020

2121
```
22-
/app # Utils (part of image)
23-
bin # Scripts for using this image
2422
/config # Configuration dir (all config is here, generated on container start)
25-
openvpn # Openvpn configuration
26-
ccd # Client config directory
27-
client # Client configuration directory
28-
<clientconffile>.conf # Base for building client config (all files merged)
29-
server # Server configuration directory
30-
<name>.conf # Server config files (all files merged)
31-
pki
32-
ca.crt # CA certificate
33-
certs by serial # Certs by Serial ID
34-
<serial-id-cert>.pem
35-
crl.pem # CRL
36-
dh.pem
37-
index.txt # Database index file
38-
issued
39-
<name>.crt # Certificates
40-
private # Directory with private keys
41-
ca.key # CA secret
42-
<name>.key # Certificate secrets
43-
reqs # Directroy with signing requests
44-
serial # The current serial number
45-
ta.key # Secret for tls-auth, tls-crypt
46-
ssl
47-
safessl-easyrsa.cnf
48-
vars
49-
example # Example configs (see root/defaults/example/README.md)
50-
config # Example client & server configs
51-
hook # Example hook configs
52-
module # Modules for openvpn
23+
backup # Folder where backups are generated
24+
example # Example configs (see root/defaults/example/README.md)
25+
module # Modules for openvpn
26+
openvpn # Openvpn configuration
27+
ccd # OpenVPN client-specific configuration directory (applied when client connects)
28+
client # Client configuration directory (for generation of .ovpn files)
29+
<clientconffile>.conf # Base for building client config (all files merged)
30+
config # Running config (server/client)
31+
<name>.conf # Config files (all files merged)
5332
hooks # Put your custom scripts in one of subfolders
54-
auth # On authentication (needs to be enabled in config)
55-
client-connect # Client connected
56-
client-disconnect # Client disconnected
57-
down # After interface is down
58-
finish # Deinit container
59-
init # Init container
60-
learn-address
61-
route-up # After routes are added
62-
route-pre-down # Before routes are removed
63-
up # After interface is up
64-
tls-verify # Check certificate
33+
auth # On authentication (needs to be enabled in config)
34+
client-connect # Client connected
35+
client-disconnect # Client disconnected
36+
down # After interface is down
37+
finish # Deinit container
38+
init # Init container
39+
learn-address
40+
route-up # After routes are added
41+
route-pre-down # Before routes are removed
42+
up # After interface is up
43+
tls-verify # Check certificate
6544
system.conf # System OpenVPN config file (do not edit, unless instructed)
66-
include-server.conf # File that includes all server configuration files (automatically generated)
67-
donotdelete # Leave this file alone, if deleted it triggers full setup
45+
include-conf.conf # File that includes all configuration files (automatically generated)
46+
pki
47+
ca.crt # CA certificate
48+
certs by serial # Certs by Serial ID
49+
<serial-id-cert>.pem
50+
crl.pem # CRL
51+
dh.pem
52+
index.txt # Database index file
53+
issued
54+
<name>.crt # Certificates
55+
private # Directory with private keys
56+
ca.key # CA secret
57+
<name>.key # Certificate secrets
58+
reqs # Directroy with signing requests
59+
secret.key # Static key (if not using real PKI)
60+
serial # The current serial number
61+
ta.key # Secret for tls-auth, tls-crypt
62+
ssl
63+
safessl-easyrsa.cnf
64+
vars
65+
tmp # Temporary folder
6866
/defaults # Default configuration, which is copied into config on full setup
69-
example # Examples
70-
config # Example configs
71-
hook # Example hooks
72-
module # Modules (for example password authentication ...)
73-
system.conf # Original server config
67+
...
7468
/etc # System config
75-
cont-init.d # Scripts run before services are started
76-
fix-attrs.d # Fix file permissions
77-
logrotate.d # Log settings
78-
services.d # Scripts that start services
69+
cont-init.d # Scripts run before services are started
70+
cont-finish.d # Scripts run after services are finished
71+
fix-attrs.d # Fix file permissions
72+
services.d # Scripts that start services
7973
```
8074

8175
## Useful links
@@ -92,4 +86,4 @@ Sections:
9286
- [OpenVPN docs](https://community.openvpn.net/openvpn/wiki/GettingStartedwithOVPN)
9387
- [Setup OpenVPN on alpine linux](https://wiki.alpinelinux.org/wiki/Setting_up_a_OpenVPN_server#Alternative_Certificate_Method)
9488
- [EasyRSA](https://community.openvpn.net/openvpn/wiki/GettingStartedwithOVPN)
95-
- [EasyRSA doc](https://github.com/OpenVPN/easy-rsa/tree/master/doc)
89+
- [EasyRSA doc](https://github.com/OpenVPN/easy-rsa/tree/master/doc)

Dockerfile

+49-38
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#
22
# Base image
3-
# @see https://github.com/linuxserver/docker-baseimage-alpine
4-
# @see https://github.com/linuxserver/docker-baseimage-alpine-python3
3+
# @see https://github.com/SloCompTech/docker-baseimage
54
#
6-
FROM lsiobase/alpine.python3:latest
5+
FROM slocomptech/baseimage:alpine
76

87
# Build arguments
98
ARG BUILD_DATE
@@ -17,61 +16,73 @@ ARG VERSION
1716
# @see http://label-schema.org/rc1/
1817
# @see https://semver.org/
1918
#
20-
LABEL org.opencontainers.image.title="OpenVPN Server" \
21-
org.label-schema.name="OpenVPN Server" \
22-
org.opencontainers.image.description="Docker image with OpenVPN server" \
23-
org.label-schema.description="Docker image with OpenVPN server" \
24-
org.opencontainers.image.url="https://github.com/SloCompTech/docker-openvpn" \
25-
org.label-schema.url="https://github.com/SloCompTech/docker-openvpn" \
26-
org.opencontainers.image.authors="Martin Dagarin <[email protected]>" \
27-
org.opencontainers.image.version=$VERSION \
28-
org.label-schema.version=$VERSION \
29-
org.opencontainers.image.revision=$VCS_REF \
30-
org.label-schema.vcs-ref=$VCS_REF \
31-
org.opencontainers.image.source=$VCS_SRC \
32-
org.label-schema.vcs-url=$VCS_SRC \
33-
org.opencontainers.image.created=$BUILD_DATE \
34-
org.label-schema.build-date=$BUILD_DATE \
35-
org.label-schema.schema-version="1.0"
19+
LABEL org.opencontainers.image.title="OpenVPN Server" \
20+
org.label-schema.name="OpenVPN Server" \
21+
org.opencontainers.image.description="Docker image with OpenVPN server" \
22+
org.label-schema.description="Docker image with OpenVPN server" \
23+
org.opencontainers.image.url="https://github.com/SloCompTech/docker-openvpn" \
24+
org.label-schema.url="https://github.com/SloCompTech/docker-openvpn" \
25+
org.opencontainers.image.authors="Martin Dagarin <[email protected]>" \
26+
org.opencontainers.image.version=$VERSION \
27+
org.label-schema.version=$VERSION \
28+
org.opencontainers.image.revision=$VCS_REF \
29+
org.label-schema.vcs-ref=$VCS_REF \
30+
org.opencontainers.image.source=$VCS_SRC \
31+
org.label-schema.vcs-url=$VCS_SRC \
32+
org.opencontainers.image.created=$BUILD_DATE \
33+
org.label-schema.build-date=$BUILD_DATE \
34+
org.label-schema.schema-version="1.0"
3635

3736

3837
#
3938
# Environment variables
4039
# @see https://github.com/OpenVPN/easy-rsa/blob/master/doc/EasyRSA-Advanced.md
4140
#
42-
ENV PATH="/app/bin:$PATH" \
43-
S6_BEHAVIOUR_IF_STAGE2_FAILS=0 \
44-
EASYRSA=/usr/share/easy-rsa \
41+
ENV EASYRSA=/usr/share/easy-rsa \
4542
EASYRSA_PKI=/config/pki \
4643
EASYRSA_VARS_FILE=/config/ssl/vars \
4744
#EASYRSA_SSL_CONF=/config/ssl/openssl-easyrsa.cnf \
4845
EASYRSA_SAFE_CONF=/config/ssl/safessl-easyrsa.cnf \
49-
EASYRSA_TEMP_FILE=/config/temp \
50-
OVPN_ROOT=/config \
51-
OVPN_HOOKS=/config/hooks \
52-
OVPN_RUN=system.conf
46+
EASYRSA_TEMP_FILE=/config/tmp/temp
5347

5448
# Install packages
55-
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/main/" >> /etc/apk/repositories && \
56-
apk add --no-cache \
49+
RUN apk add --no-cache \
5750
# Core packages
58-
bash sudo iptables ip6tables git openvpn easy-rsa && \
51+
bash \
52+
easy-rsa \
53+
iptables \
54+
ip6tables \
55+
openvpn \
56+
python3 \
57+
sudo && \
5958
# Link easy-rsa in bin directory
6059
ln -s ${EASYRSA}/easyrsa /usr/local/bin && \
6160
# Link python3 also as python
61+
ln -s /usr/bin/pip3 /usr/bin/pip && \
6262
ln -s /usr/bin/python3 /usr/bin/python && \
6363
# Remove any temporary files created by apk
6464
rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/* && \
6565
# Add permission for network management to user abc
66-
echo "abc ALL=(ALL) NOPASSWD: /sbin/ip, /sbin/ip6tables, /sbin/ip6tables-compat, /sbin/ip6tables-compat-restore, /sbin/ip6tables-compat-save, /sbin/ip6tables-restore, /sbin/ip6tables-restore-translate, \
67-
/sbin/ip6tables-save, /sbin/ip6tables-translate, /sbin/iptables, /sbin/iptables-compat, /sbin/iptables-compat-restore, /sbin/iptables-compat-save, \
68-
/sbin/iptables-restore, /sbin/iptables-restore-translate, /sbin/iptables-save, /sbin/iptables-translate, /sbin/route" \
69-
>> /etc/sudoers.d/abc
66+
echo "${CONTAINER_USER} ALL=(ALL) NOPASSWD: \
67+
/sbin/ip, \
68+
/sbin/ip6tables, \
69+
/sbin/ip6tables-compat, \
70+
/sbin/ip6tables-compat-restore, \
71+
/sbin/ip6tables-compat-save, \
72+
/sbin/ip6tables-restore, \
73+
/sbin/ip6tables-restore-translate, \
74+
/sbin/ip6tables-save, \
75+
/sbin/ip6tables-translate, \
76+
/sbin/iptables, \
77+
/sbin/iptables-compat, \
78+
/sbin/iptables-compat-restore, \
79+
/sbin/iptables-compat-save, \
80+
/sbin/iptables-restore, \
81+
/sbin/iptables-restore-translate, \
82+
/sbin/iptables-save, \
83+
/sbin/iptables-translate, \
84+
/sbin/route" \
85+
>> /etc/sudoers.d/${CONTAINER_USER}
7086

7187
# Add repo files to image
7288
COPY root/ /
73-
74-
# Configure
75-
RUN chmod +x /app/bin/* && \
76-
chmod +x /usr/local/sbin/* && \
77-
chmod -R 0644 /etc/logrotate.d

Dockerfile.armhf

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#
2+
# Base image
3+
# @see https://github.com/SloCompTech/docker-baseimage
4+
#
5+
FROM slocomptech/baseimage:alpine-armhf
6+
7+
# Build arguments
8+
ARG BUILD_DATE
9+
ARG VCS_REF
10+
ARG VCS_SRC
11+
ARG VERSION
12+
13+
#
14+
# Image labels
15+
# @see https://github.com/opencontainers/image-spec/blob/master/annotations.md
16+
# @see http://label-schema.org/rc1/
17+
# @see https://semver.org/
18+
#
19+
LABEL org.opencontainers.image.title="OpenVPN Server" \
20+
org.label-schema.name="OpenVPN Server" \
21+
org.opencontainers.image.description="Docker image with OpenVPN server" \
22+
org.label-schema.description="Docker image with OpenVPN server" \
23+
org.opencontainers.image.url="https://github.com/SloCompTech/docker-openvpn" \
24+
org.label-schema.url="https://github.com/SloCompTech/docker-openvpn" \
25+
org.opencontainers.image.authors="Martin Dagarin <[email protected]>" \
26+
org.opencontainers.image.version=$VERSION \
27+
org.label-schema.version=$VERSION \
28+
org.opencontainers.image.revision=$VCS_REF \
29+
org.label-schema.vcs-ref=$VCS_REF \
30+
org.opencontainers.image.source=$VCS_SRC \
31+
org.label-schema.vcs-url=$VCS_SRC \
32+
org.opencontainers.image.created=$BUILD_DATE \
33+
org.label-schema.build-date=$BUILD_DATE \
34+
org.label-schema.schema-version="1.0"
35+
36+
37+
#
38+
# Environment variables
39+
# @see https://github.com/OpenVPN/easy-rsa/blob/master/doc/EasyRSA-Advanced.md
40+
#
41+
ENV EASYRSA=/usr/share/easy-rsa \
42+
EASYRSA_PKI=/config/pki \
43+
EASYRSA_VARS_FILE=/config/ssl/vars \
44+
#EASYRSA_SSL_CONF=/config/ssl/openssl-easyrsa.cnf \
45+
EASYRSA_SAFE_CONF=/config/ssl/safessl-easyrsa.cnf \
46+
EASYRSA_TEMP_FILE=/config/tmp/temp
47+
48+
# Install packages
49+
RUN apk add --no-cache \
50+
# Core packages
51+
bash \
52+
easy-rsa \
53+
iptables \
54+
ip6tables \
55+
openvpn \
56+
python3 \
57+
sudo && \
58+
# Link easy-rsa in bin directory
59+
ln -s ${EASYRSA}/easyrsa /usr/local/bin && \
60+
# Link python3 also as python
61+
ln -s /usr/bin/pip3 /usr/bin/pip && \
62+
ln -s /usr/bin/python3 /usr/bin/python && \
63+
# Remove any temporary files created by apk
64+
rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/* && \
65+
# Add permission for network management to user abc
66+
echo "${CONTAINER_USER} ALL=(ALL) NOPASSWD: \
67+
/sbin/ip, \
68+
/sbin/ip6tables, \
69+
/sbin/ip6tables-compat, \
70+
/sbin/ip6tables-compat-restore, \
71+
/sbin/ip6tables-compat-save, \
72+
/sbin/ip6tables-restore, \
73+
/sbin/ip6tables-restore-translate, \
74+
/sbin/ip6tables-save, \
75+
/sbin/ip6tables-translate, \
76+
/sbin/iptables, \
77+
/sbin/iptables-compat, \
78+
/sbin/iptables-compat-restore, \
79+
/sbin/iptables-compat-save, \
80+
/sbin/iptables-restore, \
81+
/sbin/iptables-restore-translate, \
82+
/sbin/iptables-save, \
83+
/sbin/iptables-translate, \
84+
/sbin/route" \
85+
>> /etc/sudoers.d/${CONTAINER_USER}
86+
87+
# Add repo files to image
88+
COPY root/ /

0 commit comments

Comments
 (0)