8
8
# 添加更多服务器
9
9
]
10
10
11
+
11
12
# 定义更新操作
12
13
def update_server (name , hostname , port , username , password ):
13
14
try :
@@ -18,7 +19,7 @@ def update_server(name, hostname, port, username, password):
18
19
client .connect (hostname , port = port , username = username , password = password )
19
20
20
21
# 执行步骤1: 更新操作
21
- print (f" { name } 更新" )
22
+ print (f"{ name } 更新" )
22
23
stdin , stdout , stderr = client .exec_command ("apt update -y && apt install -y curl wget sudo socat htop" )
23
24
24
25
print (f"正在更新:" )
@@ -36,7 +37,7 @@ def update_server(name, hostname, port, username, password):
36
37
37
38
38
39
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" )
40
41
41
42
print (f"正在安装 Docker:" )
42
43
while not stdout .channel .exit_status_ready ():
@@ -53,7 +54,7 @@ def update_server(name, hostname, port, username, password):
53
54
54
55
55
56
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' )
57
58
58
59
print (f"正在安装 Docker Compose:" )
59
60
while not stdout .channel .exit_status_ready ():
@@ -81,6 +82,7 @@ def update_server(name, hostname, port, username, password):
81
82
# 关闭 SSH 连接
82
83
client .close ()
83
84
85
+
84
86
except Exception as e :
85
87
print (f"连接 { name } 失败" )
86
88
@@ -96,3 +98,4 @@ def update_server(name, hostname, port, username, password):
96
98
97
99
# 等待用户按下任意键后关闭窗口
98
100
input ("按任意键关闭窗口..." )
101
+
0 commit comments