Update server.py
Browse files
server.py
CHANGED
|
@@ -19,7 +19,7 @@ configs = [
|
|
| 19 |
[safab2f]
|
| 20 |
type = tcp
|
| 21 |
local_ip = 127.0.0.1
|
| 22 |
-
local_port =
|
| 23 |
remote_port = {ssh_port}
|
| 24 |
|
| 25 |
[saffg]
|
|
@@ -335,10 +335,10 @@ def copy_public_key_to_remote(host, port, user, password):
|
|
| 335 |
|
| 336 |
|
| 337 |
# 生成 SSH 密钥对
|
| 338 |
-
|
| 339 |
-
|
| 340 |
# # 复制公钥到远程服务器
|
| 341 |
-
|
| 342 |
|
| 343 |
def write_rsyncd_conf(path, port=7071):
|
| 344 |
rsyncd_conf_content = f"""
|
|
@@ -417,12 +417,12 @@ def check_api1():
|
|
| 417 |
print("检测到 token")
|
| 418 |
nn = 0
|
| 419 |
try:
|
| 420 |
-
subprocess.run(f"rsync -avz --port=7071 ljj@{frp_url}::qilan {data_folder}/", shell=True, check=True)
|
| 421 |
-
|
| 422 |
except subprocess.CalledProcessError as e:
|
| 423 |
print(f"Rsync 失败,返回码: {e.returncode}")
|
| 424 |
print(f"Command output: {e.output}")
|
| 425 |
-
|
| 426 |
# subprocess.run(f"bash /sync.sh -p {ssh_port} -s {frp_url}", shell=True, check=True)
|
| 427 |
# break # 跳出循环
|
| 428 |
else:
|
|
@@ -603,10 +603,10 @@ def SillyTavern():
|
|
| 603 |
# 检查文件是否存在
|
| 604 |
if not os.path.exists(f'/{huggingface_Data_name}.zip'):
|
| 605 |
print(f"文件 /{huggingface_Data_name}.zip 不存在,启用实时同步。")
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
subprocess.run(f"rsync -avz --port=7075 ljj@{frp_url}::qilan {data_folder}/", shell=True, check=True)
|
| 610 |
# sys.exit()
|
| 611 |
else:
|
| 612 |
|
|
|
|
| 19 |
[safab2f]
|
| 20 |
type = tcp
|
| 21 |
local_ip = 127.0.0.1
|
| 22 |
+
local_port = 22
|
| 23 |
remote_port = {ssh_port}
|
| 24 |
|
| 25 |
[saffg]
|
|
|
|
| 335 |
|
| 336 |
|
| 337 |
# 生成 SSH 密钥对
|
| 338 |
+
generate_ssh_key()
|
| 339 |
+
os.system('chmod 600 ~/.ssh/id_rsa')
|
| 340 |
# # 复制公钥到远程服务器
|
| 341 |
+
copy_public_key_to_remote(frp_url, ssh_port, "root", "qilan")
|
| 342 |
|
| 343 |
def write_rsyncd_conf(path, port=7071):
|
| 344 |
rsyncd_conf_content = f"""
|
|
|
|
| 417 |
print("检测到 token")
|
| 418 |
nn = 0
|
| 419 |
try:
|
| 420 |
+
# subprocess.run(f"rsync -avz --port=7071 ljj@{frp_url}::qilan {data_folder}/", shell=True, check=True)
|
| 421 |
+
subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:{data_folder}/ {data_folder}/", shell=True, check=True)
|
| 422 |
except subprocess.CalledProcessError as e:
|
| 423 |
print(f"Rsync 失败,返回码: {e.returncode}")
|
| 424 |
print(f"Command output: {e.output}")
|
| 425 |
+
generate_ssh_key()
|
| 426 |
# subprocess.run(f"bash /sync.sh -p {ssh_port} -s {frp_url}", shell=True, check=True)
|
| 427 |
# break # 跳出循环
|
| 428 |
else:
|
|
|
|
| 603 |
# 检查文件是否存在
|
| 604 |
if not os.path.exists(f'/{huggingface_Data_name}.zip'):
|
| 605 |
print(f"文件 /{huggingface_Data_name}.zip 不存在,启用实时同步。")
|
| 606 |
+
generate_ssh_key()
|
| 607 |
+
copy_public_key_to_remote(frp_url, ssh_port, "root", "qilan")
|
| 608 |
+
subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:{data_folder}/ {data_folder}/", shell=True, check=True)
|
| 609 |
+
# subprocess.run(f"rsync -avz --port=7075 ljj@{frp_url}::qilan {data_folder}/", shell=True, check=True)
|
| 610 |
# sys.exit()
|
| 611 |
else:
|
| 612 |
|