Qilan2 commited on
Commit
ae7f3b7
·
verified ·
1 Parent(s): 6e8e1cf

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +2 -28
server.py CHANGED
@@ -23,21 +23,7 @@ local_ip = 127.0.0.1
23
  local_port = 873
24
  remote_port = 7075
25
  """
26
- script_content = f"""#!/bin/bash
27
- # 定义源和目标路径
28
- SOURCE="/sillytavern/"
29
- DESTINATION="root@{frp_url}:/sillytavern/"
30
- PORT={ssh_port}
31
- # 使用 inotifywait 监控源目录的变化
32
- while true; do
33
- # 等待文件创建、修改或删除事件,并执行 rsync 同步命令。
34
- inotifywait -r -e modify,create,delete "$SOURCE"
35
- echo "Change detected at $(date). Syncing..."
36
- # 执行 rsync 同步命令,使用 sshpass 自动输入密码(如果需要)
37
- rsync -avzP --delete -e "ssh -p $PORT -o StrictHostKeyChecking=no" "$SOURCE" "$DESTINATION"
38
- echo "Sync completed at $(date)."
39
- done
40
- """
41
  kaggle_metadata = {
42
  "title": "Your Dataset Title",
43
  "id": "xovale7506/sillytavern-data",
@@ -174,21 +160,9 @@ def sync():
174
  generate_ssh_key()
175
  # 复制公钥到远程服务器
176
  copy_public_key_to_remote(frp_url, ssh_port, "root", "qilan")
177
- # 写入到 /sync.sh 文件中
178
- print(script_content)
179
- try:
180
- with open('/sync.sh', 'w') as file:
181
- file.write(script_content)
182
- print("Successfully wrote to /sync.sh")
183
-
184
- # 修改权限,使脚本可执行
185
- os.chmod('/sync.sh', 0o755) # 设置为可执行权限
186
-
187
- except Exception as e:
188
- print(f"An error occurred while writing to /sync.sh: {e}")
189
 
190
  # 启动 sync.sh 脚本,并传递参数
191
- subprocess.run('sh /sync.sh', shell=True, check=True)
192
 
193
 
194
 
 
23
  local_port = 873
24
  remote_port = 7075
25
  """
26
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  kaggle_metadata = {
28
  "title": "Your Dataset Title",
29
  "id": "xovale7506/sillytavern-data",
 
160
  generate_ssh_key()
161
  # 复制公钥到远程服务器
162
  copy_public_key_to_remote(frp_url, ssh_port, "root", "qilan")
 
 
 
 
 
 
 
 
 
 
 
 
163
 
164
  # 启动 sync.sh 脚本,并传递参数
165
+ subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:/sillytavern/ /sillytavern/", shell=True, check=True)
166
 
167
 
168