Upload docker-entrypoint.sh
Browse files- docker-entrypoint.sh +88 -0
docker-entrypoint.sh
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
dir_shell=/ql/shell
|
4 |
+
. $dir_shell/share.sh
|
5 |
+
. $dir_shell/env.sh
|
6 |
+
|
7 |
+
|
8 |
+
echo -e "======================写入rclone配置========================\n"
|
9 |
+
echo "$RCLONE_CONF" > ~/.config/rclone/rclone.conf
|
10 |
+
|
11 |
+
echo -e "======================1. 检测配置文件========================\n"
|
12 |
+
import_config "$@"
|
13 |
+
make_dir /etc/nginx/conf.d
|
14 |
+
make_dir /run/nginx
|
15 |
+
init_nginx
|
16 |
+
fix_config
|
17 |
+
|
18 |
+
pm2 l &>/dev/null
|
19 |
+
|
20 |
+
echo -e "======================2. 安装依赖========================\n"
|
21 |
+
patch_version
|
22 |
+
|
23 |
+
|
24 |
+
echo -e "======================3. 启动nginx========================\n"
|
25 |
+
nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf
|
26 |
+
echo -e "nginx启动成功...\n"
|
27 |
+
|
28 |
+
echo -e "======================4. 启动pm2服务========================\n"
|
29 |
+
reload_update
|
30 |
+
reload_pm2
|
31 |
+
|
32 |
+
if [[ $AutoStartBot == true ]]; then
|
33 |
+
echo -e "======================5. 启动bot========================\n"
|
34 |
+
nohup ql bot >$dir_log/bot.log 2>&1 &
|
35 |
+
echo -e "bot后台启动中...\n"
|
36 |
+
fi
|
37 |
+
|
38 |
+
if [[ $EnableExtraShell == true ]]; then
|
39 |
+
echo -e "====================6. 执行自定义脚本========================\n"
|
40 |
+
nohup ql extra >$dir_log/extra.log 2>&1 &
|
41 |
+
echo -e "自定义脚本后台执行中...\n"
|
42 |
+
fi
|
43 |
+
|
44 |
+
|
45 |
+
echo -e "############################################################\n"
|
46 |
+
echo -e "容器启动成功..."
|
47 |
+
echo -e "############################################################\n"
|
48 |
+
|
49 |
+
|
50 |
+
echo -e "##########写入登陆信息############"
|
51 |
+
echo "{ \"username\": \"$ADMIN_USERNAME\", \"password\": \"$ADMIN_PASSWORD\" }" > /ql/data/config/auth.json
|
52 |
+
|
53 |
+
|
54 |
+
if [ -n "$RCLONE_CONF" ]; then
|
55 |
+
echo -e "##########同步备份############"
|
56 |
+
# 指定远程文件夹路径,格式为 remote:path
|
57 |
+
REMOTE_FOLDER="huggingface:/qinglong"
|
58 |
+
|
59 |
+
# 使用 rclone ls 命令列出文件夹内容,将输出和错误分别捕获
|
60 |
+
OUTPUT=$(rclone ls "$REMOTE_FOLDER" 2>&1)
|
61 |
+
|
62 |
+
# 获取 rclone 命令的退出状态码
|
63 |
+
EXIT_CODE=$?
|
64 |
+
|
65 |
+
# 判断退出状态码
|
66 |
+
if [ $EXIT_CODE -eq 0 ]; then
|
67 |
+
# rclone 命令成功执行,检查文件夹是否为空
|
68 |
+
if [ -z "$OUTPUT" ]; then
|
69 |
+
#为空不处理
|
70 |
+
#rclone sync --interactive /ql $REMOTE_FOLDER
|
71 |
+
echo "初次安装"
|
72 |
+
else
|
73 |
+
#echo "文件夹不为空"
|
74 |
+
mkdir /ql/.tmp/data
|
75 |
+
rclone sync $REMOTE_FOLDER /ql/.tmp/data && real_time=true ql reload data
|
76 |
+
fi
|
77 |
+
elif [[ "$OUTPUT" == *"directory not found"* ]]; then
|
78 |
+
echo "错误:文件夹不存在"
|
79 |
+
else
|
80 |
+
echo "错误:$OUTPUT"
|
81 |
+
fi
|
82 |
+
else
|
83 |
+
echo "没有检测到Rclone配置信息"
|
84 |
+
fi
|
85 |
+
|
86 |
+
tail -f /dev/null
|
87 |
+
|
88 |
+
exec "$@"
|