-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d9362a
commit 2f7e4bf
Showing
2 changed files
with
22 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,33 @@ | ||
#!/bin/bash | ||
|
||
# 设置密码目录 | ||
# Define variables | ||
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 | ||
# 设置用户名和生成随机密码 | ||
# Set init credential | ||
INITIAL_ADMIN_EMAIL="admin@mydomain.com" | ||
INITIAL_ADMIN_PASSWORD=$(openssl rand -base64 16 | tr -d '/+' | cut -c1-16) | ||
|
||
# 设置环境变量 | ||
export INITIAL_ADMIN_EMAIL | ||
export INITIAL_ADMIN_PASSWORD | ||
|
||
# 写入密码文件 | ||
# Write credential to file | ||
mkdir -p "$(dirname "$credential_path")" | ||
credential_json="{\"username\":\"$INITIAL_ADMIN_EMAIL\",\"password\":\"$INITIAL_ADMIN_PASSWORD\"}" | ||
echo "$credential_json" > "$credential_path" | ||
else | ||
# 从密码文件中读取用户名和密码 | ||
INITIAL_ADMIN_EMAIL=$(jq -r '.username' "$credential_path") | ||
INITIAL_ADMIN_PASSWORD=$(jq -r '.password' "$credential_path") | ||
echo "{\"username\":\"$INITIAL_ADMIN_EMAIL\",\"password\":\"$INITIAL_ADMIN_PASSWORD\"}" > "$credential_path" | ||
|
||
# 设置环境变量 | ||
export INITIAL_ADMIN_EMAIL | ||
export INITIAL_ADMIN_PASSWORD | ||
else | ||
read -r INITIAL_ADMIN_EMAIL INITIAL_ADMIN_PASSWORD < <(jq -r '.username + " " + .password' "$credential_path") | ||
fi | ||
|
||
# 启动 Nginx | ||
# Reload NPM docker image Environments | ||
export INITIAL_ADMIN_EMAIL | ||
export INITIAL_ADMIN_PASSWORD | ||
|
||
# Start NPM | ||
exec /init |