mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-22 06:17:48 +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
|
FROM debian:buster
|
||||||
|
|
||||||
|
RUN apt-get update -qq && apt-get install openssl libssl1.1 -y
|
||||||
|
|
||||||
COPY --from=stage zerotier-one.deb .
|
COPY --from=stage zerotier-one.deb .
|
||||||
|
|
||||||
RUN dpkg -i zerotier-one.deb && rm -f 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
|
COPY entrypoint.sh.release /entrypoint.sh
|
||||||
RUN chmod 755 /entrypoint.sh
|
RUN chmod 755 /entrypoint.sh
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=1s CMD bash /healthcheck.sh
|
||||||
|
|
||||||
CMD []
|
CMD []
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
grepzt() {
|
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 $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,26 +40,45 @@ killzerotier() {
|
|||||||
|
|
||||||
trap killzerotier INT TERM
|
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"
|
echo "starting zerotier"
|
||||||
nohup /usr/sbin/zerotier-one &
|
nohup /usr/sbin/zerotier-one &
|
||||||
|
|
||||||
while ! grepzt
|
while ! grepzt
|
||||||
do
|
do
|
||||||
echo "zerotier hasn't started, waiting a second"
|
echo "zerotier hasn't started, waiting a second"
|
||||||
|
|
||||||
|
if [ -f nohup.out ]
|
||||||
|
then
|
||||||
|
tail -n 10 nohup.out
|
||||||
|
fi
|
||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "joining networks: $@"
|
echo "Writing healthcheck for networks: $@"
|
||||||
|
|
||||||
for i in "$@"
|
cat >/healthcheck.sh <<EOF
|
||||||
|
#!/bin/bash
|
||||||
|
for i in $@
|
||||||
do
|
do
|
||||||
echo "joining $i"
|
[ "\$(zerotier-cli get \$i status)" = "OK" ] || exit 1
|
||||||
|
|
||||||
while ! zerotier-cli join "$i"
|
|
||||||
do
|
|
||||||
echo "joining $i failed; trying again in 1s"
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
done
|
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