mvn 自动部署脚本

阅读更多
#!/bin/bash
if [ -z "${MAVEN_HOME}" ]; then
        #得到时间
        TIME_FLAG=`date +%Y%m%d_%H%M%S`
        #备份配置文件
        cp /etc/profile /etc/profile.bak_$TIME_FLAG
        echo "Begin to install maven,Please waiting..."
        #解压maven
    wget http://mirrors.noc.im/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
        tar -xzvf apache-maven-3.3.9-bin.tar.gz
        #拷贝maven到安装目录
        cp -rf apache-maven-3.3.9-bin.tar.gz /usr/local/
        echo "######################################"
        echo "Begin to config environment variables,please waiting..."
        echo "######################################"
        #修改maven的环境变量,直接写入配置文件
        echo "MAVEN_HOME=/usr/local/apache-maven-3.0.4" >>/etc/profile
        echo "PATH=\$PATH:\$MAVEN_HOME/bin" >>/etc/profile
        #运行后直接生效
        source /etc/profile
        echo "环境变量设置成功"
else
        echo "本机已安装maven无需再次安装"
fi
 

你可能感兴趣的:(mvn 自动部署脚本)