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
|
||||
/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 \
|
||||
&& apk update \
|
||||
&& apk add --no-cache npm curl jq\
|
||||
&& apk add --no-cache npm curl jq openssl\
|
||||
&& 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
|
||||
|
||||
docker rm -f myztplanet
|
||||
rm -f $(pwd)/data/zerotier
|
||||
rm -rf $(pwd)/data/zerotier
|
||||
|
||||
ZT_PORT=9994
|
||||
API_PORT=3443
|
||||
@ -218,7 +218,7 @@ function update() {
|
||||
-e API_PORT=${API_PORT} \
|
||||
-e FILE_SERVER_PORT=${FILE_PORT} \
|
||||
-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() {
|
||||
|
@ -9,26 +9,15 @@ function start() {
|
||||
cd /app/ztncui/src && npm start || exit 1
|
||||
}
|
||||
|
||||
function check_ztncui() {
|
||||
mkdir -p /app/ztncui
|
||||
if [ "$(ls -A /app/ztncui)" ]; then
|
||||
echo "${API_PORT}" >/app/config/ztncui.port
|
||||
echo "/app/ztncui is not empty, start directly"
|
||||
function check_file_server(){
|
||||
if [ ! -f "/app/config/file_server.port" ]; then
|
||||
echo "file_server.port is not exist, generate it"
|
||||
echo "${FILE_SERVER_PORT}" >/app/config/file_server.port
|
||||
echo "${FILE_SERVER_PORT}"
|
||||
else
|
||||
echo "/app/ztncui is empty, init data"
|
||||
cp -r /bak/ztncui/* /app/ztncui/
|
||||
|
||||
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!"
|
||||
echo "file_server.port is exist, read it"
|
||||
FILE_SERVER_PORT=$(cat /app/config/file_server.port)
|
||||
echo "${FILE_SERVER_PORT}"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -44,6 +33,7 @@ function check_zerotier() {
|
||||
|
||||
cd /var/lib/zerotier-one
|
||||
echo "start mkmoonworld"
|
||||
openssl rand -hex 16 > authtoken.secret
|
||||
|
||||
./zerotier-idtool initmoon identity.public >moon.json
|
||||
|
||||
@ -54,10 +44,8 @@ function check_zerotier() {
|
||||
echo "IP_ADDR6=$IP_ADDR6"
|
||||
|
||||
ZT_PORT=$(cat /app/config/zerotier-one.port)
|
||||
API_PORT=$(cat /app/config/ztncui.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_ADDR6" ]; then stableEndpoints="[\"$IP_ADDR4/${ZT_PORT}\"]"; fi
|
||||
@ -86,21 +74,31 @@ function check_zerotier() {
|
||||
fi
|
||||
}
|
||||
|
||||
function check_file_server(){
|
||||
if [ ! -f "/app/config/file_server.port" ]; then
|
||||
echo "file_server.port is not exist, generate it"
|
||||
echo "${FILE_SERVER_PORT}" >/app/config/file_server.port
|
||||
echo "${FILE_SERVER_PORT}"
|
||||
function check_ztncui() {
|
||||
mkdir -p /app/ztncui
|
||||
if [ "$(ls -A /app/ztncui)" ]; then
|
||||
echo "${API_PORT}" >/app/config/ztncui.port
|
||||
echo "/app/ztncui is not empty, start directly"
|
||||
else
|
||||
echo "file_server.port is exist, read it"
|
||||
FILE_SERVER_PORT=$(cat /app/config/file_server.port)
|
||||
echo "${FILE_SERVER_PORT}"
|
||||
echo "/app/ztncui is empty, init data"
|
||||
cp -r /bak/ztncui/* /app/ztncui/
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
check_file_server
|
||||
check_ztncui
|
||||
check_zerotier
|
||||
check_ztncui
|
||||
|
||||
start
|
Loading…
Reference in New Issue
Block a user