惜风不起、唯有努力!
一键部署jdk和maven环境脚本

一键部署jdk和maven环境脚本

#!/bin/bash

#PACKAGE_DIR=/opt
PACKAGE_DIR=$1
DEST_DIR=/usr/local

function unpack(){
    for package in `ls ${PACKAGE_DIR}|grep -E "maven|jdk"`
    do
        cd $PACKAGE_DIR
        tar -xf $package -C $DEST_DIR
    done
    ln -sf ${DEST_DIR}/$(ls ${DEST_DIR}|grep "jdk") ${DEST_DIR}/java
    ln -sf ${DEST_DIR}/$(ls ${DEST_DIR}|grep "maven") ${DEST_DIR}/maven
    ll /usr/local/|grep -E "java|maven"
}

function config_env(){
cat >> /etc/profile << EOF
export JAVA_HOME=/usr/local/java
export CLASSPATH=.:\$JAVA_HOME/jre/lib/rt.jar:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar
export MAVEN_HOME=/usr/local/maven
export PATH=\$JAVA_HOME/bin:\$MAVEN_HOME/bin:\$PATH
EOF
source /etc/profile && echo "$PATH"
}

function main(){
    unpack && config_env
}
main

发表回复

您的电子邮箱地址不会被公开。