Jpom/docs/install.sh

102 lines
3.2 KiB
Bash
Raw Normal View History

2019-08-20 00:20:38 +08:00
#!/bin/bash
2020-10-14 15:18:15 +08:00
PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:$(cd `dirname $0`; pwd)
2019-08-20 00:20:38 +08:00
export PATH
LANG=en_US.UTF-8
# 解压命令
if [[ ! -f "/usr/bin/unzip" ]];then
#rm -f /etc/yum.repos.d/epel.repo
yum install unzip -y
fi
2019-08-20 22:40:37 +08:00
TYPE="$1"
2020-10-14 15:18:15 +08:00
module="$2"
2020-11-01 14:08:39 +08:00
2020-10-14 15:18:15 +08:00
# 判断是否包含jdk
2020-11-01 16:38:48 +08:00
installJd="jdk"
2020-11-01 14:08:39 +08:00
2020-11-01 16:30:29 +08:00
if [[ $module = *$installJdk* ]]; then
2020-10-14 15:36:59 +08:00
if [[ ! -x "${JAVA_HOME}/bin/java" ]]; then
2020-11-01 16:37:32 +08:00
JAVA=`which java`
if [[ ! -x "$JAVA" ]]; then
# 判断是否存在文件
if [[ ! -f "jdk-8u251-linux-x64.tar.gz" ]]; then
wget -O jdk-8u251-linux-x64.tar.gz https://jpom-releases.oss-cn-hangzhou.aliyuncs.com/jdk-8u251-linux-x64.tar.gz
fi
mkdir /usr/java/
#
tar -zxvf jdk-8u251-linux-x64.tar.gz -C /usr/java/
#
#PATH=$PATH:/usr/java/jdk1.8.0_251/bin
#export PATH
echo '安装jdk,路径/usr/java/jdk1.8.0_251/'
# 修改环境变量
echo ''>>/etc/profile
echo 'export JAVA_HOME=/usr/java/jdk1.8.0_251'>>/etc/profile
echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar'>>/etc/profile
echo 'export PATH=$PATH:$JAVA_HOME/bin'>>/etc/profile
#export JAVA_HOME=/usr/java/jdk1.8.0_251
# 更新环境变量
source /etc/profile
# 删除jdk压缩包
rm -f jdk-8u251-linux-x64.tar.gz
else
2020-11-01 16:41:13 +08:00
echo "已经存在java环境${JAVA}/bin/java"
2020-10-14 15:36:59 +08:00
fi
2020-11-01 16:37:32 +08:00
else
2020-11-01 16:41:13 +08:00
echo "已经存在java环境${JAVA_HOME}/bin/java"
2020-10-14 15:36:59 +08:00
fi
2020-10-14 15:18:15 +08:00
fi
2020-11-01 14:08:39 +08:00
# 判断是否包含mvn
2020-11-01 16:38:48 +08:00
installMvn="mvn"
2020-11-01 14:08:39 +08:00
2020-11-01 16:30:29 +08:00
if [[ $module = *$installMvn* ]]; then
2020-11-01 14:08:39 +08:00
if [[ ! -x "${MAVEN_HOME}/bin/mvn" ]]; then
2020-11-01 16:37:32 +08:00
MVN=`which mvn`
if [[ ! -x "$MVN" ]]; then
# 判断是否存在文件
if [[ ! -f "apache-maven-3.6.3-bin.tar.gz" ]]; then
wget -O apache-maven-3.6.3-bin.tar.gz https://jpom-releases.oss-cn-hangzhou.aliyuncs.com/apache-maven-3.6.3-bin.tar.gz
fi
mkdir /usr/maven/
#
tar -zxvf apache-maven-3.6.3-bin.tar.gz -C /usr/maven/
#
echo '安装maven,路径/usr/maven/apache-maven-3.6.3/'
# 修改环境变量
echo ''>>/etc/profile
echo 'export MAVEN_HOME=/usr/maven/apache-maven-3.6.3/'>>/etc/profile
echo 'export PATH=$PATH:$MAVEN_HOME/bin'>>/etc/profile
2020-11-01 14:08:39 +08:00
2020-11-01 16:37:32 +08:00
export MAVEN_HOME=/usr/maven/apache-maven-3.6.3/
export PATH=$MAVEN_HOME/bin:$PATH
# 删除maven压缩包
rm -f apache-maven-3.6.3-bin.tar.gz
else
2020-11-01 16:41:13 +08:00
echo "已经存在maven环境${MVN}/bin/mvn"
2020-11-01 16:37:32 +08:00
fi
else
2020-11-01 16:41:13 +08:00
echo "已经存在maven环境${MAVEN_HOME}/bin/mvn"
2020-11-01 14:08:39 +08:00
fi
fi
2019-08-20 22:37:45 +08:00
# 判断
if [[ -z "${TYPE}" ]] ; then
TYPE="Server";
fi
2020-10-14 15:18:15 +08:00
# 判断是否在文件
if [[ ! -f "${TYPE}.zip" ]]; then
# 下载
wget -O ${TYPE}.zip https://1232788122276831.cn-beijing.fc.aliyuncs.com/2016-08-15/proxy/jpom/jpom-releases/?type=${TYPE}
fi
2019-08-20 00:20:38 +08:00
# 解压
2019-08-20 22:37:45 +08:00
unzip -o ${TYPE}.zip
# 删除安装包
rm -f ${TYPE}.zip
2020-11-01 14:19:05 +08:00
# 删除安装命令
rm -f install.sh
2019-09-16 09:51:11 +08:00
# 添加权限
chmod 755 ${TYPE}.sh
2019-08-20 22:37:45 +08:00
# 启动
sh ${TYPE}.sh start