Create entrypoint.sh
Browse files- entrypoint.sh +28 -0
entrypoint.sh
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# entrypoint.sh
|
| 3 |
+
# 验证配置文件是否存在
|
| 4 |
+
if [ ! -f /app/config.toml ]; then
|
| 5 |
+
echo "错误:未找到/app/config.toml配置文件"
|
| 6 |
+
exit 1
|
| 7 |
+
fi
|
| 8 |
+
# 使用环境变量动态更新config.toml
|
| 9 |
+
sed -i "s/hostname = \".*\"/hostname = \"$HOSTNAME\"/" /app/config.toml
|
| 10 |
+
sed -i "s/ipv4 = \".*\"/ipv4 = \"$IPV4_ADDRESS\"/" /app/config.toml
|
| 11 |
+
sed -i "s|listeners = .*|listeners = [\"$LISTENERS\"]|" /app/config.toml
|
| 12 |
+
sed -i "s/rpc_portal = \".*\"/rpc_portal = \"$RPC_PORTAL\"/" /app/config.toml
|
| 13 |
+
sed -i "s/network_name = \".*\"/network_name = \"$NETWORK_NAME\"/" /app/config.toml
|
| 14 |
+
sed -i "s/network_secret = \".*\"/network_secret = \"$NETWORK_SECRET\"/" /app/config.toml
|
| 15 |
+
sed -i "s/no_tun = .*/no_tun = $NO_TUN/" /app/config.toml
|
| 16 |
+
# 验证supervisord配置文件
|
| 17 |
+
if [ ! -f /app/supervisor/supervisord.conf ]; then
|
| 18 |
+
echo "错误:未找到/app/supervisor/supervisord.conf配置文件"
|
| 19 |
+
exit 1
|
| 20 |
+
fi
|
| 21 |
+
# 验证ttyd端口
|
| 22 |
+
if [ -z "$TTYD_PORT" ]; then
|
| 23 |
+
echo "警告:TTYD_PORT未设置,默认使用7860"
|
| 24 |
+
TTYD_PORT=7860
|
| 25 |
+
fi
|
| 26 |
+
sed -i "s/-p [0-9]\+ /-p $TTYD_PORT /" /app/supervisor/supervisord.conf
|
| 27 |
+
# 启动supervisord
|
| 28 |
+
exec "$@"
|