Update ff_sap.py
Browse files
ff_sap.py
CHANGED
|
@@ -48,11 +48,11 @@ else: # 如果 DATA_JSON 为空,就从单独的环境变量里取
|
|
| 48 |
|
| 49 |
|
| 50 |
def cf():
|
| 51 |
-
os.system("rm -r /
|
| 52 |
-
os.system("wget -O '/
|
| 53 |
-
os.system("chmod +x /
|
| 54 |
# https://ff1.vv9.dpdns.org
|
| 55 |
-
os.system('nohup /
|
| 56 |
|
| 57 |
UUID = os.environ.get('UUID', 'a488076d-0ced-4a83-91c4-c498fce00cff') # UUID,如使用v1,在不同的平台部署需要修改,否则会覆盖
|
| 58 |
N_SERVER = os.environ.get('NEZHA_SERVER', '')# N面板域名或ip,
|
|
@@ -171,15 +171,15 @@ def create_space(type,key = "", value = "",name = ""):
|
|
| 171 |
response = requests.post(url, headers=headers, json=payload)
|
| 172 |
return response.text
|
| 173 |
if type == 4:
|
| 174 |
-
file_path = f"/
|
| 175 |
os.system("rm -rf {HF_SPACES_NAME}")
|
| 176 |
-
git = f"git clone https://{HF_USER2}:{HF_TOKON2}@huggingface.co/spaces/{HF_USER2}/{name} /
|
| 177 |
-
url = "https://huggingface.co
|
| 178 |
print(git)
|
| 179 |
os.system(git)
|
| 180 |
os.system(f'git config --global user.email "{HF_EMAIL2}"')
|
| 181 |
os.system(f'git config --global user.name "{HF_USER2}"')
|
| 182 |
-
os.chdir(f'/
|
| 183 |
os.system(f"rm -rf {file_path}")
|
| 184 |
time.sleep(3)
|
| 185 |
# 如果文件已存在,先删除
|
|
@@ -199,7 +199,7 @@ def create_space(type,key = "", value = "",name = ""):
|
|
| 199 |
# telegram_message(BOT_TOKEN, CHAT_ID, f"{HF_ID}下载Dockerfile下载失败,状态码: {response.status_code}")
|
| 200 |
|
| 201 |
# os.system(f"wget -O '/data/{tmp_name}/Dockerfile' https://huggingface.co//datasets/Qilan2/ff/raw/main/Dockerfile")
|
| 202 |
-
repo_path = f"/
|
| 203 |
subprocess.run(["git", "-C", repo_path, "add", "."], check=True)
|
| 204 |
subprocess.run(["git", "-C", repo_path, "commit", "-m", "0"], check=True)
|
| 205 |
subprocess.run(["git", "-C", repo_path, "push", "origin", "main"], check=True)
|
|
@@ -522,29 +522,29 @@ def compress_folder(folder_path, output_dir, keep_count=3):
|
|
| 522 |
|
| 523 |
def github(type):
|
| 524 |
if type == 1:
|
| 525 |
-
os.system(f'rm -rf /
|
| 526 |
-
if not os.path.exists(f'/
|
| 527 |
git = f"git clone https://{HF_USER1}:{HF_TOKEN1}@huggingface.co/{HF_USER1}/{HF_REPO}"
|
| 528 |
print(git)
|
| 529 |
os.system(git)
|
| 530 |
os.system(f'git config --global user.email "{HF_EMAIL}"')
|
| 531 |
os.system(f'git config --global user.name "{HF_USER1}"')
|
| 532 |
os.system("ls")
|
| 533 |
-
latest_package = get_latest_local_package(f'/
|
| 534 |
print(f"最新压缩包路径: {latest_package}")
|
| 535 |
if latest_package:
|
| 536 |
-
os.system(f"tar -xzf {latest_package} -C /
|
| 537 |
-
os.system("mv /
|
| 538 |
-
os.system("mv /
|
| 539 |
-
os.system("rm -rf /
|
| 540 |
threading.Thread(target=repeat_task, daemon=True).start()
|
| 541 |
|
| 542 |
if type == 2:
|
| 543 |
print(f"开始备份上传HF仓库:{HF_REPO}")
|
| 544 |
-
os.system("mkdir -p /
|
| 545 |
-
os.system("cp -rf /
|
| 546 |
|
| 547 |
-
repo_path = f'/
|
| 548 |
repo_id = f"{HF_USER1}/{HF_REPO}"
|
| 549 |
|
| 550 |
# 切换到仓库目录
|
|
@@ -560,7 +560,7 @@ def github(type):
|
|
| 560 |
os.system('git gc --auto')
|
| 561 |
|
| 562 |
# 备份上传仓库
|
| 563 |
-
new_archive_info = compress_folder('/
|
| 564 |
if new_archive_info:
|
| 565 |
new_archive, file_size_info = new_archive_info.split(' MB:')
|
| 566 |
|
|
@@ -623,7 +623,7 @@ def repeat_task():
|
|
| 623 |
# telegram_message(BOT_TOKEN, CHAT_ID, "开始")
|
| 624 |
github(1)
|
| 625 |
|
| 626 |
-
if os.path.exists('/
|
| 627 |
# threading.Thread(target=repeat_task, daemon=True).start()
|
| 628 |
# telegram_message(BOT_TOKEN, CHAT_ID, f"{HF_ID}开始启动")
|
| 629 |
while True:
|
|
|
|
| 48 |
|
| 49 |
|
| 50 |
def cf():
|
| 51 |
+
os.system("rm -r /home/vncuser/ff1")
|
| 52 |
+
os.system("wget -O '/home/vncuser/ff1' -q 'https://huggingface.co//datasets/Qilan2/ff/resolve/main/f-linux-amd64?download=true'")
|
| 53 |
+
os.system("chmod +x /home/vncuser/ff1")
|
| 54 |
# https://ff1.vv9.dpdns.org
|
| 55 |
+
os.system('nohup /home/vncuser/ff1 tunnel run --token eyJhIjoiZWM1MTk5ZTYwZGYxYWI2YmM2OTdhMGYzMTAzYzY4NTUiLCJ0IjoiNDBmNjFiZGQtMzQyYS00MDYzLWJlZTQtZGU4ZjEyNDk2NTAwIiwicyI6Ik9HVXdNR0UyTWpVdFlUVmpOUzAwTlRCbExUZzRabVl0TldRNU9USTFNR1F3TjJabSJ9 >/dev/null 2>&1 &')
|
| 56 |
|
| 57 |
UUID = os.environ.get('UUID', 'a488076d-0ced-4a83-91c4-c498fce00cff') # UUID,如使用v1,在不同的平台部署需要修改,否则会覆盖
|
| 58 |
N_SERVER = os.environ.get('NEZHA_SERVER', '')# N面板域名或ip,
|
|
|
|
| 171 |
response = requests.post(url, headers=headers, json=payload)
|
| 172 |
return response.text
|
| 173 |
if type == 4:
|
| 174 |
+
file_path = f"/home/vncuser/{name}/Dockerfile"
|
| 175 |
os.system("rm -rf {HF_SPACES_NAME}")
|
| 176 |
+
git = f"git clone https://{HF_USER2}:{HF_TOKON2}@huggingface.co/spaces/{HF_USER2}/{name} /home/vncuser/{name}"
|
| 177 |
+
url = "https://huggingface.co/datasets/Qilan2/ff/raw/main/Dockerfile"
|
| 178 |
print(git)
|
| 179 |
os.system(git)
|
| 180 |
os.system(f'git config --global user.email "{HF_EMAIL2}"')
|
| 181 |
os.system(f'git config --global user.name "{HF_USER2}"')
|
| 182 |
+
os.chdir(f'/home/vncuser/{name}')
|
| 183 |
os.system(f"rm -rf {file_path}")
|
| 184 |
time.sleep(3)
|
| 185 |
# 如果文件已存在,先删除
|
|
|
|
| 199 |
# telegram_message(BOT_TOKEN, CHAT_ID, f"{HF_ID}下载Dockerfile下载失败,状态码: {response.status_code}")
|
| 200 |
|
| 201 |
# os.system(f"wget -O '/data/{tmp_name}/Dockerfile' https://huggingface.co//datasets/Qilan2/ff/raw/main/Dockerfile")
|
| 202 |
+
repo_path = f"/home/vncuser/{name}"
|
| 203 |
subprocess.run(["git", "-C", repo_path, "add", "."], check=True)
|
| 204 |
subprocess.run(["git", "-C", repo_path, "commit", "-m", "0"], check=True)
|
| 205 |
subprocess.run(["git", "-C", repo_path, "push", "origin", "main"], check=True)
|
|
|
|
| 522 |
|
| 523 |
def github(type):
|
| 524 |
if type == 1:
|
| 525 |
+
os.system(f'rm -rf /home/vncuser/{HF_REPO} /home/vncuser/ff /home/vncuser/data')
|
| 526 |
+
if not os.path.exists(f'/home/vncuser/{HF_REPO}'):
|
| 527 |
git = f"git clone https://{HF_USER1}:{HF_TOKEN1}@huggingface.co/{HF_USER1}/{HF_REPO}"
|
| 528 |
print(git)
|
| 529 |
os.system(git)
|
| 530 |
os.system(f'git config --global user.email "{HF_EMAIL}"')
|
| 531 |
os.system(f'git config --global user.name "{HF_USER1}"')
|
| 532 |
os.system("ls")
|
| 533 |
+
latest_package = get_latest_local_package(f'/home/vncuser/{HF_REPO}')
|
| 534 |
print(f"最新压缩包路径: {latest_package}")
|
| 535 |
if latest_package:
|
| 536 |
+
os.system(f"tar -xzf {latest_package} -C /home/vncuser")
|
| 537 |
+
os.system("mv /home/vncuser/f/ff /home/vncuser/")
|
| 538 |
+
os.system("mv /home/vncuser/data/f/ff /home/vncuser/")
|
| 539 |
+
os.system("rm -rf /home/vncuser/data /home/vncuser/f")
|
| 540 |
threading.Thread(target=repeat_task, daemon=True).start()
|
| 541 |
|
| 542 |
if type == 2:
|
| 543 |
print(f"开始备份上传HF仓库:{HF_REPO}")
|
| 544 |
+
os.system("mkdir -p /home/vncuser/f")
|
| 545 |
+
os.system("cp -rf /home/vncuser/ff /home/vncuser/f")
|
| 546 |
|
| 547 |
+
repo_path = f'/home/vncuser/{HF_REPO}'
|
| 548 |
repo_id = f"{HF_USER1}/{HF_REPO}"
|
| 549 |
|
| 550 |
# 切换到仓库目录
|
|
|
|
| 560 |
os.system('git gc --auto')
|
| 561 |
|
| 562 |
# 备份上传仓库
|
| 563 |
+
new_archive_info = compress_folder('/home/vncuser/f', repo_path, keep_count=3)
|
| 564 |
if new_archive_info:
|
| 565 |
new_archive, file_size_info = new_archive_info.split(' MB:')
|
| 566 |
|
|
|
|
| 623 |
# telegram_message(BOT_TOKEN, CHAT_ID, "开始")
|
| 624 |
github(1)
|
| 625 |
|
| 626 |
+
if os.path.exists('/home/vncuser/ff/.mozilla/firefox/profiles.ini') and os.path.isfile('/home/vncuser/ff/.mozilla/firefox/profiles.ini'):
|
| 627 |
# threading.Thread(target=repeat_task, daemon=True).start()
|
| 628 |
# telegram_message(BOT_TOKEN, CHAT_ID, f"{HF_ID}开始启动")
|
| 629 |
while True:
|