This commit is contained in:
66
java/update.sh
Normal file
66
java/update.sh
Normal file
@@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
|
||||
|
||||
source <(curl -f -s --connect-timeout 10 --retry 3 https://dl.acepanel.net/public.sh)
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Download public.sh failed, please check the network or try again later."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
slug=${1}
|
||||
version=${2}
|
||||
java_path="${setup_path}/server/java/${slug}"
|
||||
|
||||
# 预检查
|
||||
if [ ! -f "${java_path}/bin/java" ]; then
|
||||
error "Java ${slug} is not installed"
|
||||
fi
|
||||
|
||||
# 架构映射
|
||||
case ${ARCH} in
|
||||
x86_64)
|
||||
JAVA_ARCH="x64"
|
||||
;;
|
||||
aarch64)
|
||||
JAVA_ARCH="aarch64"
|
||||
;;
|
||||
esac
|
||||
|
||||
# 下载Amazon Corretto JDK
|
||||
JAVA_TARBALL="amazon-corretto-${version}-linux-${JAVA_ARCH}.tar.gz"
|
||||
JAVA_URL="https://corretto.aws/downloads/resources/${version}/${JAVA_TARBALL}"
|
||||
echo "Downloading Corretto ${version} from AWS..."
|
||||
|
||||
cd ${java_path}
|
||||
aria2c -x8 \
|
||||
-U "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36" \
|
||||
-o ${JAVA_TARBALL} \
|
||||
${JAVA_URL}
|
||||
if [ $? -ne 0 ]; then
|
||||
rm -f ${JAVA_TARBALL}
|
||||
error "Failed to download Java ${version}"
|
||||
fi
|
||||
|
||||
# 删除旧文件
|
||||
find ${java_path} -mindepth 1 ! -name "${JAVA_TARBALL}" -exec rm -rf {} + 2>/dev/null
|
||||
|
||||
# 解压
|
||||
tar -zxf ${JAVA_TARBALL}
|
||||
if [ $? -ne 0 ]; then
|
||||
rm -f ${JAVA_TARBALL}
|
||||
error "Failed to extract Java ${version}"
|
||||
fi
|
||||
|
||||
# Corretto解压后移动到当前目录
|
||||
mv amazon-corretto-*/* .
|
||||
rm -rf amazon-corretto-*/
|
||||
rm -f ${JAVA_TARBALL}
|
||||
|
||||
# 验证安装
|
||||
if [ ! -f "${java_path}/bin/java" ]; then
|
||||
error "Java ${version} upgrade failed"
|
||||
fi
|
||||
|
||||
echo -e $HR
|
||||
echo "Upgrade successful"
|
||||
echo -e $HR
|
||||
Reference in New Issue
Block a user