Jpom/docs/install.sh

153 lines
4.7 KiB
Bash
Raw Normal View History

2019-08-20 00:20:38 +08:00
#!/bin/bash
2021-12-14 21:35:35 +08:00
# The MIT License (MIT)
#
# Copyright (c) 2019 Code Technology Studio
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2022-01-13 08:22:51 +08:00
# https://github.com/AdoptOpenJDK/openjdk-docker/blob/master/8/jdk/centos/Dockerfile.hotspot.releases.full
# https://github.com/carlossg/docker-maven/blob/master/openjdk-8/Dockerfile
2022-01-19 16:32:06 +08:00
JPOM_TYPE="$1"
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
2022-01-13 12:43:55 +08:00
# loading env
if [ -f /etc/profile ]; then
. /etc/profile
fi
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
if [ -f ~/.bash_profile ]; then
. ~/.bash_profile
fi
2022-01-13 08:22:51 +08:00
# 安装 jdk
2022-01-13 12:39:46 +08:00
function installJdkFn() {
2022-01-13 08:22:51 +08:00
if [[ ! -x "${JAVA_HOME}/bin/java" ]]; then
2020-11-01 16:37:32 +08:00
JAVA=`which java`
if [[ ! -x "$JAVA" ]]; then
2022-01-13 12:39:46 +08:00
# 判断是否存在文件
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 -zxf 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
2020-11-01 16:37:32 +08:00
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
2022-01-13 08:22:51 +08:00
}
2020-11-01 14:08:39 +08:00
2022-01-13 08:22:51 +08:00
# 安装 mvn
2022-01-13 12:39:46 +08:00
function installMvnFn() {
2022-01-13 08:22:51 +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
2022-01-13 08:22:51 +08:00
wget -O apache-maven-3.6.3-bin.tar.gz https://mirrors.aliyun.com/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
2020-11-01 16:37:32 +08:00
fi
mkdir /usr/maven/
#
2021-07-29 08:27:45 +08:00
tar -zxf apache-maven-3.6.3-bin.tar.gz -C /usr/maven/
2020-11-01 16:37:32 +08:00
#
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
2022-01-13 08:22:51 +08:00
# 更新环境变量
source /etc/profile
2020-11-01 16:37:32 +08:00
# 删除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
2022-01-13 08:22:51 +08:00
}
2022-01-13 12:39:46 +08:00
# 解压命令
if [[ ! -f "/usr/bin/unzip" ]];then
#rm -f /etc/yum.repos.d/epel.repo
yum install unzip -y
fi
2022-01-19 16:32:06 +08:00
2022-01-13 12:39:46 +08:00
module="$2"
# 判断是否包含jdk
temp_result=$(echo $module | grep "jdk")
if [[ "$temp_result" != "" ]]; then
echo "开始检查 jdk"
installJdkFn
fi
# 判断是否包含mvn
temp_result=$(echo $module | grep "mvn")
if [[ "$temp_result" != "" ]]; then
echo "开始检查 mvn"
installMvnFn
fi
2022-01-13 12:41:22 +08:00
2022-01-13 12:39:46 +08:00
# 判断
2022-01-19 16:24:20 +08:00
if [[ -z "${JPOM_TYPE}" ]] ; then
2022-01-13 12:39:46 +08:00
TYPE="Server";
fi
2022-01-19 16:24:20 +08:00
echo "开始安装:${JPOM_TYPE}"
2022-01-13 12:39:46 +08:00
# 判断是否在文件
2022-01-19 16:24:20 +08:00
if [[ ! -f "${JPOM_TYPE}.zip" ]]; then
2022-01-13 12:39:46 +08:00
# 下载
2022-01-19 16:24:20 +08:00
wget -O ${JPOM_TYPE}.zip https://1232788122276831.cn-beijing.fc.aliyuncs.com/2016-08-15/proxy/jpom/jpom-releases/?type=${JPOM_TYPE}
2022-01-13 12:39:46 +08:00
fi
# 解压
2022-01-19 16:24:20 +08:00
unzip -o ${JPOM_TYPE}.zip
2022-01-13 12:39:46 +08:00
# 删除安装包
2022-01-19 16:24:20 +08:00
rm -f ${JPOM_TYPE}.zip
2022-01-13 12:39:46 +08:00
# 删除安装命令
rm -f install.sh
# 添加权限
2022-01-19 16:24:20 +08:00
chmod 755 ${JPOM_TYPE}.sh
2022-01-13 12:39:46 +08:00
# 启动
2022-01-19 16:24:20 +08:00
bash ${JPOM_TYPE}.sh start $@