更新脚本

This commit is contained in:
Zhang Peng 2019-05-07 11:19:36 +08:00
parent 53614e4e55
commit f882607677
4 changed files with 21 additions and 23 deletions

View File

@ -1,21 +1,33 @@
#!/usr/bin/env bash #!/usr/bin/env bash
cat << EOF
################################################################################### ###################################################################################
# 安装 Maven 脚本 # 安装 Maven3 脚本
# 适用于所有 linux 发行版本。 # 适用于所有 linux 发行版本。
# Maven 会被安装到 /opt/maven 路径。 # Maven 会被安装到 /opt/maven 路径。
# 注意Maven 要求必须先安装 JDK # 注意Maven 要求必须先安装 JDK
# Author: Zhang Peng # Author: Zhang Peng
################################################################################### ###################################################################################
EOF
version=3.6.0
if [[ -n $1 ]]; then
version=$1
fi
root=/opt/maven
if [[ -n $2 ]]; then
root=$2
fi
echo -e "\n>>>>>>>>> download maven"
mkdir -p ${root}
cd ${root}
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" -O ${root}/apache-maven-${version}-bin.tar.gz http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/${version}/binaries/apache-maven-${version}-bin.tar.gz
echo -e "\n>>>>>>>>> install maven" echo -e "\n>>>>>>>>> install maven"
tar -zxvf apache-maven-${version}-bin.tar.gz -C ${root}
mkdir -p /opt/maven
cd /opt/maven
version=3.5.4
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/${version}/binaries/apache-maven-${version}-bin.tar.gz
tar -zxvf apache-maven-${version}-bin.tar.gz
# 设置环境变量 # 设置环境变量
cat >> /etc/profile << EOF cat >> /etc/profile << EOF
@ -27,4 +39,4 @@ source /etc/profile
# 备份并替换 settings.xml使用 aliyun 镜像加速 maven # 备份并替换 settings.xml使用 aliyun 镜像加速 maven
echo -e "\n>>>>>>>>> replace /opt/maven/apache-maven-${version}/conf/settings.xml" echo -e "\n>>>>>>>>> replace /opt/maven/apache-maven-${version}/conf/settings.xml"
cp /opt/maven/apache-maven-${version}/conf/settings.xml /opt/maven/apache-maven-${version}/conf/settings.xml.bak cp /opt/maven/apache-maven-${version}/conf/settings.xml /opt/maven/apache-maven-${version}/conf/settings.xml.bak
wget -N https://raw.githubusercontent.com/dunwu/os-tutorial/master/codes/linux/ops/soft/maven/settings-aliyun.xml -O /opt/maven/apache-maven-${version}/conf/settings.xml wget -N https://raw.githubusercontent.com/dunwu/os-tutorial/master/codes/linux/ops/soft/config/settings-aliyun.xml -O /opt/maven/apache-maven-${version}/conf/settings.xml

View File

@ -1,14 +0,0 @@
# 脚本使用说明
## 安装 Maven
使用方法:执行以下任意命令即可执行脚本。
```sh
curl -o- https://raw.githubusercontent.com/dunwu/os-tutorial/master/codes/linux/ops/soft/maven/install-maven3.sh | bash
wget -qO- https://raw.githubusercontent.com/dunwu/os-tutorial/master/codes/linux/ops/soft/maven/install-maven3.sh | bash
```
脚本会下载解压 maven 到 `/opt/maven` 路径下。
备份并替换 settings.xml本目录中的 settings-aliyun.xml使用 aliyun 镜像加速 maven