mirror of
https://github.com/xubiaolin/docker-zerotier-planet.git
synced 2025-01-22 12:48:14 -05:00
fix-authtoken (#119)
This commit is contained in:
parent
b4c4bc636a
commit
ddfce29c28
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
.idea
|
.idea
|
||||||
|
/data
|
@ -61,7 +61,7 @@ COPY --from=builder /app/http_server.js /app/http_server.js
|
|||||||
|
|
||||||
RUN set -x ;sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
|
RUN set -x ;sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
|
||||||
&& apk update \
|
&& apk update \
|
||||||
&& apk add --no-cache npm curl jq\
|
&& apk add --no-cache npm curl jq openssl\
|
||||||
&& mkdir /app/config -p
|
&& mkdir /app/config -p
|
||||||
|
|
||||||
|
|
||||||
|
3
build.sh
Executable file
3
build.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
docker build -t xubiaolin/zerotier-planet:latest .
|
@ -19,7 +19,7 @@ function install() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
docker rm -f myztplanet
|
docker rm -f myztplanet
|
||||||
rm -f $(pwd)/data/zerotier
|
rm -rf $(pwd)/data/zerotier
|
||||||
|
|
||||||
ZT_PORT=9994
|
ZT_PORT=9994
|
||||||
API_PORT=3443
|
API_PORT=3443
|
||||||
@ -218,7 +218,7 @@ function update() {
|
|||||||
-e API_PORT=${API_PORT} \
|
-e API_PORT=${API_PORT} \
|
||||||
-e FILE_SERVER_PORT=${FILE_PORT} \
|
-e FILE_SERVER_PORT=${FILE_PORT} \
|
||||||
-v $(pwd)/data/zerotier/dist:/app/dist \
|
-v $(pwd)/data/zerotier/dist:/app/dist \
|
||||||
-v $(pwd)/data/zerotier/ztncui:/app/ztncui -v $(pwd)/data/zerotier/one:/var/lib/zerotier-one -v /data/config:/app/config xubiaolin/zerotier-planet:latest
|
-v $(pwd)/data/zerotier/ztncui:/app/ztncui -v $(pwd)/data/zerotier/one:/var/lib/zerotier-one -v $(pwd)/data/config:/app/config xubiaolin/zerotier-planet:latest
|
||||||
}
|
}
|
||||||
|
|
||||||
function menu() {
|
function menu() {
|
||||||
|
@ -9,26 +9,15 @@ function start() {
|
|||||||
cd /app/ztncui/src && npm start || exit 1
|
cd /app/ztncui/src && npm start || exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_ztncui() {
|
function check_file_server(){
|
||||||
mkdir -p /app/ztncui
|
if [ ! -f "/app/config/file_server.port" ]; then
|
||||||
if [ "$(ls -A /app/ztncui)" ]; then
|
echo "file_server.port is not exist, generate it"
|
||||||
echo "${API_PORT}" >/app/config/ztncui.port
|
echo "${FILE_SERVER_PORT}" >/app/config/file_server.port
|
||||||
echo "/app/ztncui is not empty, start directly"
|
echo "${FILE_SERVER_PORT}"
|
||||||
else
|
else
|
||||||
echo "/app/ztncui is empty, init data"
|
echo "file_server.port is exist, read it"
|
||||||
cp -r /bak/ztncui/* /app/ztncui/
|
FILE_SERVER_PORT=$(cat /app/config/file_server.port)
|
||||||
|
echo "${FILE_SERVER_PORT}"
|
||||||
echo "config ztncui"
|
|
||||||
mkdir -p /app/config
|
|
||||||
echo "${API_PORT}" >/app/config/ztncui.port
|
|
||||||
cd /app/ztncui/src
|
|
||||||
echo "HTTP_PORT=${API_PORT}" >.env &&
|
|
||||||
echo 'NODE_ENV=production' >>.env &&
|
|
||||||
echo 'HTTP_ALL_INTERFACES=true' >>.env &&
|
|
||||||
echo "ZT_ADDR=localhost:${ZT_PORT}" >>.env && echo "${ZT_PORT}" >/app/config/zerotier-one.port &&
|
|
||||||
cp -v etc/default.passwd etc/passwd && TOKEN=$(cat /var/lib/zerotier-one/authtoken.secret) &&
|
|
||||||
echo "ZT_TOKEN=$TOKEN" >>.env &&
|
|
||||||
echo "make ztncui success!"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,6 +33,7 @@ function check_zerotier() {
|
|||||||
|
|
||||||
cd /var/lib/zerotier-one
|
cd /var/lib/zerotier-one
|
||||||
echo "start mkmoonworld"
|
echo "start mkmoonworld"
|
||||||
|
openssl rand -hex 16 > authtoken.secret
|
||||||
|
|
||||||
./zerotier-idtool initmoon identity.public >moon.json
|
./zerotier-idtool initmoon identity.public >moon.json
|
||||||
|
|
||||||
@ -54,10 +44,8 @@ function check_zerotier() {
|
|||||||
echo "IP_ADDR6=$IP_ADDR6"
|
echo "IP_ADDR6=$IP_ADDR6"
|
||||||
|
|
||||||
ZT_PORT=$(cat /app/config/zerotier-one.port)
|
ZT_PORT=$(cat /app/config/zerotier-one.port)
|
||||||
API_PORT=$(cat /app/config/ztncui.port)
|
|
||||||
|
|
||||||
echo "ZT_PORT=$ZT_PORT"
|
echo "ZT_PORT=$ZT_PORT"
|
||||||
echo "API_PORT=$API_PORT"
|
|
||||||
|
|
||||||
if [ -z "$IP_ADDR4" ]; then stableEndpoints="[\"$IP_ADDR6/${ZT_PORT}\"]"; fi
|
if [ -z "$IP_ADDR4" ]; then stableEndpoints="[\"$IP_ADDR6/${ZT_PORT}\"]"; fi
|
||||||
if [ -z "$IP_ADDR6" ]; then stableEndpoints="[\"$IP_ADDR4/${ZT_PORT}\"]"; fi
|
if [ -z "$IP_ADDR6" ]; then stableEndpoints="[\"$IP_ADDR4/${ZT_PORT}\"]"; fi
|
||||||
@ -86,21 +74,31 @@ function check_zerotier() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_file_server(){
|
function check_ztncui() {
|
||||||
if [ ! -f "/app/config/file_server.port" ]; then
|
mkdir -p /app/ztncui
|
||||||
echo "file_server.port is not exist, generate it"
|
if [ "$(ls -A /app/ztncui)" ]; then
|
||||||
echo "${FILE_SERVER_PORT}" >/app/config/file_server.port
|
echo "${API_PORT}" >/app/config/ztncui.port
|
||||||
echo "${FILE_SERVER_PORT}"
|
echo "/app/ztncui is not empty, start directly"
|
||||||
else
|
else
|
||||||
echo "file_server.port is exist, read it"
|
echo "/app/ztncui is empty, init data"
|
||||||
FILE_SERVER_PORT=$(cat /app/config/file_server.port)
|
cp -r /bak/ztncui/* /app/ztncui/
|
||||||
echo "${FILE_SERVER_PORT}"
|
|
||||||
|
echo "config ztncui"
|
||||||
|
mkdir -p /app/config
|
||||||
|
echo "${API_PORT}" >/app/config/ztncui.port
|
||||||
|
cd /app/ztncui/src
|
||||||
|
echo "HTTP_PORT=${API_PORT}" >.env &&
|
||||||
|
echo 'NODE_ENV=production' >>.env &&
|
||||||
|
echo 'HTTP_ALL_INTERFACES=true' >>.env &&
|
||||||
|
echo "ZT_ADDR=localhost:${ZT_PORT}" >>.env && echo "${ZT_PORT}" >/app/config/zerotier-one.port &&
|
||||||
|
cp -v etc/default.passwd etc/passwd && TOKEN=$(cat /var/lib/zerotier-one/authtoken.secret) &&
|
||||||
|
echo "ZT_TOKEN=$TOKEN" >>.env &&
|
||||||
|
echo "make ztncui success!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
check_file_server
|
check_file_server
|
||||||
check_ztncui
|
|
||||||
check_zerotier
|
check_zerotier
|
||||||
|
check_ztncui
|
||||||
|
|
||||||
start
|
start
|
Loading…
Reference in New Issue
Block a user