hxger commited on
Commit
99d45b3
·
verified ·
1 Parent(s): 07057be

Upload 3 files

Browse files
Files changed (3) hide show
  1. Dockerfile +4 -2
  2. gt.sh +13 -0
  3. sync_data.sh +38 -1
Dockerfile CHANGED
@@ -14,13 +14,15 @@ WORKDIR $HOME/app
14
  ENV VIRTUAL_ENV=$HOME/venv
15
  RUN python3 -m venv $VIRTUAL_ENV
16
  ENV PATH="$VIRTUAL_ENV/bin:$PATH"
17
- RUN pip install --no-cache-dir requests webdavclient3
18
 
19
  COPY --chown=user . $HOME/app
20
  COPY --chown=user sync_data.sh $HOME/app/
 
21
 
22
  RUN chmod +x $HOME/app/wdp && \
23
- chmod +x $HOME/app/sync_data.sh
 
24
 
25
  RUN chown -R user:user /home/user
26
  USER user
 
14
  ENV VIRTUAL_ENV=$HOME/venv
15
  RUN python3 -m venv $VIRTUAL_ENV
16
  ENV PATH="$VIRTUAL_ENV/bin:$PATH"
17
+ RUN pip install --no-cache-dir requests webdavclient3 gradio-tunneling
18
 
19
  COPY --chown=user . $HOME/app
20
  COPY --chown=user sync_data.sh $HOME/app/
21
+ COPY --chown=user gt.sh $HOME/app/
22
 
23
  RUN chmod +x $HOME/app/wdp && \
24
+ chmod +x $HOME/app/sync_data.sh && \
25
+ chmod +x $HOME/app/gt.sh
26
 
27
  RUN chown -R user:user /home/user
28
  USER user
gt.sh ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # 终止所有 gradio-tun 进程
4
+ pkill -9 -f "gradio-tun"
5
+
6
+ # 终止所有 frpc 客户端进程
7
+ pkill -9 -f "frpc_linux_amd64"
8
+
9
+ sleep 2
10
+
11
+ # 启动新隧道
12
+ gradio-tun 5246 --sd hfqiuyelu 2>&1 &
13
+ # 固定的隧道地址 https://16ee201e7b64166dc2.gradio.live
sync_data.sh CHANGED
@@ -66,6 +66,40 @@ with requests.get(f'$FULL_WEBDAV_URL/{latest_backup}', auth=('$WEBDAV_USERNAME',
66
  echo "Downloading latest backup from WebDAV..."
67
  restore_backup
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  # 等待30秒后启动程序
70
  sleep 30
71
 
@@ -126,4 +160,7 @@ else:
126
  }
127
 
128
  # 启动同步进程
129
- sync_data &
 
 
 
 
66
  echo "Downloading latest backup from WebDAV..."
67
  restore_backup
68
 
69
+ # 首次运行gradio-tunneling隧道
70
+ echo "初始化启动gradio-tunneling隧道..."
71
+ $HOME/app/gt.sh
72
+
73
+ # 定时运行gt.sh脚本的函数
74
+ run_gt_script() {
75
+ while true; do
76
+ # 获取当前时间
77
+ current_hour=$(date +%H)
78
+ current_minute=$(date +%M)
79
+
80
+ # 计算距离下一次执行的时间(假设每天凌晨3点执行)
81
+ target_hour=3
82
+ target_minute=0
83
+
84
+ if [[ $current_hour -gt $target_hour || ($current_hour -eq $target_hour && $current_minute -ge $target_minute) ]]; then
85
+ # 已经过了今天的执行时间,等待到明天
86
+ seconds_to_wait=$(( (24 - current_hour + target_hour) * 3600 - current_minute * 60 + target_minute * 60 ))
87
+ else
88
+ # 今天的执行时间还没到
89
+ seconds_to_wait=$(( (target_hour - current_hour) * 3600 + (target_minute - current_minute) * 60 ))
90
+ fi
91
+
92
+ echo "下次执行gt.sh将在$(date -d "+$seconds_to_wait seconds" '+%Y-%m-%d %H:%M:%S')进行"
93
+
94
+ # 等待到执行时间
95
+ sleep $seconds_to_wait
96
+
97
+ # 执行gt.sh脚本
98
+ echo "执行定时任务: $(date)"
99
+ $HOME/app/gt.sh
100
+ done
101
+ }
102
+
103
  # 等待30秒后启动程序
104
  sleep 30
105
 
 
160
  }
161
 
162
  # 启动同步进程
163
+ sync_data &
164
+
165
+ # 启动gt.sh定时执行进程
166
+ run_gt_script &