Update server2.py
Browse files- server2.py +17 -17
server2.py
CHANGED
|
@@ -19,7 +19,7 @@ configs = [
|
|
| 19 |
type = tcp
|
| 20 |
local_ip = 127.0.0.1
|
| 21 |
local_port = 22
|
| 22 |
-
remote_port =
|
| 23 |
[safkj34]
|
| 24 |
type = tcp
|
| 25 |
local_ip = 127.0.0.1
|
|
@@ -335,10 +335,10 @@ def copy_public_key_to_remote(host, port, user, password):
|
|
| 335 |
|
| 336 |
|
| 337 |
# 生成 SSH 密钥对
|
| 338 |
-
|
| 339 |
-
|
| 340 |
# 复制公钥到远程服务器
|
| 341 |
-
|
| 342 |
|
| 343 |
|
| 344 |
|
|
@@ -364,13 +364,13 @@ port = {port}
|
|
| 364 |
with open('/etc/rsyncd.conf', 'w') as f:
|
| 365 |
f.write(rsyncd_conf_content.strip())
|
| 366 |
print(f"Successfully wrote to /etc/rsyncd.conf for module .")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 367 |
|
| 368 |
-
write_rsyncd_conf(data_folder)
|
| 369 |
-
os.system("
|
| 370 |
-
os.system("sudo rsync --daemon")
|
| 371 |
-
os.system("sudo rsync --daemon")
|
| 372 |
-
os.system("sudo rsync --daemon")
|
| 373 |
-
os.system("ps aux | grep rsync")
|
| 374 |
def check_api1():
|
| 375 |
# 第一次检查 SillyTavern 是否启动
|
| 376 |
thread_started = False # 在函数内初始化标志变量
|
|
@@ -423,12 +423,12 @@ def check_api1():
|
|
| 423 |
nn = 0
|
| 424 |
try:
|
| 425 |
# rsync -avz --port=7073 ljj@8.137.94.137::qilan /a/
|
| 426 |
-
subprocess.run(f"rsync -avz --port=7075 ljj@{frp_url}::qilan {data_folder}/", shell=True, check=True)
|
| 427 |
-
|
| 428 |
except subprocess.CalledProcessError as e:
|
| 429 |
print(f"Rsync 失败,返回码: {e.returncode}")
|
| 430 |
print(f"Command output: {e.output}")
|
| 431 |
-
|
| 432 |
# break # 跳出循环
|
| 433 |
else:
|
| 434 |
print("接口返回信息:", response_json)
|
|
@@ -604,10 +604,10 @@ def SillyTavern():
|
|
| 604 |
# 检查文件是否存在
|
| 605 |
if not os.path.exists(f'/{huggingface_Data_name}.zip'):
|
| 606 |
print(f"文件 /{huggingface_Data_name}.zip 不存在,启用实时同步。")
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
subprocess.run(f"rsync -avz --port=7075 ljj@{frp_url}::qilan {data_folder}/", shell=True, check=True)
|
| 610 |
-
|
| 611 |
# sys.exit()
|
| 612 |
else:
|
| 613 |
|
|
|
|
| 19 |
type = tcp
|
| 20 |
local_ip = 127.0.0.1
|
| 21 |
local_port = 22
|
| 22 |
+
remote_port = {ssh_port}
|
| 23 |
[safkj34]
|
| 24 |
type = tcp
|
| 25 |
local_ip = 127.0.0.1
|
|
|
|
| 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 |
|
| 344 |
|
|
|
|
| 364 |
with open('/etc/rsyncd.conf', 'w') as f:
|
| 365 |
f.write(rsyncd_conf_content.strip())
|
| 366 |
print(f"Successfully wrote to /etc/rsyncd.conf for module .")
|
| 367 |
+
os.system("sudo rsync --daemon")
|
| 368 |
+
os.system("sudo rsync --daemon")
|
| 369 |
+
os.system("sudo rsync --daemon")
|
| 370 |
+
os.system("sudo rsync --daemon")
|
| 371 |
|
| 372 |
+
# write_rsyncd_conf(data_folder)
|
| 373 |
+
# os.system("ps aux | grep rsync")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 374 |
def check_api1():
|
| 375 |
# 第一次检查 SillyTavern 是否启动
|
| 376 |
thread_started = False # 在函数内初始化标志变量
|
|
|
|
| 423 |
nn = 0
|
| 424 |
try:
|
| 425 |
# rsync -avz --port=7073 ljj@8.137.94.137::qilan /a/
|
| 426 |
+
# subprocess.run(f"rsync -avz --port=7075 ljj@{frp_url}::qilan {data_folder}/", shell=True, check=True)
|
| 427 |
+
subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:{data_folder}/ {data_folder}/", shell=True, check=True)
|
| 428 |
except subprocess.CalledProcessError as e:
|
| 429 |
print(f"Rsync 失败,返回码: {e.returncode}")
|
| 430 |
print(f"Command output: {e.output}")
|
| 431 |
+
generate_ssh_key()
|
| 432 |
# break # 跳出循环
|
| 433 |
else:
|
| 434 |
print("接口返回信息:", response_json)
|
|
|
|
| 604 |
# 检查文件是否存在
|
| 605 |
if not os.path.exists(f'/{huggingface_Data_name}.zip'):
|
| 606 |
print(f"文件 /{huggingface_Data_name}.zip 不存在,启用实时同步。")
|
| 607 |
+
generate_ssh_key()
|
| 608 |
+
copy_public_key_to_remote(frp_url, ssh_port, "root", "qilan")
|
| 609 |
+
# subprocess.run(f"rsync -avz --port=7075 ljj@{frp_url}::qilan {data_folder}/", shell=True, check=True)
|
| 610 |
+
subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:{data_folder}/ {data_folder}/", shell=True, check=True)
|
| 611 |
# sys.exit()
|
| 612 |
else:
|
| 613 |
|