Skip to content
This repository was archived by the owner on Jun 15, 2021. It is now read-only.

Commit e7ffd29

Browse files
author
Josh Stark
authored
Merge pull request #75 from linuxserver/rewrite
Rewrite of install/update logic, added mysql client for cluster support
2 parents 78ea2c1 + 9542e7e commit e7ffd29

File tree

7 files changed

+60
-35
lines changed

7 files changed

+60
-35
lines changed

Dockerfile

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,27 @@ RUN \
1515
apt-get update && \
1616
apt-get install -y \
1717
iptables \
18+
libmysqlclient-dev \
1819
net-tools \
19-
rsync && \
20-
echo "**** install openvpn-as ****" && \
20+
rsync \
21+
sqlite3 && \
22+
echo "**** download openvpn-as ****" && \
2123
if [ -z ${OPENVPNAS_VERSION+x} ]; then \
2224
OPENVPNAS_VERSION=$(curl -w "%{url_effective}" -ILsS -o /dev/null \
2325
https://openvpn.net/downloads/openvpn-as-latest-ubuntu16.amd_64.deb \
2426
| awk -F '(openvpn-as-|-Ubuntu16)' '{print $2}'); \
2527
fi && \
28+
mkdir /openvpn && \
2629
curl -o \
27-
/tmp/openvpn.deb -L \
30+
/openvpn/openvpn.deb -L \
2831
"https://swupdate.openvpn.org/as/openvpn-as-${OPENVPNAS_VERSION}-Ubuntu16.amd_64.deb" && \
29-
dpkg -i /tmp/openvpn.deb && \
3032
echo "**** ensure home folder for abc user set to /config ****" && \
3133
usermod -d /config abc && \
3234
echo "**** create admin user and set default password for it ****" && \
3335
useradd -s /sbin/nologin admin && \
3436
echo "admin:password" | chpasswd && \
35-
echo "**** configure openvpn-as ****" && \
36-
find /usr/local/openvpn_as/scripts -type f -print0 | \
37-
xargs -0 sed -i 's#/usr/local/openvpn_as#/config#g' && \
38-
find /usr/local/openvpn_as/bin -type f -print0 | \
39-
xargs -0 sed -i 's#/usr/local/openvpn_as#/config#g' && \
40-
sed -i \
41-
-e 's#=openvpn_as#=abc#g' \
42-
-e 's#~/tmp#/openvpn/tmp#g' \
43-
-e 's#~/sock#/openvpn/sock#g' \
44-
/usr/local/openvpn_as/etc/as_templ.conf && \
45-
echo "**** cleanup ****" && \
46-
apt-get clean && \
4737
rm -rf \
48-
/tmp/* \
49-
/usr/local/openvpn_as/etc/db/* \
50-
/usr/local/openvpn_as/etc/sock \
51-
/usr/local/openvpn_as/etc/tmp \
52-
/usr/local/openvpn_as/tmp \
53-
/var/lib/apt/lists/* \
54-
/var/tmp/*
38+
/tmp/*
5539

5640
# add local files
5741
COPY /root /

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ Below are the instructions for updating containers:
174174

175175
## Versions
176176

177+
* **03.04.19:** - Big rewrite of the install and update logic of openvpn-as to fix breaking changes (should fix updating from 2.6.1 to 2.7.3), added mysql-client for cluster support.
177178
* **14.03.19:** - Update deb package URL.
178179
* **21.02.19:** - Rebase to xenial due to incompatibility issues on some older host OSes.
179180
* **12.02.19:** - Rename github repo to match the docker hub repo and container name.

readme-vars.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ app_setup_block: |
6060
6161
# changelog
6262
changelogs:
63+
- { date: "03.04.19:", desc: "Big rewrite of the install and update logic of openvpn-as to fix breaking changes (should fix updating from 2.6.1 to 2.7.3), added mysql-client for cluster support." }
6364
- { date: "14.03.19:", desc: "Update deb package URL." }
6465
- { date: "21.02.19:", desc: "Rebase to xenial due to incompatibility issues on some older host OSes." }
6566
- { date: "12.02.19:", desc: "Rename github repo to match the docker hub repo and container name." }

root/etc/cont-init.d/30-config

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,51 @@ if [ ! -c /dev/net/tun ]; then
88
mknod /dev/net/tun c 10 200
99
fi
1010

11-
# copy config or update
12-
if [ ! -f /config/bin/ovpn-init ]; then
13-
cp -pr /usr/local/openvpn_as/* /config/
14-
else
15-
rsync -rlptD --exclude="/etc/as.conf" --exclude="/etc/config.json" --exclude="/tmp" /usr/local/openvpn_as/ /config/
11+
shopt -s extglob
12+
# install or update openvpn-as
13+
if [ -f /openvpn/openvpn.deb ]; then
14+
rm -rf /usr/local/openvpn_as
15+
ln -s /config /usr/local/openvpn_as
16+
if [ ! -f /config/etc/as.conf ]; then
17+
echo "installing openvpn-as for the first time"
18+
dpkg -i /openvpn/openvpn.deb
19+
rm /openvpn/openvpn.deb
20+
else
21+
echo "existing data found, reinstalling openvpn-as"
22+
mkdir -p /config/backup
23+
cd /config/etc/db || exit
24+
DBFILESBAK="*.db"
25+
for f in $DBFILESBAK
26+
do
27+
echo "backing up $f"
28+
sqlite3 "$f" .dump > /config/backup/"$f"
29+
done
30+
echo "backing up as.conf"
31+
cp /config/etc/as.conf /config/backup/as.conf
32+
cd /config || exit
33+
rm -rf !("backup"|"log")
34+
dpkg -i /openvpn/openvpn.deb
35+
rm /openvpn/openvpn.deb
36+
sed -i \
37+
-e 's#=openvpn_as#=abc#g' \
38+
-e 's#~/tmp#/openvpn/tmp#g' \
39+
-e 's#~/sock#/openvpn/sock#g' \
40+
/usr/local/openvpn_as/etc/as_templ.conf
41+
cd /config/backup || exit
42+
DBFILERES="*.db"
43+
for f in $DBFILERES
44+
do
45+
echo "restoring $f"
46+
rm -f /config/etc/db/"$f"
47+
sqlite3 </config/backup/"$f" /config/etc/db/"$f"
48+
done
49+
rm -f /config/etc/as.conf
50+
echo "restoring as.conf"
51+
cp /config/backup/as.conf /config/etc/as.conf
52+
rm -rf /config/backup
53+
fi
1654
fi
55+
shopt -u extglob
1756

1857
# clear old sock files
1958
for file in /openvpn/sock/*

root/etc/cont-init.d/40-openvpn-init

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ else
99
CONFINPUT=$NOASCONFIG$ASCONFIG
1010
fi
1111

12-
if [[ $(find /config/etc/db -type f | wc -l) -eq 0 || ! -f "/config/etc/as.conf" ]]; then
12+
if [[ $(find /config/etc/db -type f | wc -l) -eq 0 || ! -f "/config/etc/as.conf" || (-f "/config/etc/as.conf" && $(grep "vpn.server.user=openvpn_as" /config/etc/as.conf)) ]]; then
1313
# shellcheck disable=SC2059
14-
printf "${CONFINPUT}" | /config/bin/ovpn-init
14+
printf "${CONFINPUT}" | /usr/local/openvpn_as/bin/ovpn-init
1515
fi
1616

1717
chown -R abc:abc \

root/etc/cont-init.d/50-interface

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ else
66
SET_INTERFACE=$INTERFACE
77
fi
88

9-
/config/scripts/confdba -mk "admin_ui.https.ip_address" -v "$SET_INTERFACE"
10-
/config/scripts/confdba -mk "cs.https.ip_address" -v "$SET_INTERFACE"
11-
/config/scripts/confdba -mk "vpn.daemon.0.listen.ip_address" -v "$SET_INTERFACE"
12-
/config/scripts/confdba -mk "vpn.daemon.0.server.ip_address" -v "$SET_INTERFACE"
9+
/usr/local/openvpn_as/scripts/confdba -mk "admin_ui.https.ip_address" -v "$SET_INTERFACE"
10+
/usr/local/openvpn_as/scripts/confdba -mk "cs.https.ip_address" -v "$SET_INTERFACE"
11+
/usr/local/openvpn_as/scripts/confdba -mk "vpn.daemon.0.listen.ip_address" -v "$SET_INTERFACE"
12+
/usr/local/openvpn_as/scripts/confdba -mk "vpn.daemon.0.server.ip_address" -v "$SET_INTERFACE"
1313

root/etc/services.d/openvpn/run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/with-contenv bash
22

3-
/config/scripts/openvpnas --nodaemon --umask=0077 --pidfile=/openvpn/pid/openvpn.pid --logfile=/config/log/openvpn.log
3+
/usr/local/openvpn_as/scripts/openvpnas --nodaemon --umask=0077 --pidfile=/openvpn/pid/openvpn.pid --logfile=/config/log/openvpn.log

0 commit comments

Comments
 (0)