Skip to content

Commit

Permalink
Use ipsec service
Browse files Browse the repository at this point in the history
- Use OpenRC to run the ipsec service in the Alpine-based image,
  instead of running the ipsec command directly.
  Ref: hwdsl2/setup-ipsec-vpn@a891b76
       gliderlabs/docker-alpine#437
  • Loading branch information
hwdsl2 committed Mar 28, 2022
1 parent 207eecc commit c545c24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ WORKDIR /opt/src
RUN set -x \
&& apk add --no-cache \
bash bind-tools coreutils openssl uuidgen wget xl2tpd iproute2 \
libcap-ng libcurl libevent linux-pam musl nspr nss nss-tools \
libcap-ng libcurl libevent linux-pam musl nspr nss nss-tools openrc \
bison flex gcc make libc-dev bsd-compat-headers linux-pam-dev \
nss-dev libcap-ng-dev libevent-dev curl-dev nspr-dev \
&& wget -t 3 -T 30 -nv -O libreswan.tar.gz "https://github.com/libreswan/libreswan/archive/v${SWAN_VER}.tar.gz" \
Expand All @@ -29,6 +29,8 @@ RUN set -x \
&& make -s base \
&& make -s install-base \
&& cd /opt/src \
&& mkdir -p /run/openrc \
&& touch /run/openrc/softlevel \
&& rm -rf "/opt/src/libreswan-${SWAN_VER}" \
&& apk del --no-cache \
bison flex gcc make libc-dev bsd-compat-headers linux-pam-dev \
Expand Down
5 changes: 3 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,9 @@ echo "Starting IPsec service..."
mkdir -p /run/pluto /var/run/pluto
rm -f /run/pluto/pluto.pid /var/run/pluto/pluto.pid
if [ "$os_type" = "alpine" ]; then
ipsec initnss >/dev/null
ipsec pluto --config /etc/ipsec.conf
sed -i '1c\#!/sbin/openrc-run' /etc/init.d/ipsec
rc-status >/dev/null 2>&1
rc-service ipsec start >/dev/null
else
service ipsec start >/dev/null 2>&1
fi
Expand Down

0 comments on commit c545c24

Please sign in to comment.