jdk8|tomcat8安装脚本

jdk8|tomcat8安装脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
echo "beigin install jdk-1.7"
# sudo su #切换到root权限
mkdir /usr/local/java
cd /usr/local/java
#download jdk 1.7.67
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u67-b01/jdk-7u67-linux-x64.tar.gz
#extract jdk
tar -xvf jdk-7u67-linux-x64.tar.gz
#set environment
export JAVA_HOME="/usr/local/java/jdk1.7.0_67"
if ! grep "JAVA_HOME=/usr/local/java/jdk1.7.0_67" /etc/environment
then
echo "JAVA_HOME=/usr/local/java/jdk1.7.0_67" | sudo tee -a /etc/environment
echo "export JAVA_HOME" | sudo tee -a /etc/environment
echo "PATH=$PATH:$JAVA_HOME/bin" | sudo tee -a /etc/environment
echo "export PATH" | sudo tee -a /etc/environment
echo "CLASSPATH=.:$JAVA_HOME/lib" | sudo tee -a /etc/environment
echo "export CLASSPATH" | sudo tee -a /etc/environment
fi
#update environment
source /etc/environment
echo "jdk is installed !"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
echo "开始安装 jdk-1.8"
JDK_INSTALL_PATH="/data/soft/java"
JDK_TAR_FILE="jdk-8u51-linux-x64.tar.gz"
JDK_FILE="jdk1.8.0_51"
ENV_DIR="/data/env"
ENV_FILE="$ENV_DIR/environment"
if [ ! -d "$ENV_DIR" ];then
echo "环境文件目录不存在,创建目录[$ENV_DIR]"
mkdir -p $ENV_DIR
fi
if [ ! -d "$JDK_INSTALL_PATH" ] ; then
echo "安装目录不存在,创建安装目录[$JDK_INSTALL_PATH]"
mkdir -p $JDK_INSTALL_PATH
fi
if [ ! -f "$JDK_TAR_FILE" ] ; then
echo "JDK安装包不存在,开始下载安装包"
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u51-b16/jdk-8u51-linux-x64.tar.gz
echo "JDK安装包下载完成"
#cp ./$JDK_TAR_FILE $JDK_INSTALL_PATH
fi
cp ./$JDK_TAR_FILE $JDK_INSTALL_PATH
cd $JDK_INSTALL_PATH
if [ -d "$JDK_INSTALL_PATH/$JDK_FILE" ]; then
echo "删除已存在目录[$JDK_INSTALL_PATH/$JDK_FILE],重新解压缩"
rm -rf $JDK_INSTALL_PATH/$JDK_FILE
fi
tar -xvf $JDK_TAR_FILE
echo "解压缩安装包完成。。。"
if [ ! -f "$ENV_FILE" ]; then
echo "环境变量文件不存在,创建文件[$ENV_FILE]"
touch $ENV_FILE
fi
echo "配置环境变量开始"
if ! grep "JAVA_HOME=" /data/env/environment
then
echo "JAVA_HOME=$JDK_INSTALL_PATH/$JDK_FILE" | tee -a $ENV_FILE
echo "export JAVA_HOME" | tee -a $ENV_FILE
echo 'PATH=$PATH:$JAVA_HOME/bin' | tee -a $ENV_FILE
echo "export PATH" | tee -a $ENV_FILE
echo 'CLASSPATH=.:$JAVA_HOME/lib' | tee -a $ENV_FILE
echo "export CLASSPATH" | tee -a $ENV_FILE
fi
echo "JDK安装完成"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
echo "开始安装 tomcat-8.0"
JDK_INSTALL_PATH="/data/soft/tomcat"
JDK_TAR_FILE="apache-tomcat-8.0.24.tar.gz"
JDK_FILE="apache-tomcat-8.0.24"
if [ ! -d "$JDK_INSTALL_PATH" ] ; then
echo "安装目录不存在,创建安装目录[$JDK_INSTALL_PATH]"
mkdir -p $JDK_INSTALL_PATH
fi
if [ ! -f "$JDK_TAR_FILE" ] ; then
echo "TOMCAT安装包不存在,开始下载安装包"
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://mirrors.cnnic.cn/apache/tomcat/tomcat-8/v8.0.24/bin/apache-tomcat-8.0.24.tar.gz
echo "TOMCAT安装包下载完成"
# cp ./$JDK_TAR_FILE $JDK_INSTALL_PATH
fi
cp ./$JDK_TAR_FILE $JDK_INSTALL_PATH
cd $JDK_INSTALL_PATH
if [ -d "$JDK_INSTALL_PATH/$JDK_FILE" ]; then
echo "删除已存在目录[$JDK_INSTALL_PATH/$JDK_FILE],重新解压缩"
rm -rf $JDK_INSTALL_PATH/$JDK_FILE
fi
tar -xvf $JDK_TAR_FILE
echo "解压缩安装包完成。。。"
echo "TOMCAT安装完成"