feat: Add rclone
Browse files- Dockerfile +4 -0
- docker-entrypoint.sh +33 -2
Dockerfile
CHANGED
@@ -64,6 +64,7 @@ RUN set -x && \
|
|
64 |
procps \
|
65 |
netcat \
|
66 |
sshpass \
|
|
|
67 |
unzip \
|
68 |
libatomic1 && \
|
69 |
apt-get clean && \
|
@@ -121,6 +122,9 @@ RUN useradd -m -u 1000 user
|
|
121 |
# Switch to the "user" user
|
122 |
USER user
|
123 |
|
|
|
|
|
|
|
124 |
HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
|
125 |
CMD curl -sf --noproxy '*' http://127.0.0.1:5400/api/health || exit 1
|
126 |
|
|
|
64 |
procps \
|
65 |
netcat \
|
66 |
sshpass \
|
67 |
+
rclone \
|
68 |
unzip \
|
69 |
libatomic1 && \
|
70 |
apt-get clean && \
|
|
|
122 |
# Switch to the "user" user
|
123 |
USER user
|
124 |
|
125 |
+
# 创建rclone配置文件
|
126 |
+
RUN rclone config -h
|
127 |
+
|
128 |
HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
|
129 |
CMD curl -sf --noproxy '*' http://127.0.0.1:5400/api/health || exit 1
|
130 |
|
docker-entrypoint.sh
CHANGED
@@ -4,6 +4,10 @@ dir_shell=/ql/shell
|
|
4 |
. $dir_shell/share.sh
|
5 |
. $dir_shell/env.sh
|
6 |
|
|
|
|
|
|
|
|
|
7 |
echo -e "======================1. 检测配置文件========================\n"
|
8 |
import_config "$@"
|
9 |
make_dir /etc/nginx/conf.d
|
@@ -44,9 +48,36 @@ echo -e "############################################################\n"
|
|
44 |
|
45 |
|
46 |
echo -e "##########写入登陆信息############"
|
47 |
-
#echo -e "{ \"username\": \"$ADMIN_USERNAME\", \"password\": \"$ADMIN_PASSWORD\" }"
|
48 |
echo "{ \"username\": \"$ADMIN_USERNAME\", \"password\": \"$ADMIN_PASSWORD\" }" > /ql/data/config/auth.json
|
49 |
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
exec "$@"
|
|
|
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
|
|
|
48 |
|
49 |
|
50 |
echo -e "##########写入登陆信息############"
|
|
|
51 |
echo "{ \"username\": \"$ADMIN_USERNAME\", \"password\": \"$ADMIN_PASSWORD\" }" > /ql/data/config/auth.json
|
52 |
|
53 |
+
echo -e "##########同步备份############"
|
54 |
+
# 指定远程文件夹路径,格式为 remote:path
|
55 |
+
REMOTE_FOLDER="cf-s3:/qinglong"
|
56 |
+
|
57 |
+
# 使用 rclone ls 命令列出文件夹内容,将输出和错误分别捕获
|
58 |
+
OUTPUT=$(rclone ls "$REMOTE_FOLDER" 2>&1)
|
59 |
+
|
60 |
+
# 获取 rclone 命令的退出状态码
|
61 |
+
EXIT_CODE=$?
|
62 |
+
|
63 |
+
# 判断退出状态码
|
64 |
+
if [ $EXIT_CODE -eq 0 ]; then
|
65 |
+
# rclone 命令成功执行,检查文件夹是否为空
|
66 |
+
if [ -z "$OUTPUT" ]; then
|
67 |
+
#为空不处理
|
68 |
+
#rclone sync --interactive /ql $REMOTE_FOLDER
|
69 |
+
echo "初次安装"
|
70 |
+
else
|
71 |
+
#echo "文件夹不为空"
|
72 |
+
mkdir /ql/.tmp/data
|
73 |
+
rclone sync $REMOTE_FOLDER /ql/.tmp/data && real_time=true ql reload data
|
74 |
+
fi
|
75 |
+
elif [[ "$OUTPUT" == *"directory not found"* ]]; then
|
76 |
+
echo "错误:文件夹不存在"
|
77 |
+
else
|
78 |
+
echo "错误:$OUTPUT"
|
79 |
+
fi
|
80 |
+
|
81 |
+
tail -f /dev/null
|
82 |
|
83 |
exec "$@"
|