1
0

openjdk-8.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/oneinstack
  10. Install_OpenJDK8() {
  11. if [ "${Family}" == 'rhel' ]; then
  12. yum -y install java-1.8.0-openjdk-devel
  13. JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
  14. elif [ "${Family}" == 'debian' ]; then
  15. if [[ "${Debian_ver}" =~ ^10$|^11$|^12$ ]]; then
  16. #wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | apt-key add -
  17. cat ${oneinstack_dir}/src/adoptium.key | sudo apt-key add -
  18. apt-add-repository --yes https://mirrors.tuna.tsinghua.edu.cn/Adoptium/deb
  19. apt -y update
  20. apt-get --no-install-recommends -y install temurin-8-jdk
  21. JAVA_HOME=/usr/lib/jvm/temurin-8-jdk-${SYS_ARCH}
  22. elif [[ "${Debian_ver}" =~ ^9$ ]]; then
  23. apt-get --no-install-recommends -y install openjdk-8-jdk
  24. JAVA_HOME=/usr/lib/jvm/java-8-openjdk-${SYS_ARCH}
  25. fi
  26. elif [ "${Family}" == 'ubuntu' ]; then
  27. apt-get --no-install-recommends -y install openjdk-8-jdk
  28. JAVA_HOME=/usr/lib/jvm/java-8-openjdk-${SYS_ARCH}
  29. fi
  30. if [ -e "${JAVA_HOME}/bin/java" ]; then
  31. cat > /etc/profile.d/openjdk.sh << EOF
  32. export JAVA_HOME=${JAVA_HOME}
  33. export CLASSPATH=\$JAVA_HOME/lib/tools.jar:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib
  34. EOF
  35. . /etc/profile.d/openjdk.sh
  36. echo "${CSUCCESS}OpenJDK8 installed successfully! ${CEND}"
  37. else
  38. echo "${CFAILURE}OpenJDK8 install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
  39. kill -9 $$; exit 1;
  40. fi
  41. }