#!/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