Repository navigation
Expand file tree
/
Copy pathInstall.sh
More file actions
327 lines (305 loc) · 8.42 KB
/
Copy pathInstall.sh
File metadata and controls
327 lines (305 loc) · 8.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#=================================================
# System Required: CentOS 6/7,Debian 8/9,Ubuntu 16+
# Description: 一键重装系统
# Version: 1.0.1
# Author: 千影,Vicer
# Blog: https://www.94ish.me/
#=================================================
sh_ver="1.0.1"
github="raw.githubusercontent.com/chiakge/installNET/master"
Green_font_prefix="\033[32m" && Red_font_prefix="\033[31m" && Green_background_prefix="\033[42;37m" && Red_background_prefix="\033[41;37m" && Font_color_suffix="\033[0m"
Info="${Green_font_prefix}[信息]${Font_color_suffix}"
Error="${Red_font_prefix}[错误]${Font_color_suffix}"
Tip="${Green_font_prefix}[注意]${Font_color_suffix}"
#安装环境
first_job(){
if [[ "${release}" == "centos" ]]; then
yum install -y xz openssl gawk file
elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
apt-get update
apt-get install -y xz-utils openssl gawk file
fi
}
# 安装系统
InstallOS(){
read -p " 请设置密码:" pw
if [[ "${model}" == "自动" ]]; then
model="a"
else
model="m"
fi
if [[ "${country}" == "国外" ]]; then
country=""
else
if [[ "${os}" == "c" ]]; then
country="--mirror https://mirrors.tuna.tsinghua.edu.cn/centos/"
elif [[ "${os}" == "u" ]]; then
country="--mirror https://mirrors.tuna.tsinghua.edu.cn/ubuntu/"
elif [[ "${os}" == "d" ]]; then
country="--mirror https://mirrors.tuna.tsinghua.edu.cn/debian/"
fi
fi
wget --no-check-certificate https://${github}/InstallNET.sh && chmod -x InstallNET.sh
bash InstallNET.sh -${os} ${1} -v ${vbit} -${model} -p ${pw} ${country}
}
# 安装系统
installadvanced(){
read -p " 请设置参数:" advanced
wget --no-check-certificate https://${github}/InstallNET.sh && chmod -x InstallNET.sh
bash InstallNET.sh $advanced
}
# 切换位数
switchbit(){
if [[ "${vbit}" == "64" ]]; then
vbit="32"
else
vbit="64"
fi
}
# 切换模式
switchmodel(){
if [[ "${model}" == "自动" ]]; then
model="手动"
else
model="自动"
fi
}
# 切换国家
switchcountry(){
if [[ "${country}" == "国外" ]]; then
country="国内"
else
country="国外"
fi
}
#安装CentOS
installCentos(){
clear
os="c"
echo && echo -e " 一键网络重装管理脚本 ${Red_font_prefix}[v${sh_ver}]${Font_color_suffix}
-- 就是爱生活 | 94ish.me --
————————————选择版本————————————
${Green_font_prefix}1.${Font_color_suffix} 安装 CentOS6.8系统
${Green_font_prefix}2.${Font_color_suffix} 安装 CentOS6.9系统
————————————切换模式————————————
${Green_font_prefix}3.${Font_color_suffix} 切换安装位数
${Green_font_prefix}4.${Font_color_suffix} 切换安装模式
${Green_font_prefix}5.${Font_color_suffix} 切换镜像源
————————————————————————————————
${Green_font_prefix}0.${Font_color_suffix} 返回主菜单" && echo
echo -e " 当前模式: 安装${Red_font_prefix}${vbit}${Font_color_suffix}位系统,${Red_font_prefix}${model}${Font_color_suffix}模式,${Red_font_prefix}${country}${Font_color_suffix}镜像源。"
echo
read -p " 请输入数字 [0-11]:" num
case "$num" in
0)
start_menu
;;
1)
InstallOS "6.8"
;;
2)
InstallOS "6.9"
;;
3)
switchbit
installCentos
;;
4)
switchmodel
installCentos
;;
5)
switchcountry
installCentos
;;
*)
clear
echo -e "${Error}:请输入正确数字 [0-11]"
sleep 5s
installCentos
;;
esac
}
#安装Debian
installDebian(){
clear
os="d"
echo && echo -e " 一键网络重装管理脚本 ${Red_font_prefix}[v${sh_ver}]${Font_color_suffix}
-- 就是爱生活 | 94ish.me --
————————————选择版本————————————
${Green_font_prefix}1.${Font_color_suffix} 安装 Debian9系统
${Green_font_prefix}2.${Font_color_suffix} 安装 Debian10系统
${Green_font_prefix}3.${Font_color_suffix} 安装 Debian11系统
————————————切换模式————————————
${Green_font_prefix}4.${Font_color_suffix} 切换安装位数
${Green_font_prefix}5.${Font_color_suffix} 切换安装模式
${Green_font_prefix}6.${Font_color_suffix} 切换镜像源
————————————————————————————————
${Green_font_prefix}0.${Font_color_suffix} 返回主菜单" && echo
echo -e " 当前模式: 安装${Red_font_prefix}${vbit}${Font_color_suffix}位系统,${Red_font_prefix}${model}${Font_color_suffix}模式,${Red_font_prefix}${country}${Font_color_suffix}镜像源。"
echo
read -p " 请输入数字 [0-11]:" num
case "$num" in
0)
start_menu
;;
1)
InstallOS "9"
;;
2)
InstallOS "10"
;;
3)
InstallOS "11"
;;
4)
switchbit
installDebian
;;
5)
switchmodel
installDebian
;;
6)
switchcountry
installDebian
;;
*)
clear
echo -e "${Error}:请输入正确数字 [0-11]"
sleep 5s
installCentos
;;
esac
}
#安装Ubuntu
installUbuntu(){
clear
os="u"
echo && echo -e " 一键网络重装管理脚本 ${Red_font_prefix}[v${sh_ver}]${Font_color_suffix}
-- 就是爱生活 | 94ish.me --
————————————选择版本————————————
${Green_font_prefix}1.${Font_color_suffix} 安装 Ubuntu16系统
${Green_font_prefix}2.${Font_color_suffix} 安装 Ubuntu18系统
${Green_font_prefix}3.${Font_color_suffix} 安装 Ubuntu20系统
————————————切换模式————————————
${Green_font_prefix}4.${Font_color_suffix} 切换安装位数
${Green_font_prefix}5.${Font_color_suffix} 切换安装模式
${Green_font_prefix}6.${Font_color_suffix} 切换镜像源
————————————————————————————————
${Green_font_prefix}0.${Font_color_suffix} 返回主菜单" && echo
echo -e " 当前模式: 安装${Red_font_prefix}${vbit}${Font_color_suffix}位系统,${Red_font_prefix}${model}${Font_color_suffix}模式,${Red_font_prefix}${country}${Font_color_suffix}镜像源。"
echo
read -p " 请输入数字 [0-11]:" num
case "$num" in
0)
start_menu
;;
1)
InstallOS "16.04"
;;
2)
InstallOS "18.04"
;;
3)
InstallOS "20.04"
;;
4)
switchbit
installUbuntu
;;
5)
switchmodel
installUbuntu
;;
6)
switchcountry
installUbuntu
;;
*)
clear
echo -e "${Error}:请输入正确数字 [0-11]"
sleep 5s
installCentos
;;
esac
}
#开始菜单
start_menu(){
clear
echo && echo -e " 一键网络重装管理脚本 ${Red_font_prefix}[v${sh_ver}]${Font_color_suffix}
-- 就是爱生活 | 94ish.me --
————————————重装系统————————————
${Green_font_prefix}1.${Font_color_suffix} 安装 CentOS系统
${Green_font_prefix}2.${Font_color_suffix} 安装 Debian系统
${Green_font_prefix}3.${Font_color_suffix} 安装 Ubuntu系统
${Green_font_prefix}4.${Font_color_suffix} 高级模式(自定义参数)
————————————切换模式————————————
${Green_font_prefix}5.${Font_color_suffix} 切换安装位数
${Green_font_prefix}6.${Font_color_suffix} 切换安装模式
${Green_font_prefix}7.${Font_color_suffix} 切换镜像源
————————————————————————————————" && echo
echo -e " 当前模式: 安装${Red_font_prefix}${vbit}${Font_color_suffix}位系统,${Red_font_prefix}${model}${Font_color_suffix}模式,${Red_font_prefix}${country}${Font_color_suffix}镜像源。"
echo
read -p " 请输入数字 [0-11]:" num
case "$num" in
1)
installCentos
;;
2)
installDebian
;;
3)
installUbuntu
;;
4)
installadvanced
;;
5)
switchbit
start_menu
;;
6)
switchmodel
start_menu
;;
7)
switchcountry
start_menu
;;
*)
clear
echo -e "${Error}:请输入正确数字 [0-11]"
sleep 5s
start_menu
;;
esac
}
#############系统检测组件#############
#检查系统
check_sys(){
if [[ -f /etc/redhat-release ]]; then
release="centos"
elif cat /etc/issue | grep -q -E -i "debian"; then
release="debian"
elif cat /etc/issue | grep -q -E -i "ubuntu"; then
release="ubuntu"
elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then
release="centos"
elif cat /proc/version | grep -q -E -i "debian"; then
release="debian"
elif cat /proc/version | grep -q -E -i "ubuntu"; then
release="ubuntu"
elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then
release="centos"
fi
}
check_sys
first_job
model="自动"
vbit="64"
country="国外"
start_menu