mirror of
https://github.com/tuna/tunasync-scripts.git
synced 2025-04-20 04:12:42 +00:00
Merge pull request #54 from RobberPhex/adoptopenjdk
下载AdoptOpenJDK的installer
This commit is contained in:
commit
5a9a221bc2
57
adoptopenjdk.sh
Executable file → Normal file
57
adoptopenjdk.sh
Executable file → Normal file
@ -7,34 +7,57 @@ BASE_PATH="${TUNASYNC_WORKING_DIR}"
|
|||||||
# 参数为版本,比如8,11等
|
# 参数为版本,比如8,11等
|
||||||
function downloadRelease() {
|
function downloadRelease() {
|
||||||
curl -s "https://api.adoptopenjdk.net/v2/latestAssets/releases/openjdk$1" | \
|
curl -s "https://api.adoptopenjdk.net/v2/latestAssets/releases/openjdk$1" | \
|
||||||
jq -r '.[]| [.version,.binary_type,.architecture,.os,.binary_name,.binary_link,.checksum_link]| @tsv' | \
|
jq -r '.[]| [.version,.binary_type,.architecture,.os,.binary_name,.binary_link,.checksum_link,.installer_name,.installer_link,.installer_checksum_link]| @tsv' | \
|
||||||
while IFS=$'\t' read -r version binary_type architecture os binary_name binary_link checksum_link; do
|
while IFS=$'\t' read -r version binary_type architecture os binary_name binary_link checksum_link installer_name installer_link installer_checksum_link; do
|
||||||
mkdir -p "$BASE_PATH/$version/$binary_type/$architecture/$os/" || true
|
mkdir -p "$BASE_PATH/$version/$binary_type/$architecture/$os/" || true
|
||||||
dest_filename="$BASE_PATH/$version/$binary_type/$architecture/$os/$binary_name"
|
dest_filename="$BASE_PATH/$version/$binary_type/$architecture/$os/$binary_name"
|
||||||
declare downloaded=false
|
declare downloaded=false
|
||||||
if [[ -f $dest_filename ]]; then
|
if [[ -f $dest_filename ]]; then
|
||||||
echo "Skiping $binary_name"
|
echo "Skiping $binary_name"
|
||||||
downloaded=true
|
downloaded=true
|
||||||
fi
|
fi
|
||||||
while [[ $downloaded != true ]]; do
|
while [[ $downloaded != true ]]; do
|
||||||
echo "Downloading ${dest_filename}"
|
echo "Downloading ${dest_filename}"
|
||||||
rm "${dest_filename}" "${dest_filename}.sha256.txt" 2>/dev/null || true
|
link="$binary_link"
|
||||||
rm "${dest_filename}.tmp" "${dest_filename}.sha256.txt.tmp" 2>/dev/null || true
|
download_and_check && {
|
||||||
curl -s -S --fail -L ${CURL_OPTIONS:-} \
|
downloaded=true
|
||||||
-o "${dest_filename}.tmp" \
|
|
||||||
"$binary_link"
|
|
||||||
curl -s -S --fail -L ${CURL_OPTIONS:-} \
|
|
||||||
-o "${dest_filename}.sha256.txt.tmp" \
|
|
||||||
"$checksum_link"
|
|
||||||
sha256sum_check && {
|
|
||||||
mv "${dest_filename}.sha256.txt.tmp" "${dest_filename}.sha256.txt"
|
|
||||||
mv "${dest_filename}.tmp" "${dest_filename}"
|
|
||||||
downloaded=true
|
|
||||||
}
|
}
|
||||||
done
|
done
|
||||||
|
if [[ -z $installer_name ]]; then
|
||||||
|
dest_filename="$BASE_PATH/$version/$binary_type/$architecture/$os/$installer_name"
|
||||||
|
downloaded=false
|
||||||
|
if [[ -f $dest_filename ]]; then
|
||||||
|
echo "Skiping $installer_name"
|
||||||
|
downloaded=true
|
||||||
|
fi
|
||||||
|
while [[ $downloaded != true ]]; do
|
||||||
|
echo "Downloading ${dest_filename}"
|
||||||
|
link="$installer_link"
|
||||||
|
checksum_link="$installer_checksum_link"
|
||||||
|
download_and_check && {
|
||||||
|
downloaded=true
|
||||||
|
}
|
||||||
|
done
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function download_and_check() {
|
||||||
|
rm "${dest_filename}" "${dest_filename}.sha256.txt" 2>/dev/null || true
|
||||||
|
rm "${dest_filename}.tmp" "${dest_filename}.sha256.txt.tmp" 2>/dev/null || true
|
||||||
|
curl -s -S --fail -L ${CURL_OPTIONS:-} \
|
||||||
|
-o "${dest_filename}.tmp" \
|
||||||
|
"$link"
|
||||||
|
curl -s -S --fail -L ${CURL_OPTIONS:-} \
|
||||||
|
-o "${dest_filename}.sha256.txt.tmp" \
|
||||||
|
"$checksum_link"
|
||||||
|
sha256sum_check && {
|
||||||
|
mv "${dest_filename}.sha256.txt.tmp" "${dest_filename}.sha256.txt"
|
||||||
|
mv "${dest_filename}.tmp" "${dest_filename}"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function sha256sum_check() {
|
function sha256sum_check() {
|
||||||
expected=$(cat "${dest_filename}.sha256.txt.tmp" | awk '{print $1}')
|
expected=$(cat "${dest_filename}.sha256.txt.tmp" | awk '{print $1}')
|
||||||
actual=$(sha256sum "${dest_filename}.tmp" | awk '{print $1}')
|
actual=$(sha256sum "${dest_filename}.tmp" | awk '{print $1}')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user