Skip to content

Commit 6fa15d5

Browse files
authoredJun 8, 2023
优化安装稳定性
1 parent 398fc7a commit 6fa15d5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed
 

‎一键所有VPS安装docker.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# 添加更多服务器
99
]
1010

11+
1112
# 定义更新操作
1213
def update_server(name, hostname, port, username, password):
1314
try:
@@ -18,7 +19,7 @@ def update_server(name, hostname, port, username, password):
1819
client.connect(hostname, port=port, username=username, password=password)
1920

2021
# 执行步骤1: 更新操作
21-
print(f" {name} 更新")
22+
print(f"{name} 更新")
2223
stdin, stdout, stderr = client.exec_command("apt update -y && apt install -y curl wget sudo socat htop")
2324

2425
print(f"正在更新:")
@@ -36,7 +37,7 @@ def update_server(name, hostname, port, username, password):
3637

3738

3839
print(f"{name} 安装 Docker")
39-
stdin, stdout, stderr = client.exec_command("wget -qO- https://get.docker.com/ | sh")
40+
stdin, stdout, stderr = client.exec_command("curl -fsSL https://get.docker.com | sh")
4041

4142
print(f"正在安装 Docker:")
4243
while not stdout.channel.exit_status_ready():
@@ -53,7 +54,7 @@ def update_server(name, hostname, port, username, password):
5354

5455

5556
print(f"{name} 安装 Docker Compose")
56-
stdin, stdout, stderr = client.exec_command("wget https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-$(uname -s)-$(uname -m) -O /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose")
57+
stdin, stdout, stderr = client.exec_command('curl -L "https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose')
5758

5859
print(f"正在安装 Docker Compose:")
5960
while not stdout.channel.exit_status_ready():
@@ -81,6 +82,7 @@ def update_server(name, hostname, port, username, password):
8182
# 关闭 SSH 连接
8283
client.close()
8384

85+
8486
except Exception as e:
8587
print(f"连接 {name} 失败")
8688

@@ -96,3 +98,4 @@ def update_server(name, hostname, port, username, password):
9698

9799
# 等待用户按下任意键后关闭窗口
98100
input("按任意键关闭窗口...")
101+

0 commit comments

Comments
 (0)