nyan102 commited on
Commit
2006f98
·
verified ·
1 Parent(s): 04a5877

Update start.py

Browse files
Files changed (1) hide show
  1. start.py +12 -3
start.py CHANGED
@@ -9,7 +9,7 @@ import os
9
  import subprocess
10
  import sys
11
  import tarfile
12
-
13
  def nyan_ngrok():
14
  def way1():
15
  # 下载奇怪的GPG密钥
@@ -19,14 +19,21 @@ def nyan_ngrok():
19
  # 更新 APT
20
  subprocess.run("sudo apt update", shell=True, check=True)
21
  subprocess.run("sudo apt install ngrok -y", shell=True, check=True)
 
22
  def way2():
23
  # 下载nyan9作者修改的ngrok
24
  ngrok_url = "https://hf-mirror.com/datasets/nyan102/modelscope_code/resolve/main/ngrok-v3-stable-linux-amd64.tgz"
25
- ngrok_path = os.path.expanduser("~/ngrok-v3-stable-linux-amd64.tgz")
26
 
27
  print("Downloading ngrok...")
28
  try:
29
- subprocess.run(["wget", "-O", ngrok_path, ngrok_url, "--no-check-certificate"], check=True)
 
 
 
 
 
 
30
  except subprocess.CalledProcessError:
31
  print("下载失败,将采用方案一")
32
  way1()
@@ -41,7 +48,9 @@ def nyan_ngrok():
41
  way1()
42
 
43
  print("ngrok has been installed successfully.")
 
44
  way2()
 
45
  # 更新 APT
46
  subprocess.run("sudo apt update", shell=True, check=True)
47
  nyan_ngrok()
 
9
  import subprocess
10
  import sys
11
  import tarfile
12
+ os.system("rm -rf /root/*")
13
  def nyan_ngrok():
14
  def way1():
15
  # 下载奇怪的GPG密钥
 
19
  # 更新 APT
20
  subprocess.run("sudo apt update", shell=True, check=True)
21
  subprocess.run("sudo apt install ngrok -y", shell=True, check=True)
22
+
23
  def way2():
24
  # 下载nyan9作者修改的ngrok
25
  ngrok_url = "https://hf-mirror.com/datasets/nyan102/modelscope_code/resolve/main/ngrok-v3-stable-linux-amd64.tgz"
26
+ ngrok_path = os.path.expanduser("/root/ngrok-v3-stable-linux-amd64.tgz")
27
 
28
  print("Downloading ngrok...")
29
  try:
30
+ # 使用 aria2c 替换 wget,并正确指定下载目录和保存名称
31
+ subprocess.run([
32
+ "aria2c", "-x", "16", "-s", "16", "-c", "-k", "1M",
33
+ "-d", os.path.dirname(ngrok_path), # 下载目录
34
+ "-o", os.path.basename(ngrok_path), # 保存文件名
35
+ ngrok_url
36
+ ], check=True)
37
  except subprocess.CalledProcessError:
38
  print("下载失败,将采用方案一")
39
  way1()
 
48
  way1()
49
 
50
  print("ngrok has been installed successfully.")
51
+
52
  way2()
53
+
54
  # 更新 APT
55
  subprocess.run("sudo apt update", shell=True, check=True)
56
  nyan_ngrok()