Fetch the repository succeeded.
#!/bin/sh
#
#********************************************************************
#Author: ocean
#QQ: 910853073
#Date: 2019-12-20
#FileName: ocean.sh
#URL: http://www.ocean101.com
#Description: The test script
#Copyright (C): 2023 All rights reserved
#********************************************************************
#ply="6666"
#a="1"
#b="1"
#echo "sss $ply"
#if [ "$a" == "$b" ]; then
# echo "值相同"
#else
# echo "值不同"
#fi
# ANSI颜色序列
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m' # 恢复默认颜色
# 判断是否为CentOS
systemVersion=""
systemType=""
if [[ -f /etc/redhat-release ]]; then
centos_version=$(grep -oE '[0-9]+\.[0-9]+' /etc/redhat-release)
echo "当前系统是 CentOS $centos_version"
systemVersion="CentOS $centos_version"
systemType="1"
fi
# 判断是否为Debian
if [[ -f /etc/debian_version ]]; then
debian_version=$(cat /etc/debian_version)
#echo "当前系统是 Debian $debian_version"
systemVersion="Debian $debian_version"
systemType="2"
fi
# 判断是否为国产系统(如麒麟、深度等)
if [[ -f /etc/os-release ]]; then
source /etc/os-release
if [[ "$NAME" == *"Kylin"* ]]; then
#echo "当前系统是国产系统 - 麒麟"
systemVersion="国产系统 - 麒麟"
systemType="4"
elif [[ "$NAME" == *"Deepin"* ]]; then
#echo "当前系统是国产系统 - 深度"
systemVersion="国产系统 - 深度"
systemType="5"
else
echo "当前系统是 $NAME"
#systemVersion="$NAME"
#systemType="6"
fi
fi
# 判断是否为Ubuntu
if [[ -f /etc/lsb-release ]]; then
source /etc/lsb-release
if [[ "$DISTRIB_ID" == "Ubuntu" ]]; then
#echo "当前系统是 Ubuntu $DISTRIB_RELEASE"
systemVersion="Ubuntu $DISTRIB_RELEASE"
systemType="3"
fi
fi
# 其他未知系统类型
#echo "无法确定当前系统类型"
function installCentos() {
mkdir -p /usr/java
cp jdk-8u371-linux-x64.tar.gz /usr/java/
cd /usr/java
tar -xvf jdk-8u371-linux-x64.tar.gz
sh -c 'echo " " >> /etc/profile'
sh -c 'echo "export JAVA_HOME=/usr/java/jdk1.8.0_371" >> /etc/profile'
sh -c 'echo "export CLASSPATH=\$CLASSPATH:\$JAVA_HOME/lib/" >> /etc/profile'
sh -c 'echo "export PATH=\$PATH:\$JAVA_HOME/bin" >> /etc/profile'
source /etc/profile
if [[ "$javaHome" != *openjdk* ]];then
echo -e "${YELLOW}jdk安装成功${NC}"
echo -e "${YELLOW}$(java -version 2>&1)${NC}"
exit 0
else
echo -e "${YELLOW}jdk安装失败${NC}"
fi
}
echo "开始安装JDK"
rpmJava="$(rpm -qa | grep java)"
rpmJdk="$(rpm -qa | grep jdk)"
javaHome="$(java -version 2>&1)"
#echo "$rpmJava"
#echo "$rpmJdk"
#echo "$javaHome"
if [ "$rpmJava" == "" -a "$rpmJdk" == "" ] && [[ "$javaHome" != *version* ]];then
echo "没有安装JDK"
echo -e "${YELLOW}$systemType${NC}"
#echo "$javaHome"
#判断是否为centos系统
if [ "$systemType" == "1" ];then
echo "调用installCentos方法"
installCentos
else
exit 0
fi
else
echo "已安装JDK"
fi
#thisFile="$(pwd)"
#echo "$thisFile"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。