First Commit
This commit is contained in:
commit
dbdc5bcc4a
1791 files changed
+489451
No files matched your search
@@ -0,0 +1,30 @@
|
||||
# vim: ft=dockerfile
|
||||
|
||||
FROM alpine:latest as builder
|
||||
|
||||
WORKDIR /src
|
||||
RUN apk add --no-cache rust cargo \
|
||||
&& apk add openssl-dev \
|
||||
&& apk add --update alpine-sdk linux-headers \
|
||||
&& git clone --quiet https://github.com/zerotier/ZeroTierOne.git /src \
|
||||
&& git reset --quiet --hard ${ZTO_COMMIT} \
|
||||
&& make -f make-linux.mk
|
||||
|
||||
FROM alpine:latest
|
||||
LABEL version=${ZTO_VER}
|
||||
LABEL description="ZeroTier One docker image for Synology NAS"
|
||||
|
||||
RUN apk add --update --no-cache bash jq libc6-compat libstdc++
|
||||
|
||||
EXPOSE 9993/udp
|
||||
ENV MAX_WAIT_SECS SLEEP_TIME
|
||||
|
||||
COPY --from=builder /src/zerotier-one /usr/sbin/
|
||||
RUN mkdir -p /var/lib/zerotier-one \
|
||||
&& ln -s /usr/sbin/zerotier-one /usr/sbin/zerotier-idtool \
|
||||
&& ln -s /usr/sbin/zerotier-one /usr/sbin/zerotier-cli
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod 755 /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
@@ -0,0 +1,8 @@
|
||||
## Docker image for Synology's DSM7
|
||||
|
||||
Documentation: [docs.zerotier.com/devices/synology](https://docs.zerotier.com/devices/synology)
|
||||
|
||||
### Build & Push changes to DockerHub
|
||||
```shell
|
||||
./build.sh build
|
||||
```
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
ZTO_VER=$(git describe --tags $(git rev-list --tags --max-count=1))
|
||||
ZTO_COMMIT=$(git rev-parse HEAD)
|
||||
|
||||
build() {
|
||||
sudo docker login --username=${DOCKERHUB_USERNAME}
|
||||
|
||||
sudo docker buildx build \
|
||||
--push \
|
||||
--platform linux/arm/v7,linux/arm64/v8,linux/amd64 \
|
||||
--tag zerotier/zerotier-synology:${ZTO_VER} \
|
||||
--tag zerotier/zerotier-synology:latest \
|
||||
--build-arg ZTO_COMMIT=${ZTO_COMMIT} \
|
||||
--build-arg ZTO_VER=${ZTO_VER} \
|
||||
.
|
||||
}
|
||||
|
||||
"$@"
|
||||
Executable
+82
@@ -0,0 +1,82 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -uo pipefail
|
||||
|
||||
trap 'trap " " SIGTERM; kill 0; wait' SIGTERM SIGQUIT SIGINT
|
||||
|
||||
echo "Starting Zerotier-One"
|
||||
zerotier-one -d
|
||||
|
||||
echo "Wait for ZT service to come online before attempting queries..."
|
||||
MAX_WAIT_SECS="${MAX_WAIT_SECS:-90}"
|
||||
SLEEP_TIME="${SLEEP_TIME:-15}"
|
||||
if [[ "$SLEEP_TIME" -le 0 ]]
|
||||
then
|
||||
SLEEP_TIME=1
|
||||
fi
|
||||
|
||||
iterations=$((MAX_WAIT_SECS/SLEEP_TIME))
|
||||
online=false
|
||||
|
||||
for ((s=0; s<=iterations; s++))
|
||||
do
|
||||
online="$(zerotier-cli -j info | jq '.online' 2>/dev/null)"
|
||||
if [[ "$online" == "true" ]]
|
||||
then
|
||||
break
|
||||
fi
|
||||
sleep "$SLEEP_TIME"
|
||||
echo " ."
|
||||
done
|
||||
|
||||
if [[ "$online" != "true" ]]
|
||||
then
|
||||
echo "Waited $MAX_WAIT_SECS for zerotier-one to start, exiting." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "done."
|
||||
|
||||
(
|
||||
echo "Starting route helper"
|
||||
while true
|
||||
do
|
||||
if ! NETWORK_LIST="$(zerotier-cli -j listnetworks)"
|
||||
then
|
||||
echo "Route helper: $NETWORK_LIST" >&2
|
||||
exit 1
|
||||
fi
|
||||
NETWORK_COUNT="$(jq -r '. | length' <<< "$NETWORK_LIST")"
|
||||
if [[ "$NETWORK_COUNT" -gt 0 ]]
|
||||
then
|
||||
for ((j=0; j<=$((NETWORK_COUNT-1)); j++))
|
||||
do
|
||||
ALLOW_DEFAULT="$(jq -r '.['$j'].allowDefault' <<< "$NETWORK_LIST")"
|
||||
ROUTE_COUNT="$(jq -r '.['$j'].routes | length' <<< "$NETWORK_LIST")"
|
||||
for ((k=0; k<=$((ROUTE_COUNT-1)); k++))
|
||||
do
|
||||
ROUTE="$(jq -r '.['$j'].routes['$k'].target' <<< "$NETWORK_LIST")"
|
||||
VIA="$(jq -r '.['$j'].routes['$k'].via' <<< "$NETWORK_LIST")"
|
||||
if [[ -n "$ROUTE" ]]
|
||||
then
|
||||
# check if route is default and allowDefault enabled for this network
|
||||
if [[ "$ROUTE" == "0.0.0.0/0" && "$ALLOW_DEFAULT" == "false" ]]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
EXIST="$(ip -o route show "$ROUTE")"
|
||||
if [[ -z "${EXIST}" && "$VIA" == "null" ]]
|
||||
then
|
||||
IFNAME="$(jq -r '.['$j'] | .portDeviceName' <<< "$NETWORK_LIST")"
|
||||
echo " Adding route $ROUTE to dev $IFNAME"
|
||||
ip route add "$ROUTE" dev "$IFNAME"
|
||||
# Routes will be deleted when ZT brings the interface down
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
sleep 15
|
||||
done ) &
|
||||
|
||||
wait
|
||||
|
||||
Reference in new issue
Block a user