mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-21 22:07:49 +00:00
Merge pull request #1596 from erikh/docker-image-fixes
Fix dockerfile & entrypoint:
This commit is contained in:
commit
76e30cf165
@ -11,6 +11,8 @@ RUN curl -sSL -o zerotier-one.deb "${PACKAGE_BASEURL}/zerotier-one_${VERSION}_${
|
||||
|
||||
FROM debian:buster
|
||||
|
||||
RUN apt-get update -qq && apt-get install openssl libssl1.1 -y
|
||||
|
||||
COPY --from=stage zerotier-one.deb .
|
||||
|
||||
RUN dpkg -i zerotier-one.deb && rm -f zerotier-one.deb
|
||||
@ -20,5 +22,7 @@ RUN rm -rf /var/lib/zerotier-one
|
||||
COPY entrypoint.sh.release /entrypoint.sh
|
||||
RUN chmod 755 /entrypoint.sh
|
||||
|
||||
HEALTHCHECK --interval=1s CMD bash /healthcheck.sh
|
||||
|
||||
CMD []
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
grepzt() {
|
||||
[ ! -n "$(cat /var/lib/zerotier-one/zerotier-one.pid)" -a -d "/proc/$(cat /var/lib/zerotier-one/zerotier-one.pid)" ]
|
||||
[ -f /var/lib/zerotier-one/zerotier-one.pid -a -n "$(cat /var/lib/zerotier-one/zerotier-one.pid)" -a -d "/proc/$(cat /var/lib/zerotier-one/zerotier-one.pid)" ]
|
||||
return $?
|
||||
}
|
||||
|
||||
@ -40,26 +40,45 @@ killzerotier() {
|
||||
|
||||
trap killzerotier INT TERM
|
||||
|
||||
echo "Configuring networks to join"
|
||||
mkdir -p /var/lib/zerotier-one/networks.d
|
||||
|
||||
echo "joining networks: $@"
|
||||
for i in "$@"
|
||||
do
|
||||
echo "Configuring join for $i"
|
||||
touch "/var/lib/zerotier-one/networks.d/${i}.conf"
|
||||
done
|
||||
|
||||
echo "starting zerotier"
|
||||
nohup /usr/sbin/zerotier-one &
|
||||
|
||||
while ! grepzt
|
||||
do
|
||||
echo "zerotier hasn't started, waiting a second"
|
||||
|
||||
if [ -f nohup.out ]
|
||||
then
|
||||
tail -n 10 nohup.out
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "joining networks: $@"
|
||||
echo "Writing healthcheck for networks: $@"
|
||||
|
||||
for i in "$@"
|
||||
cat >/healthcheck.sh <<EOF
|
||||
#!/bin/bash
|
||||
for i in $@
|
||||
do
|
||||
echo "joining $i"
|
||||
|
||||
while ! zerotier-cli join "$i"
|
||||
do
|
||||
echo "joining $i failed; trying again in 1s"
|
||||
sleep 1
|
||||
done
|
||||
[ "\$(zerotier-cli get \$i status)" = "OK" ] || exit 1
|
||||
done
|
||||
EOF
|
||||
|
||||
sleep infinity
|
||||
chmod +x /healthcheck.sh
|
||||
|
||||
echo "Sleeping infinitely"
|
||||
while true
|
||||
do
|
||||
sleep 1
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user