mirror of
https://github.com/Websoft9/websoft9.git
synced 2025-02-03 01:28:39 +08:00
fix proxy migration
This commit is contained in:
parent
2d9362a916
commit
2f7e4bf546
@ -9,8 +9,9 @@ LABEL version="2.11.3-rc1"
|
|||||||
|
|
||||||
COPY README.md /data/nginx/README.md
|
COPY README.md /data/nginx/README.md
|
||||||
RUN mkdir /data/nginx/custom
|
RUN mkdir /data/nginx/custom
|
||||||
|
RUN mkdir -p /etc/websoft9
|
||||||
COPY ./config/http.conf /data/nginx/custom/http.conf
|
COPY ./config/http.conf /data/nginx/custom/http.conf
|
||||||
COPY ./config/initproxy.conf /data/nginx/default_host/initproxy.conf
|
COPY ./config/initproxy.conf /etc/websoft9/initproxy.conf
|
||||||
COPY ./init_nginx.sh /app/init_nginx.sh
|
COPY ./init_nginx.sh /app/init_nginx.sh
|
||||||
RUN chmod +x /app/init_nginx.sh
|
RUN chmod +x /app/init_nginx.sh
|
||||||
|
|
||||||
|
@ -1,31 +1,33 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# 设置密码目录
|
# Define variables
|
||||||
credential_path="/data/credential"
|
credential_path="/data/credential"
|
||||||
|
|
||||||
# 检查是否已经存在密码文件
|
# Migrating initproxy.conf file
|
||||||
|
|
||||||
|
cp -f /etc/websoft9/initproxy.conf /data/nginx/default_host/initproxy.conf
|
||||||
|
[ -f /etc/websoft9/initproxy.conf ] && rm -f /data/nginx/proxy_host/initproxy.conf
|
||||||
|
|
||||||
|
|
||||||
|
# If credential file then create it and init credential for NPM
|
||||||
|
# Reload NPM docker image Environments
|
||||||
|
|
||||||
if [ ! -f "$credential_path" ]; then
|
if [ ! -f "$credential_path" ]; then
|
||||||
# 设置用户名和生成随机密码
|
# Set init credential
|
||||||
INITIAL_ADMIN_EMAIL="admin@mydomain.com"
|
INITIAL_ADMIN_EMAIL="admin@mydomain.com"
|
||||||
INITIAL_ADMIN_PASSWORD=$(openssl rand -base64 16 | tr -d '/+' | cut -c1-16)
|
INITIAL_ADMIN_PASSWORD=$(openssl rand -base64 16 | tr -d '/+' | cut -c1-16)
|
||||||
|
|
||||||
# 设置环境变量
|
# Write credential to file
|
||||||
export INITIAL_ADMIN_EMAIL
|
|
||||||
export INITIAL_ADMIN_PASSWORD
|
|
||||||
|
|
||||||
# 写入密码文件
|
|
||||||
mkdir -p "$(dirname "$credential_path")"
|
mkdir -p "$(dirname "$credential_path")"
|
||||||
credential_json="{\"username\":\"$INITIAL_ADMIN_EMAIL\",\"password\":\"$INITIAL_ADMIN_PASSWORD\"}"
|
echo "{\"username\":\"$INITIAL_ADMIN_EMAIL\",\"password\":\"$INITIAL_ADMIN_PASSWORD\"}" > "$credential_path"
|
||||||
echo "$credential_json" > "$credential_path"
|
|
||||||
else
|
|
||||||
# 从密码文件中读取用户名和密码
|
|
||||||
INITIAL_ADMIN_EMAIL=$(jq -r '.username' "$credential_path")
|
|
||||||
INITIAL_ADMIN_PASSWORD=$(jq -r '.password' "$credential_path")
|
|
||||||
|
|
||||||
# 设置环境变量
|
else
|
||||||
export INITIAL_ADMIN_EMAIL
|
read -r INITIAL_ADMIN_EMAIL INITIAL_ADMIN_PASSWORD < <(jq -r '.username + " " + .password' "$credential_path")
|
||||||
export INITIAL_ADMIN_PASSWORD
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 启动 Nginx
|
# Reload NPM docker image Environments
|
||||||
|
export INITIAL_ADMIN_EMAIL
|
||||||
|
export INITIAL_ADMIN_PASSWORD
|
||||||
|
|
||||||
|
# Start NPM
|
||||||
exec /init
|
exec /init
|
||||||
|
Loading…
Reference in New Issue
Block a user