Qilan2 commited on
Commit
9eda7d1
·
verified ·
1 Parent(s): 5bf6224

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +9 -14
server.py CHANGED
@@ -174,22 +174,17 @@ def sync():
174
  generate_ssh_key()
175
  # 复制公钥到远程服务器
176
  copy_public_key_to_remote(frp_url, ssh_port, "root", "qilan")
177
- commands = [
178
- "rm -rf /rsync.py /sync.sh",
179
- # "wget -O /rsync.py https://huggingface.co/datasets/Qilan2/st-server/resolve/main/rsync.py",
180
- # "wget -O /sync.sh https://huggingface.co/datasets/Qilan2/st-server/resolve/main/sync.sh",
181
- "chmod +x /sync.sh",
182
- "chmod +x /rsync.py"
183
- ]
184
  # 写入到 /sync.sh 文件中
185
- with open('/sync.sh', 'w') as file:
186
- file.write(script_content)
 
 
 
 
 
187
 
188
- for command in commands:
189
- print(f"Running: {command}")
190
- if os.system(command) != 0:
191
- print("Command failed.")
192
- return # 如果有命令失败,则退出函数
193
 
194
  # 启动 sync.sh 脚本,并传递参数
195
  subprocess.run('sh /sync.sh', shell=True, check=True)
 
174
  generate_ssh_key()
175
  # 复制公钥到远程服务器
176
  copy_public_key_to_remote(frp_url, ssh_port, "root", "qilan")
 
 
 
 
 
 
 
177
  # 写入到 /sync.sh 文件中
178
+ try:
179
+ with open('/sync.sh', 'w') as file:
180
+ file.write(script_content)
181
+ print("Successfully wrote to /sync.sh")
182
+
183
+ # 修改权限,使脚本可执行
184
+ os.chmod('/sync.sh', 0o755) # 设置为可执行权限
185
 
186
+ except Exception as e:
187
+ print(f"An error occurred while writing to /sync.sh: {e}")
 
 
 
188
 
189
  # 启动 sync.sh 脚本,并传递参数
190
  subprocess.run('sh /sync.sh', shell=True, check=True)