标签:|| path $path 环境变量 bash 添加 package dir apache
#!/bin/bash
# linux maven安装
package_dir=/opt/tools
install_dir=/opt
#########################
# 下载maven的tar包
[ -d ${package_dir} ] || mkdir -pv ${package_dir}
cd ${package_dir} && wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz
# 解压
tar xf ${package_dir}/apache-maven-3.5.4-bin.tar.gz -C ${install_dir}/
[ -L ${install_dir}/maven ] && rm -f ${install_dir}/maven
ln -s ${install_dir}/apache-maven-3.5.4 ${install_dir}/maven
# 添加环境变量
echo -e "export MAVEN_HOME=${install_dir}/maven\nPATH=\$PATH:\$MAVEN_HOME/bin" > /etc/profile.d/maven.sh
cat /etc/profile.d/maven.sh
#export MAVEN_HOME=/opt/maven
#PATH=$PATH:$MAVEN_HOME/bin
source /etc/profile.d/maven.sh
# 测试
echo $MAVEN_HOME
mvn -version
标签:|| path $path 环境变量 bash 添加 package dir apache
原文地址:http://blog.51cto.com/moerjinrong/2138869