-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlinux.sh
230 lines (204 loc) · 8.9 KB
/
linux.sh
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
#!/bin/bash
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
bit=`uname -m`
}
ubt2004(){
check_sys
[[ ${release} = "ubuntu" ]] && [[ $(lsb_release -r --short) = "20.04" ]] && [[ $(uname -m) = "aarch64" ]] && sudo cp -a /etc/apt/sources.list /etc/apt/sources.list.bak && sudo wget -O /etc/apt/sources.list https://cdn.jsdelivr.net/gh/waterrr/Script/arm/Ubuntu-Ports-focal.list && echo "已经替换源为阿里源(ARM),默认源备份在【/etc/apt/sources.list.bak】"&& exit 1
check_sys
[[ ${release} != "ubuntu" ]] || [[ $(lsb_release -r --short) != "20.04" ]] && echo -e "${Error} 本脚本不支持当前系统 ${release} $(lsb_release -r --short) !" && exit 1
sudo echo "
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
">/root/tmp
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo rm /etc/apt/sources.list
sudo cp /root/tmp /etc/apt/sources.list
sudo rm /root/tmp
sudo echo "已经替换源为阿里源,默认源备份在【/etc/apt/sources.list.bak】"
sudo echo "请尝试执行【apt update&apt upgrade】查看是否生效"
}
ubt1804(){
check_sys
[[ ${release} = "ubuntu" ]] && [[ $(lsb_release -r --short) = "18.04" ]] && [[ $(uname -m) = "aarch64" ]] && sudo cp -a /etc/apt/sources.list /etc/apt/sources.list.bak && sudo wget -O /etc/apt/sources.list https://cdn.jsdelivr.net/gh/waterrr/Script/arm/Ubuntu-Ports-bionic.list && echo "已经替换源为阿里源(ARM),默认源备份在【/etc/apt/sources.list.bak】"&& exit 1
check_sys
[[ ${release} != "ubuntu" ]] || [[ $(lsb_release -r --short) != "18.04" ]] && echo -e "${Error} 本脚本不支持当前系统 ${release} $(lsb_release -r --short) !" && exit 1
sudo echo "
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
">/root/tmp
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo rm /etc/apt/sources.list
sudo cp /root/tmp /etc/apt/sources.list
sudo rm /root/tmp
sudo echo "已经替换源为阿里源,默认源备份在【/etc/apt/sources.list.bak】"
sudo echo "请尝试执行【apt update&apt upgrade】查看是否生效"
}
ubt1604(){
check_sys
[[ ${release} = "ubuntu" ]] && [[ $(lsb_release -r --short) = "16.04" ]] && [[ $(uname -m) = "aarch64" ]] && sudo cp -a /etc/apt/sources.list /etc/apt/sources.list.bak && sudo wget -O /etc/apt/sources.list https://cdn.jsdelivr.net/gh/waterrr/Script/arm/Ubuntu-Ports-xenial.list && echo "已经替换源为阿里源(ARM),默认源备份在【/etc/apt/sources.list.bak】"&& exit 1
check_sys
[[ ${release} != "ubuntu" ]] || [[ $(lsb_release -r --short) != "16.04" ]] && echo -e "${Error} 本脚本不支持当前系统 ${release} $(lsb_release -r --short) !" && exit 1
sudo echo "
deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe
">/root/tmp
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo rm /etc/apt/sources.list
sudo cp /root/tmp /etc/apt/sources.list
sudo rm /root/tmp
sudo echo "已经替换源为阿里源,默认源备份在【/etc/apt/sources.list.bak】"
sudo echo "请尝试执行【apt update&apt upgrade】查看是否生效"
}
PyPI(){
if [ ! -d "/root/.pip" ]; then
sudo mkdir /root/.pip
fi
sudo echo "
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
">/root/.pip/pip.conf
sudo echo "已经更换PyPI默认源为阿里镜像源,请尝试执行【pip install --upgrade pip】查看是否生效"
}
Docker(){
echo "正在安装Docker"
echo `curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh --mirror Aliyun`
echo "Docker安装完毕"
echo `rm get-docker.sh`
sudo systemctl daemon-reload
sudo systemctl restart docker
}
Docker_Compose(){
echo "正在安装DockerCompose"
echo `curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m) > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose`
echo "DockerCompose安装完毕"
}
Docker_Hub(){
sudo echo "{
\"registry-mirrors\": [
\"https://hub-mirror.c.163.com\",
\"https://docker.mirrors.ustc.edu.cn\"
]
}">/root/tmp
mkdir /etc/docker/
#sudo cp /etc/docker/daemon.json /etc/docker/daemon.json.bak
#sudo rm /etc/docker/daemon.json
sudo cp /root/tmp /etc/docker/daemon.json
sudo rm /root/tmp
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo echo "已经替换DockerHub为国内阿里/中科大源"
}
Superbench(){
while [ ! -f ./bench ]; do
wget https://bench.im/bench.py -O bench
done
sudo python3 bench
sudo rm ./bench
break
}
Netflix_check(){
while [ ! -f ./check.sh ]; do
wget -N -P ./ --no-check-certificate https://cdn.jsdelivr.net/gh/waterrr/Script/check.sh
done
chmod +x check.sh
bash check.sh
}
echo -e " Linux服务器常见一键脚本 ${Red_font_prefix}[0.3]${Font_color_suffix}
----Upgrade in 2021-09-06 ----
---- W4ter | https://github.com/waterrr ----
---- iriszero | https://github.com/iriszero48 ----
${Green_font_prefix}1.${Font_color_suffix} 更换Ubuntu20.04(focal)默认源为阿里源【支持ARM】
${Green_font_prefix}2.${Font_color_suffix} 更换Ubuntu18.04(bionic)默认源为阿里源【支持ARM】
${Green_font_prefix}3.${Font_color_suffix} 更换Ubuntu16.04(xenial)默认源为阿里源【支持ARM】
${Green_font_prefix}4.${Font_color_suffix} 更换PyPI默认源为阿里镜像源
————————————
${Green_font_prefix}5.${Font_color_suffix} 一键安装Docker【国内镜像】
${Green_font_prefix}6.${Font_color_suffix} 一键安装Docker Compose【国内镜像】
${Green_font_prefix}7.${Font_color_suffix} 一键加速DockerHub镜像【阿里/中科大源】
————————————
${Green_font_prefix}8.${Font_color_suffix} 一键测试网速 | bench.im【需要python3支持】
${Green_font_prefix}9.${Font_color_suffix} 一键测试服务器流媒体解锁
————————————
${Green_font_prefix}0.${Font_color_suffix} ${Red_font_prefix}EXIT${Font_color_suffix}
"
echo && read -e -p "请输入数字 [0-9]:" num
case "$num" in
0)
exit 0
;;
1)
ubt2004
;;
2)
ubt1804
;;
3)
ubt1604
;;
4)
PyPI
;;
5)
Docker
;;
6)
Docker_Compose
;;
7)
Docker_Hub
;;
8)
Superbench
;;
9)
Netflix_check
;;
*)
echo -e "${Error} 请输入正确的数字 [0-9]"
;;
esac