linux-tutorial/codes/linux/ops/soft/maven-install.sh

44 lines
1.4 KiB
Bash
Raw Normal View History

2018-02-01 16:34:02 +08:00
#!/usr/bin/env bash
2019-05-07 11:19:36 +08:00
cat << EOF
2018-02-23 17:33:12 +08:00
###################################################################################
2019-05-07 11:19:36 +08:00
# 安装 Maven3 脚本
2018-02-23 17:33:12 +08:00
# 适用于所有 linux 发行版本。
2018-09-29 10:16:24 +08:00
# Maven 会被安装到 /opt/maven 路径。
2018-02-23 17:33:12 +08:00
# 注意Maven 要求必须先安装 JDK
# Author: Zhang Peng
###################################################################################
2019-05-07 11:19:36 +08:00
EOF
2018-02-23 17:33:12 +08:00
2019-05-07 11:19:36 +08:00
version=3.6.0
if [[ -n $1 ]]; then
version=$1
fi
root=/opt/maven
if [[ -n $2 ]]; then
root=$2
fi
2018-02-01 16:34:02 +08:00
2019-05-07 11:19:36 +08:00
echo -e "\n>>>>>>>>> download maven"
mkdir -p ${root}
2019-05-07 11:39:42 +08:00
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
2019-05-07 11:19:36 +08:00
echo -e "\n>>>>>>>>> install maven"
2019-05-07 11:39:42 +08:00
tar -zxvf ${root}/apache-maven-${version}-bin.tar.gz -C ${root}
2018-02-02 17:53:50 +08:00
2019-05-07 11:39:42 +08:00
path=${root}/apache-maven-${version}
2019-02-22 17:09:40 +08:00
# 设置环境变量
2018-02-02 17:53:50 +08:00
cat >> /etc/profile << EOF
2019-05-07 11:39:42 +08:00
export MAVEN_HOME=${path}
2018-02-23 17:33:12 +08:00
export PATH=\$MAVEN_HOME/bin:\$PATH
2018-02-02 17:53:50 +08:00
EOF
source /etc/profile
2019-02-22 17:09:40 +08:00
# 备份并替换 settings.xml使用 aliyun 镜像加速 maven
2019-05-07 11:39:42 +08:00
echo -e "\n>>>>>>>>> replace ${path}/conf/settings.xml"
cp ${path}/conf/settings.xml ${path}/conf/settings.xml.bak
wget -N https://raw.githubusercontent.com/dunwu/os-tutorial/master/codes/linux/ops/soft/config/settings-aliyun.xml -O ${path}/conf/settings.xml
2019-05-07 12:07:59 +08:00
mvn -v