Skip to content

Commit 2664d07

Browse files
committed
更新脚本
1 parent 700d814 commit 2664d07

File tree

7 files changed

+146
-11
lines changed

7 files changed

+146
-11
lines changed

codes/linux/ops/service/maven/install-maven3.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,3 @@ source /etc/profile
2828
echo -e "\n>>>>>>>>> replace /opt/maven/apache-maven-${version}/conf/settings.xml"
2929
cp /opt/maven/apache-maven-${version}/conf/settings.xml /opt/maven/apache-maven-${version}/conf/settings.xml.bak
3030
wget -N https://raw.githubusercontent.com/dunwu/os-tutorial/master/codes/linux/ops/service/maven/settings-aliyun.xml -O /opt/maven/apache-maven-${version}/conf/settings.xml
31-
32-
# 回到初始目录
33-
cd -

codes/linux/ops/service/nodejs/install-nodejs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ echo -e "\n>>>>>>>>> install node.js"
1111
. ~/.nvm/nvm.sh
1212
nvm --version
1313
execode=$?
14-
if [ ${execode} != 0 ]; then
14+
if [[ ${execode} != 0 ]]; then
1515
echo -e "\n未找到 nvm ,开始安装"
1616
echo -e "\n>>>>>>>>> install nvm"
1717
rm -rf ~/.nvm

codes/linux/sys/yum/Centos-6.repo

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# CentOS-Base.repo
2+
#
3+
# The mirror system uses the connecting IP address of the client and the
4+
# update status of each mirror to pick mirrors that are updated to and
5+
# geographically close to the client. You should use this for CentOS updates
6+
# unless you are manually picking other mirrors.
7+
#
8+
# If the mirrorlist= does not work for you, as a fall back you can try the
9+
# remarked out baseurl= line instead.
10+
#
11+
#
12+
13+
[base]
14+
name=CentOS-$releasever - Base - mirrors.aliyun.com
15+
failovermethod=priority
16+
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
17+
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
18+
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
19+
gpgcheck=1
20+
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
21+
22+
#released updates
23+
[updates]
24+
name=CentOS-$releasever - Updates - mirrors.aliyun.com
25+
failovermethod=priority
26+
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
27+
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
28+
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
29+
gpgcheck=1
30+
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
31+
32+
#additional packages that may be useful
33+
[extras]
34+
name=CentOS-$releasever - Extras - mirrors.aliyun.com
35+
failovermethod=priority
36+
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
37+
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
38+
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
39+
gpgcheck=1
40+
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
41+
42+
#additional packages that extend functionality of existing packages
43+
[centosplus]
44+
name=CentOS-$releasever - Plus - mirrors.aliyun.com
45+
failovermethod=priority
46+
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
47+
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
48+
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
49+
gpgcheck=1
50+
enabled=0
51+
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
52+
53+
#contrib - packages by Centos Users
54+
[contrib]
55+
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
56+
failovermethod=priority
57+
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
58+
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
59+
http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
60+
gpgcheck=1
61+
enabled=0
62+
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

codes/linux/sys/yum/Centos-7.repo

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# CentOS-Base.repo
2+
#
3+
# The mirror system uses the connecting IP address of the client and the
4+
# update status of each mirror to pick mirrors that are updated to and
5+
# geographically close to the client. You should use this for CentOS updates
6+
# unless you are manually picking other mirrors.
7+
#
8+
# If the mirrorlist= does not work for you, as a fall back you can try the
9+
# remarked out baseurl= line instead.
10+
#
11+
#
12+
13+
[base]
14+
name=CentOS-$releasever - Base - mirrors.aliyun.com
15+
failovermethod=priority
16+
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
17+
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
18+
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
19+
gpgcheck=1
20+
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
21+
22+
#released updates
23+
[updates]
24+
name=CentOS-$releasever - Updates - mirrors.aliyun.com
25+
failovermethod=priority
26+
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
27+
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
28+
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
29+
gpgcheck=1
30+
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
31+
32+
#additional packages that may be useful
33+
[extras]
34+
name=CentOS-$releasever - Extras - mirrors.aliyun.com
35+
failovermethod=priority
36+
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
37+
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
38+
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
39+
gpgcheck=1
40+
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
41+
42+
#additional packages that extend functionality of existing packages
43+
[centosplus]
44+
name=CentOS-$releasever - Plus - mirrors.aliyun.com
45+
failovermethod=priority
46+
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
47+
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
48+
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
49+
gpgcheck=1
50+
enabled=0
51+
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
52+
53+
#contrib - packages by Centos Users
54+
[contrib]
55+
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
56+
failovermethod=priority
57+
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
58+
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
59+
http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
60+
gpgcheck=1
61+
enabled=0
62+
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

codes/linux/sys/yum/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# 脚本使用说明
2+
3+
## 替换 yum repo 源
4+
5+
由于 CentOS 默认 yum 源,访问速度很慢,所以推荐使用国内镜像。
6+
7+
使用方法:执行以下任意命令即可执行脚本。
8+
9+
```sh
10+
curl -o- https://raw.githubusercontent.com/dunwu/os-tutorial/master/codes/linux/sys/yum/change-yum-repo.sh | bash
11+
wget -qO- https://raw.githubusercontent.com/dunwu/os-tutorial/master/codes/linux/sys/yum/change-yum-repo.sh | bash
12+
```

codes/linux/sys/yum/change-yum-repo.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,25 @@ cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
1515
# version=`lsb_release -r | awk '{print substr($2,1,1)}'` # 很多机器没有 lsb_release 命令
1616
version=`cat /etc/redhat-release | awk '{print substr($4,1,1)}'`
1717

18+
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
19+
1820
# 根据发型版本选择相应 yum 镜像
19-
if [ ${version} == 5 ]; then
21+
if [[ ${version} == 5 ]]; then
2022
# Cento5 已废弃,只能使用 http://vault.CentOS.org/ 替换,但由于是国外镜像,速度较慢
21-
wget --no-cookie --no-check-certificate -O /etc/yum.repos.d/CentOS-Base.repo https://github.com/dunwu/os-tutorial/master/codes/deploy/sys/yum/CentOS-Base.repo
23+
wget -N https://raw.githubusercontent.com/dunwu/os-tutorial/master/codes/linux/sys/yum/Centos-5.repo -O /etc/yum.repos.d/CentOS-Base.repo
2224

2325
# 根据实际发型版本情况替换
2426
detailVersion=`lsb_release -r | awk '{print substr($2,1,3)}'`
2527
sed -i 's/$releasever/'"${detailVersion}"'/g' /etc/yum.repos.d/CentOS-Base.repo
2628

2729
# 不替换下面的开关,可能会出现错误:Could not open/read repomd.xml
2830
sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/CentOS-Media.repo
31+
elif [[ ${version} == 6 ]]; then
32+
wget -N https://raw.githubusercontent.com/dunwu/os-tutorial/master/codes/linux/sys/yum/Centos-6.repo -O /etc/yum.repos.d/CentOS-Base.repo
33+
elif [[ ${version} == 7 ]]; then
34+
wget -N https://raw.githubusercontent.com/dunwu/os-tutorial/master/codes/linux/sys/yum/Centos-7.repo -O /etc/yum.repos.d/CentOS-Base.repo
2935
else
30-
# 国内 aliyun 镜像
31-
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/CentOS-${version}.repo
32-
33-
# 国内 163 镜像(备选)
34-
#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS${version}-Base-163.repo
36+
echo -e "版本不支持,替换 yum repo 失败"
3537
fi
3638

3739
# 更新缓存

0 commit comments

Comments
 (0)