How to build a localized sdkman mirror service

How to build a localized sdkman mirror service

  • 概述
  • 想法

概述

从官方给出的安装说明,我们可以知道,官方给出的安装脚本是基于脚本https://get.sdkman.io/进行安装的,下面是该脚本的全部内容。

#!/bin/bash
#
#   Copyright 2017 Marco Vermeulen
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
## install:- channel: stable; cliVersion: 5.18.2; cliNativeVersion: 0.4.6; api: https://api.sdkman.io/2set -etrack_last_command() {last_command=$current_commandcurrent_command=$BASH_COMMAND
}
trap track_last_command DEBUGecho_failed_command() {local exit_code="$?"if [[ "$exit_code" != "0" ]]; thenecho "'$last_command': command failed with exit code $exit_code."fi
}
trap echo_failed_command EXIT# Global variables
export SDKMAN_SERVICE="https://api.sdkman.io/2"
export SDKMAN_VERSION="5.18.2"
export SDKMAN_NATIVE_VERSION="0.4.6"if [ -z "$SDKMAN_DIR" ]; thenSDKMAN_DIR="$HOME/.sdkman"SDKMAN_DIR_RAW='$HOME/.sdkman'
elseSDKMAN_DIR_RAW="$SDKMAN_DIR"
fi
export SDKMAN_DIR# Local variables
sdkman_src_folder="${SDKMAN_DIR}/src"
sdkman_libexec_folder="${SDKMAN_DIR}/libexec"
sdkman_tmp_folder="${SDKMAN_DIR}/tmp"
sdkman_ext_folder="${SDKMAN_DIR}/ext"
sdkman_etc_folder="${SDKMAN_DIR}/etc"
sdkman_var_folder="${SDKMAN_DIR}/var"
sdkman_candidates_folder="${SDKMAN_DIR}/candidates"
sdkman_config_file="${sdkman_etc_folder}/config"
sdkman_platform_file="${sdkman_var_folder}/platform"
sdkman_bash_profile="${HOME}/.bash_profile"
sdkman_profile="${HOME}/.profile"
sdkman_bashrc="${HOME}/.bashrc"
sdkman_zshrc="${ZDOTDIR:-${HOME}}/.zshrc"sdkman_init_snippet=$( cat << EOF
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$SDKMAN_DIR_RAW"
[[ -s "${SDKMAN_DIR_RAW}/bin/sdkman-init.sh" ]] && source "${SDKMAN_DIR_RAW}/bin/sdkman-init.sh"
EOF
)# OS specific support (must be 'true' or 'false').
cygwin=false;
darwin=false;
solaris=false;
freebsd=false;
case "$(uname)" inCYGWIN*)cygwin=true;;Darwin*)darwin=true;;SunOS*)solaris=true;;FreeBSD*)freebsd=true
esacecho ''
echo '                                -+syyyyyyys:'
echo '                            `/yho:`       -yd.'
echo '                         `/yh/`             +m.'
echo '                       .oho.                 hy                          .`'
echo '                     .sh/`                   :N`                `-/o`  `+dyyo:.'
echo '                   .yh:`                     `M-          `-/osysoym  :hs` `-+sys:      hhyssssssssy+'
echo '                 .sh:`                       `N:          ms/-``  yy.yh-      -hy.    `.N-````````+N.'
echo '               `od/`                         `N-       -/oM-      ddd+`     `sd:     hNNm        -N:'
echo '              :do`                           .M.       dMMM-     `ms.      /d+`     `NMMs       `do'
echo '            .yy-                             :N`    ```mMMM.      -      -hy.       /MMM:       yh'
echo '          `+d+`           `:/oo/`       `-/osyh/ossssssdNMM`           .sh:         yMMN`      /m.'
echo '         -dh-           :ymNMMMMy  `-/shmNm-`:N/-.``   `.sN            /N-         `NMMy      .m/'
echo '       `oNs`          -hysosmMMMMydmNmds+-.:ohm           :             sd`        :MMM/      yy'
echo '      .hN+           /d:    -MMMmhs/-.`   .MMMh   .ss+-                 `yy`       sMMN`     :N.'
echo '     :mN/           `N/     `o/-`         :MMMo   +MMMN-         .`      `ds       mMMh      do'
echo '    /NN/            `N+....--:/+oooosooo+:sMMM:   hMMMM:        `my       .m+     -MMM+     :N.'
echo '   /NMo              -+ooooo+/:-....`...:+hNMN.  `NMMMd`        .MM/       -m:    oMMN.     hs'
echo '  -NMd`                                    :mm   -MMMm- .s/     -MMm.       /m-   mMMd     -N.'
echo ' `mMM/                                      .-   /MMh. -dMo     -MMMy        od. .MMMs..---yh'
echo ' +MMM.                                           sNo`.sNMM+     :MMMM/        sh`+MMMNmNm+++-'
echo ' mMMM-                                           /--ohmMMM+     :MMMMm.       `hyymmmdddo'
echo ' MMMMh.                  `````-+yy/`yMMM/     :MMMMMy       -sm:.``..-:-.`'
echo ' dMMMMmo-.``````..-:/osyhddddho.           `+shdh+.   hMMM:     :MmMMMM/   ./yy/` `:sys+/+sh/'
echo ' .dMMMMMMmdddddmmNMMMNNNNNMMMMMs           sNdo-      dMMM-  `-/yd/MMMMm-:sy+.   :hs-      /N`'
echo '  `/ymNNNNNNNmmdys+/::----/dMMm:          +m-         mMMM+ohmo/.` sMMMMdo-    .om:       `sh'
echo '     `.-----+/.`       `.-+hh/`         `od.          NMMNmds/     `mmy:`     +mMy      `:yy.'
echo '           /moyso+//+ossso:.           .yy`          `dy+:`         ..       :MMMN+---/oys:'
echo '         /+m:  `.-:::-`               /d+                                    +MMMMMMMNh:`'
echo '        +MN/                        -yh.                                     `+hddhy+.'
echo '       /MM+                       .sh:'
echo '      :NMo                      -sh/'
echo '     -NMs                    `/yy:'
echo '    .NMy                  `:sh+.'
echo '   `mMm`               ./yds-'
echo '  `dMMMmyo:-.````.-:oymNy:`'
echo '  +NMMMMMMMMMMMMMMMMms:`'
echo '    -+shmNMMMNmdy+:`'
echo ''
echo ''
echo '                                                                 Now attempting installation...'
echo ''
echo ''# Sanity checksecho "Looking for a previous installation of SDKMAN..."
if [ -d "$SDKMAN_DIR" ]; thenecho "SDKMAN found."echo ""echo "======================================================================================================"echo " You already have SDKMAN installed."echo " SDKMAN was found at:"echo ""echo "    ${SDKMAN_DIR}"echo ""echo " Please consider running the following if you need to upgrade."echo ""echo "    $ sdk selfupdate force"echo ""echo "======================================================================================================"echo ""exit 0
fiecho "Looking for unzip..."
if ! command -v unzip > /dev/null; thenecho "Not found."echo "======================================================================================================"echo " Please install unzip on your system using your favourite package manager."echo ""echo " Restart after installing unzip."echo "======================================================================================================"echo ""exit 1
fiecho "Looking for zip..."
if ! command -v zip > /dev/null; thenecho "Not found."echo "======================================================================================================"echo " Please install zip on your system using your favourite package manager."echo ""echo " Restart after installing zip."echo "======================================================================================================"echo ""exit 1
fiecho "Looking for curl..."
if ! command -v curl > /dev/null; thenecho "Not found."echo ""echo "======================================================================================================"echo " Please install curl on your system using your favourite package manager."echo ""echo " Restart after installing curl."echo "======================================================================================================"echo ""exit 1
fiif [[ "$solaris" == true ]]; thenecho "Looking for gsed..."if [ -z $(which gsed) ]; thenecho "Not found."echo ""echo "======================================================================================================"echo " Please install gsed on your solaris system."echo ""echo " SDKMAN uses gsed extensively."echo ""echo " Restart after installing gsed."echo "======================================================================================================"echo ""exit 1fi
elseecho "Looking for sed..."if [ -z $(command -v sed) ]; thenecho "Not found."echo ""echo "======================================================================================================"echo " Please install sed on your system using your favourite package manager."echo ""echo " Restart after installing sed."echo "======================================================================================================"echo ""exit 1fi
fiecho "Installing SDKMAN scripts..."# Create directory structureecho "Create distribution directories..."
mkdir -p "$sdkman_tmp_folder"
mkdir -p "$sdkman_ext_folder"
mkdir -p "$sdkman_etc_folder"
mkdir -p "$sdkman_var_folder"
mkdir -p "$sdkman_candidates_folder"echo "Getting available candidates..."
SDKMAN_CANDIDATES_CSV=$(curl -s "${SDKMAN_SERVICE}/candidates/all")
echo "$SDKMAN_CANDIDATES_CSV" > "${SDKMAN_DIR}/var/candidates"echo "Prime platform file..."
# infer platform
function infer_platform() {local kernellocal machinekernel="$(uname -s)"machine="$(uname -m)"case $kernel inLinux)case $machine ini686)echo "linuxx32";;x86_64)echo "linuxx64";;armv6l)echo "linuxarm32hf";;armv7l)echo "linuxarm32hf";;armv8l)echo "linuxarm32hf";;aarch64)echo "linuxarm64";;*)echo "exotic";;esac;;Darwin)case $machine inx86_64)echo "darwinx64";;arm64)echo "darwinarm64";;*)echo "darwinx64";;esac;;MSYS*|MINGW*)case $machine inx86_64)echo "windowsx64";;*)echo "exotic";;esac;;*)echo "exotic"esac
}export SDKMAN_PLATFORM="$(infer_platform)"echo "$SDKMAN_PLATFORM" > "$sdkman_platform_file"echo "Prime the config file..."
touch "$sdkman_config_file"
echo "sdkman_auto_answer=false" >> "$sdkman_config_file"
if [ -z "$ZSH_VERSION" -a -z "$BASH_VERSION" ]; thenecho "sdkman_auto_complete=false" >> "$sdkman_config_file"
elseecho "sdkman_auto_complete=true" >> "$sdkman_config_file"
fi
echo "sdkman_auto_env=false" >> "$sdkman_config_file"
echo "sdkman_beta_channel=false" >> "$sdkman_config_file"
echo "sdkman_checksum_enable=true" >> "$sdkman_config_file"
echo "sdkman_colour_enable=true" >> "$sdkman_config_file"
echo "sdkman_curl_connect_timeout=7" >> "$sdkman_config_file"
echo "sdkman_curl_max_time=10" >> "$sdkman_config_file"
echo "sdkman_debug_mode=false" >> "$sdkman_config_file"
echo "sdkman_insecure_ssl=false" >> "$sdkman_config_file"
echo "sdkman_selfupdate_feature=true" >> "$sdkman_config_file"# script cli distribution
echo "Installing script cli archive..."
# fetch distribution
sdkman_zip_file="${sdkman_tmp_folder}/sdkman-${SDKMAN_VERSION}.zip"
echo "* Downloading..."
curl --fail --location --progress-bar "${SDKMAN_SERVICE}/broker/download/sdkman/install/${SDKMAN_VERSION}/${SDKMAN_PLATFORM}" > "$sdkman_zip_file"# check integrity
echo "* Checking archive integrity..."
ARCHIVE_OK=$(unzip -qt "$sdkman_zip_file" | grep 'No errors detected in compressed data')
if [[ -z "$ARCHIVE_OK" ]]; thenecho "Downloaded zip archive corrupt. Are you connected to the internet?"echo ""echo "If problems persist, please ask for help on our Slack:"echo "* easy sign up: https://slack.sdkman.io/"echo "* report on channel: https://sdkman.slack.com/app_redirect?channel=user-issues"exit
fi# extract archive
echo "* Extracting archive..."
if [[ "$cygwin" == 'true' ]]; thensdkman_tmp_folder=$(cygpath -w "$sdkman_tmp_folder")sdkman_zip_file=$(cygpath -w "$sdkman_zip_file")
fi
unzip -qo "$sdkman_zip_file" -d "$sdkman_tmp_folder"# copy in place
echo "* Copying archive contents..."
rm -f "$sdkman_src_folder"/*
cp -rf "${sdkman_tmp_folder}"/sdkman-*/* "$SDKMAN_DIR"# clean up
echo "* Cleaning up..."
rm -rf "$sdkman_tmp_folder"/sdkman-*
rm -rf "$sdkman_zip_file"echo ""# native cli distribution
if [[ "$SDKMAN_PLATFORM" != "exotic" ]]; then
echo "Installing script cli archive..."
# fetch distribution
sdkman_zip_file="${sdkman_tmp_folder}/sdkman-native-${SDKMAN_NATIVE_VERSION}.zip"
echo "* Downloading..."
curl --fail --location --progress-bar "${SDKMAN_SERVICE}/broker/download/native/install/${SDKMAN_NATIVE_VERSION}/${SDKMAN_PLATFORM}" > "$sdkman_zip_file"# check integrity
echo "* Checking archive integrity..."
ARCHIVE_OK=$(unzip -qt "$sdkman_zip_file" | grep 'No errors detected in compressed data')
if [[ -z "$ARCHIVE_OK" ]]; thenecho "Downloaded zip archive corrupt. Are you connected to the internet?"echo ""echo "If problems persist, please ask for help on our Slack:"echo "* easy sign up: https://slack.sdkman.io/"echo "* report on channel: https://sdkman.slack.com/app_redirect?channel=user-issues"exit
fi# extract archive
echo "* Extracting archive..."
if [[ "$cygwin" == 'true' ]]; thensdkman_tmp_folder=$(cygpath -w "$sdkman_tmp_folder")sdkman_zip_file=$(cygpath -w "$sdkman_zip_file")
fi
unzip -qo "$sdkman_zip_file" -d "$sdkman_tmp_folder"# copy in place
echo "* Copying archive contents..."
rm -f "$sdkman_libexec_folder"/*
cp -rf "${sdkman_tmp_folder}"/sdkman-*/* "$SDKMAN_DIR"# clean up
echo "* Cleaning up..."
rm -rf "$sdkman_tmp_folder"/sdkman-*
rm -rf "$sdkman_zip_file"echo ""
fiecho "Set version to $SDKMAN_VERSION ..."
echo "$SDKMAN_VERSION" > "${SDKMAN_DIR}/var/version"echo "Set native version to $SDKMAN_NATIVE_VERSION ..."
echo "$SDKMAN_NATIVE_VERSION" > "${SDKMAN_DIR}/var/version_native"if [[ $darwin == true ]]; thentouch "$sdkman_bash_profile"echo "Attempt update of login bash profile on OSX..."if [[ -z $(grep 'sdkman-init.sh' "$sdkman_bash_profile") ]]; thenecho -e "\n$sdkman_init_snippet" >> "$sdkman_bash_profile"echo "Added sdkman init snippet to $sdkman_bash_profile"fi
elseecho "Attempt update of interactive bash profile on regular UNIX..."touch "${sdkman_bashrc}"if [[ -z $(grep 'sdkman-init.sh' "$sdkman_bashrc") ]]; thenecho -e "\n$sdkman_init_snippet" >> "$sdkman_bashrc"echo "Added sdkman init snippet to $sdkman_bashrc"fi
fiecho "Attempt update of zsh profile..."
touch "$sdkman_zshrc"
if [[ -z $(grep 'sdkman-init.sh' "$sdkman_zshrc") ]]; thenecho -e "\n$sdkman_init_snippet" >> "$sdkman_zshrc"echo "Updated existing ${sdkman_zshrc}"
fiecho -e "\n\n\nAll done!\n\n"echo "You are subscribed to the STABLE channel."echo ""
echo "Please open a new terminal, or run the following in the existing one:"
echo ""
echo "    source \"${SDKMAN_DIR}/bin/sdkman-init.sh\""
echo ""
echo "Then issue the following command:"
echo ""
echo "    sdk help"
echo ""
echo "Enjoy!!!"

在这里,我们看到,要完成脚本的安装,需要从服务器下载两个文件,生成一个文件的内容。

  • 第一个文件,即
export SDKMAN_SERVICE="https://api.sdkman.io/2"
export SDKMAN_VERSION="5.18.2"
export SDKMAN_NATIVE_VERSION="0.4.6"# ...# script cli distribution
echo "Installing script cli archive..."
# fetch distribution
sdkman_zip_file="${sdkman_tmp_folder}/sdkman-${SDKMAN_VERSION}.zip"
echo "* Downloading..."
curl --fail --location --progress-bar "${SDKMAN_SERVICE}/broker/download/sdkman/install/${SDKMAN_VERSION}/${SDKMAN_PLATFORM}" > "$sdkman_zip_file"# check integrity
echo "* Checking archive integrity..."
ARCHIVE_OK=$(unzip -qt "$sdkman_zip_file" | grep 'No errors detected in compressed data')
if [[ -z "$ARCHIVE_OK" ]]; thenecho "Downloaded zip archive corrupt. Are you connected to the internet?"echo ""echo "If problems persist, please ask for help on our Slack:"echo "* easy sign up: https://slack.sdkman.io/"echo "* report on channel: https://sdkman.slack.com/app_redirect?channel=user-issues"exit
fi# extract archive
echo "* Extracting archive..."
if [[ "$cygwin" == 'true' ]]; thensdkman_tmp_folder=$(cygpath -w "$sdkman_tmp_folder")sdkman_zip_file=$(cygpath -w "$sdkman_zip_file")
fi
unzip -qo "$sdkman_zip_file" -d "$sdkman_tmp_folder"# copy in place
echo "* Copying archive contents..."
rm -f "$sdkman_src_folder"/*
cp -rf "${sdkman_tmp_folder}"/sdkman-*/* "$SDKMAN_DIR"# clean up
echo "* Cleaning up..."
rm -rf "$sdkman_tmp_folder"/sdkman-*
rm -rf "$sdkman_zip_file"echo ""

脚本下载文件https://api.sdkman.io/2/broker/download/sdkman/install/5.18.2/linuxx64后重命名为sdkman-版本号.zip,比如sdkman-5.18.2.zip,将其解压后的内容复制放到~/.sdkman目录。

  • 第二个文件,即
export SDKMAN_SERVICE="https://api.sdkman.io/2"
export SDKMAN_VERSION="5.18.2"
export SDKMAN_NATIVE_VERSION="0.4.6"# ...# native cli distribution
if [[ "$SDKMAN_PLATFORM" != "exotic" ]]; then
echo "Installing script cli archive..."
# fetch distribution
sdkman_zip_file="${sdkman_tmp_folder}/sdkman-native-${SDKMAN_NATIVE_VERSION}.zip"
echo "* Downloading..."
curl --fail --location --progress-bar "${SDKMAN_SERVICE}/broker/download/native/install/${SDKMAN_NATIVE_VERSION}/${SDKMAN_PLATFORM}" > "$sdkman_zip_file"# check integrity
echo "* Checking archive integrity..."
ARCHIVE_OK=$(unzip -qt "$sdkman_zip_file" | grep 'No errors detected in compressed data')
if [[ -z "$ARCHIVE_OK" ]]; thenecho "Downloaded zip archive corrupt. Are you connected to the internet?"echo ""echo "If problems persist, please ask for help on our Slack:"echo "* easy sign up: https://slack.sdkman.io/"echo "* report on channel: https://sdkman.slack.com/app_redirect?channel=user-issues"exit
fi# extract archive
echo "* Extracting archive..."
if [[ "$cygwin" == 'true' ]]; thensdkman_tmp_folder=$(cygpath -w "$sdkman_tmp_folder")sdkman_zip_file=$(cygpath -w "$sdkman_zip_file")
fi
unzip -qo "$sdkman_zip_file" -d "$sdkman_tmp_folder"# copy in place
echo "* Copying archive contents..."
rm -f "$sdkman_libexec_folder"/*
cp -rf "${sdkman_tmp_folder}"/sdkman-*/* "$SDKMAN_DIR"# clean up
echo "* Cleaning up..."
rm -rf "$sdkman_tmp_folder"/sdkman-*
rm -rf "$sdkman_zip_file"echo ""
fi

脚本下载文件https://api.sdkman.io/2/broker/download/native/install/0.4.6/linuxx64重命名为sdkman-native-版本号.zip,比如sdkman-native-0.4.6.zip,将其解压后的内容复制放到~/.sdkman目录。

  • 生成一个文件内容
export SDKMAN_SERVICE="https://api.sdkman.io/2"
export SDKMAN_VERSION="5.18.2"
export SDKMAN_NATIVE_VERSION="0.4.6"
# ...
echo "Getting available candidates..."
SDKMAN_CANDIDATES_CSV=$(curl -s "${SDKMAN_SERVICE}/candidates/all")
echo "$SDKMAN_CANDIDATES_CSV" > "${SDKMAN_DIR}/var/candidates"

脚本访问服务https://api.sdkman.io/2/candidates/all,将其返回值用于生成文件~/.sdkman/var/candidates

想法

考虑到sdkman官方服务部署在海外,有时候访问不了,我们这里可以通过其他手段将这三个文件提前下载下来,基于nginx部署为本地服务,并将服务地址指向本地服务,这样后续安装的时候,就不在受到海外服务卡顿带来的影响了。

下面是我基于官方脚本重新修改后的安装脚本,内容如下

#!/bin/bash
#
#   Copyright 2017 Marco Vermeulen
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
## install:- channel: stable; cliVersion: 5.18.2; cliNativeVersion: 0.4.6; api: https://api.sdkman.io/2set -etrack_last_command() {last_command=$current_commandcurrent_command=$BASH_COMMAND
}
trap track_last_command DEBUGecho_failed_command() {local exit_code="$?"if [[ "$exit_code" != "0" ]]; thenecho "'$last_command': command failed with exit code $exit_code."fi
}
trap echo_failed_command EXIT# Global variables
export SDKMAN_SERVICE="https://api.sdkman.io/2"
export SDKMAN_VERSION="5.18.2"
export SDKMAN_NATIVE_VERSION="0.4.6"if [ -z "$SDKMAN_DIR" ]; thenSDKMAN_DIR="$HOME/.sdkman"SDKMAN_DIR_RAW='$HOME/.sdkman'
elseSDKMAN_DIR_RAW="$SDKMAN_DIR"
fi
export SDKMAN_DIR# Local variables#sdkman_download_dir=~/Download/sdkman
sdkman_download_dir=$(pwd)sdkman_src_folder="${SDKMAN_DIR}/src"
sdkman_libexec_folder="${SDKMAN_DIR}/libexec"
sdkman_tmp_folder="${SDKMAN_DIR}/tmp"
sdkman_ext_folder="${SDKMAN_DIR}/ext"
sdkman_etc_folder="${SDKMAN_DIR}/etc"
sdkman_var_folder="${SDKMAN_DIR}/var"
sdkman_candidates_folder="${SDKMAN_DIR}/candidates"
sdkman_config_file="${sdkman_etc_folder}/config"
sdkman_platform_file="${sdkman_var_folder}/platform"
sdkman_bash_profile="${HOME}/.bash_profile"
sdkman_profile="${HOME}/.profile"
sdkman_bashrc="${HOME}/.bashrc"
sdkman_zshrc="${ZDOTDIR:-${HOME}}/.zshrc"sdkman_init_snippet=$( cat << EOF
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$SDKMAN_DIR_RAW"
[[ -s "${SDKMAN_DIR_RAW}/bin/sdkman-init.sh" ]] && source "${SDKMAN_DIR_RAW}/bin/sdkman-init.sh"
EOF
)# OS specific support (must be 'true' or 'false').
cygwin=false;
darwin=false;
solaris=false;
freebsd=false;
case "$(uname)" inCYGWIN*)cygwin=true;;Darwin*)darwin=true;;SunOS*)solaris=true;;FreeBSD*)freebsd=true
esacecho ''
echo '                                -+syyyyyyys:'
echo '                            `/yho:`       -yd.'
echo '                         `/yh/`             +m.'
echo '                       .oho.                 hy                          .`'
echo '                     .sh/`                   :N`                `-/o`  `+dyyo:.'
echo '                   .yh:`                     `M-          `-/osysoym  :hs` `-+sys:      hhyssssssssy+'
echo '                 .sh:`                       `N:          ms/-``  yy.yh-      -hy.    `.N-````````+N.'
echo '               `od/`                         `N-       -/oM-      ddd+`     `sd:     hNNm        -N:'
echo '              :do`                           .M.       dMMM-     `ms.      /d+`     `NMMs       `do'
echo '            .yy-                             :N`    ```mMMM.      -      -hy.       /MMM:       yh'
echo '          `+d+`           `:/oo/`       `-/osyh/ossssssdNMM`           .sh:         yMMN`      /m.'
echo '         -dh-           :ymNMMMMy  `-/shmNm-`:N/-.``   `.sN            /N-         `NMMy      .m/'
echo '       `oNs`          -hysosmMMMMydmNmds+-.:ohm           :             sd`        :MMM/      yy'
echo '      .hN+           /d:    -MMMmhs/-.`   .MMMh   .ss+-                 `yy`       sMMN`     :N.'
echo '     :mN/           `N/     `o/-`         :MMMo   +MMMN-         .`      `ds       mMMh      do'
echo '    /NN/            `N+....--:/+oooosooo+:sMMM:   hMMMM:        `my       .m+     -MMM+     :N.'
echo '   /NMo              -+ooooo+/:-....`...:+hNMN.  `NMMMd`        .MM/       -m:    oMMN.     hs'
echo '  -NMd`                                    :mm   -MMMm- .s/     -MMm.       /m-   mMMd     -N.'
echo ' `mMM/                                      .-   /MMh. -dMo     -MMMy        od. .MMMs..---yh'
echo ' +MMM.                                           sNo`.sNMM+     :MMMM/        sh`+MMMNmNm+++-'
echo ' mMMM-                                           /--ohmMMM+     :MMMMm.       `hyymmmdddo'
echo ' MMMMh.                  `````-+yy/`yMMM/     :MMMMMy       -sm:.``..-:-.`'
echo ' dMMMMmo-.``````..-:/osyhddddho.           `+shdh+.   hMMM:     :MmMMMM/   ./yy/` `:sys+/+sh/'
echo ' .dMMMMMMmdddddmmNMMMNNNNNMMMMMs           sNdo-      dMMM-  `-/yd/MMMMm-:sy+.   :hs-      /N`'
echo '  `/ymNNNNNNNmmdys+/::----/dMMm:          +m-         mMMM+ohmo/.` sMMMMdo-    .om:       `sh'
echo '     `.-----+/.`       `.-+hh/`         `od.          NMMNmds/     `mmy:`     +mMy      `:yy.'
echo '           /moyso+//+ossso:.           .yy`          `dy+:`         ..       :MMMN+---/oys:'
echo '         /+m:  `.-:::-`               /d+                                    +MMMMMMMNh:`'
echo '        +MN/                        -yh.                                     `+hddhy+.'
echo '       /MM+                       .sh:'
echo '      :NMo                      -sh/'
echo '     -NMs                    `/yy:'
echo '    .NMy                  `:sh+.'
echo '   `mMm`               ./yds-'
echo '  `dMMMmyo:-.````.-:oymNy:`'
echo '  +NMMMMMMMMMMMMMMMMms:`'
echo '    -+shmNMMMNmdy+:`'
echo ''
echo ''
echo '                                                                 Now attempting installation...'
echo ''
echo ''# Sanity checks#echo "Looking for a previous installation of SDKMAN..."
#if [ -d "$SDKMAN_DIR" ]; then
#	echo "SDKMAN found."
#	echo ""
#	echo "======================================================================================================"
#	echo " You already have SDKMAN installed."
#	echo " SDKMAN was found at:"
#	echo ""
#	echo "    ${SDKMAN_DIR}"
#	echo ""
#	echo " Please consider running the following if you need to upgrade."
#	echo ""
#	echo "    $ sdk selfupdate force"
#	echo ""
#	echo "======================================================================================================"
#	echo ""
#	exit 0
#fiecho "Looking for unzip..."
if ! command -v unzip > /dev/null; thenecho "Not found."echo "======================================================================================================"echo " Please install unzip on your system using your favourite package manager."echo ""echo " Restart after installing unzip."echo "======================================================================================================"echo ""exit 1
fiecho "Looking for zip..."
if ! command -v zip > /dev/null; thenecho "Not found."echo "======================================================================================================"echo " Please install zip on your system using your favourite package manager."echo ""echo " Restart after installing zip."echo "======================================================================================================"echo ""exit 1
fiecho "Looking for curl..."
if ! command -v curl > /dev/null; thenecho "Not found."echo ""echo "======================================================================================================"echo " Please install curl on your system using your favourite package manager."echo ""echo " Restart after installing curl."echo "======================================================================================================"echo ""exit 1
fiif [[ "$solaris" == true ]]; thenecho "Looking for gsed..."if [ -z $(which gsed) ]; thenecho "Not found."echo ""echo "======================================================================================================"echo " Please install gsed on your solaris system."echo ""echo " SDKMAN uses gsed extensively."echo ""echo " Restart after installing gsed."echo "======================================================================================================"echo ""exit 1fi
elseecho "Looking for sed..."if [ -z $(command -v sed) ]; thenecho "Not found."echo ""echo "======================================================================================================"echo " Please install sed on your system using your favourite package manager."echo ""echo " Restart after installing sed."echo "======================================================================================================"echo ""exit 1fi
fiecho "Installing SDKMAN scripts..."# Create directory structureecho "Create distribution directories..."
mkdir -p "$sdkman_tmp_folder"
mkdir -p "$sdkman_ext_folder"
mkdir -p "$sdkman_etc_folder"
mkdir -p "$sdkman_var_folder"
mkdir -p "$sdkman_candidates_folder"echo "Getting available candidates..."
#SDKMAN_CANDIDATES_CSV=$(curl -s "${SDKMAN_SERVICE}/candidates/all")
#echo "$SDKMAN_CANDIDATES_CSV" > "${SDKMAN_DIR}/var/candidates"cat $sdkman_download_dir/candidates > "${SDKMAN_DIR}/var/candidates"echo "Prime platform file..."
# infer platform
function infer_platform() {local kernellocal machinekernel="$(uname -s)"machine="$(uname -m)"case $kernel inLinux)case $machine ini686)echo "linuxx32";;x86_64)echo "linuxx64";;armv6l)echo "linuxarm32hf";;armv7l)echo "linuxarm32hf";;armv8l)echo "linuxarm32hf";;aarch64)echo "linuxarm64";;*)echo "exotic";;esac;;Darwin)case $machine inx86_64)echo "darwinx64";;arm64)echo "darwinarm64";;*)echo "darwinx64";;esac;;MSYS*|MINGW*)case $machine inx86_64)echo "windowsx64";;*)echo "exotic";;esac;;*)echo "exotic"esac
}export SDKMAN_PLATFORM="$(infer_platform)"echo "$SDKMAN_PLATFORM" > "$sdkman_platform_file"echo "Prime the config file..."
touch "$sdkman_config_file"
echo "sdkman_auto_answer=false" >> "$sdkman_config_file"
if [ -z "$ZSH_VERSION" -a -z "$BASH_VERSION" ]; thenecho "sdkman_auto_complete=false" >> "$sdkman_config_file"
elseecho "sdkman_auto_complete=true" >> "$sdkman_config_file"
fi
echo "sdkman_auto_env=false" >> "$sdkman_config_file"
echo "sdkman_beta_channel=false" >> "$sdkman_config_file"
echo "sdkman_checksum_enable=true" >> "$sdkman_config_file"
echo "sdkman_colour_enable=true" >> "$sdkman_config_file"
echo "sdkman_curl_connect_timeout=7" >> "$sdkman_config_file"
echo "sdkman_curl_max_time=10" >> "$sdkman_config_file"
echo "sdkman_debug_mode=false" >> "$sdkman_config_file"
echo "sdkman_insecure_ssl=false" >> "$sdkman_config_file"
echo "sdkman_selfupdate_feature=true" >> "$sdkman_config_file"# script cli distribution
echo "Installing script cli archive..."
# fetch distribution
sdkman_main_zip_file="${sdkman_tmp_folder}/sdkman_main_${SDKMAN_VERSION}.zip"
echo "* Downloading..."
#curl --fail --location --progress-bar "${SDKMAN_SERVICE}/broker/download/sdkman/install/${SDKMAN_VERSION}/${SDKMAN_PLATFORM}" > "$sdkman_zip_file"rm -rf $sdkman_main_zip_file
cp $sdkman_download_dir/sdkman_main_*.zip $sdkman_main_zip_file# check integrity
echo "* Checking archive integrity..."
ARCHIVE_OK=$(unzip -qt "$sdkman_main_zip_file" | grep 'No errors detected in compressed data')
if [[ -z "$ARCHIVE_OK" ]]; thenecho "Downloaded zip archive corrupt. Are you connected to the internet?"echo ""echo "If problems persist, please ask for help on our Slack:"echo "* easy sign up: https://slack.sdkman.io/"echo "* report on channel: https://sdkman.slack.com/app_redirect?channel=user-issues"exit
fi# extract archive
echo "* Extracting archive..."
if [[ "$cygwin" == 'true' ]]; thensdkman_tmp_folder=$(cygpath -w "$sdkman_tmp_folder")sdkman_main_zip_file=$(cygpath -w "$sdkman_main_zip_file")
fiunzip -qo "$sdkman_main_zip_file" -d "$sdkman_tmp_folder"# copy in place
echo "* Copying archive contents..."rm -f "$sdkman_src_folder"/*
cp -rf "${sdkman_tmp_folder}"/sdkman_main_*/* "$SDKMAN_DIR"# clean up
echo "* Cleaning up..."
rm -rf "$sdkman_tmp_folder"/sdkman_main_*
#rm -rf "$sdkman_zip_file"echo ""# native cli distribution
if [[ "$SDKMAN_PLATFORM" != "exotic" ]]; then
echo "Installing script cli archive..."
# fetch distribution
sdkman_native_zip_file="${sdkman_tmp_folder}/sdkman_native_${SDKMAN_NATIVE_VERSION}.zip"
echo "* Downloading..."
#curl --fail --location --progress-bar "${SDKMAN_SERVICE}/broker/download/native/install/${SDKMAN_NATIVE_VERSION}/${SDKMAN_PLATFORM}" > "$sdkman_zip_file"rm -rf $sdkman_native_zip_file
cp $sdkman_download_dir/sdkman_native_*.zip $sdkman_native_zip_file# check integrity
echo "* Checking archive integrity..."
ARCHIVE_OK=$(unzip -qt "$sdkman_native_zip_file" | grep 'No errors detected in compressed data')
if [[ -z "$ARCHIVE_OK" ]]; thenecho "Downloaded zip archive corrupt. Are you connected to the internet?"echo ""echo "If problems persist, please ask for help on our Slack:"echo "* easy sign up: https://slack.sdkman.io/"echo "* report on channel: https://sdkman.slack.com/app_redirect?channel=user-issues"exit
fi# extract archive
echo "* Extracting archive..."
if [[ "$cygwin" == 'true' ]]; thensdkman_tmp_folder=$(cygpath -w "$sdkman_tmp_folder")sdkman_native_zip_file=$(cygpath -w "$sdkman_native_zip_file")
fi
unzip -qo "$sdkman_native_zip_file" -d "$sdkman_tmp_folder"# copy in place
echo "* Copying archive contents..."
rm -f "$sdkman_libexec_folder"/*
cp -rf "${sdkman_tmp_folder}"/sdkman_native_*/* "$SDKMAN_DIR"# clean up
echo "* Cleaning up..."
rm -rf "$sdkman_tmp_folder"/sdkman_native_*
#rm -rf "$sdkman_native_zip_file"
echo ""
fiecho "Set version to $SDKMAN_VERSION ..."
echo "$SDKMAN_VERSION" > "${SDKMAN_DIR}/var/version"echo "Set native version to $SDKMAN_NATIVE_VERSION ..."
echo "$SDKMAN_NATIVE_VERSION" > "${SDKMAN_DIR}/var/version_native"if [[ $darwin == true ]]; thentouch "$sdkman_bash_profile"echo "Attempt update of login bash profile on OSX..."if [[ -z $(grep 'sdkman-init.sh' "$sdkman_bash_profile") ]]; thenecho -e "\n$sdkman_init_snippet" >> "$sdkman_bash_profile"echo "Added sdkman init snippet to $sdkman_bash_profile"fi
elseecho "Attempt update of interactive bash profile on regular UNIX..."touch "${sdkman_bashrc}"if [[ -z $(grep 'sdkman-init.sh' "$sdkman_bashrc") ]]; thenecho -e "\n$sdkman_init_snippet" >> "$sdkman_bashrc"echo "Added sdkman init snippet to $sdkman_bashrc"fi
fiecho "Attempt update of zsh profile..."
touch "$sdkman_zshrc"
if [[ -z $(grep 'sdkman-init.sh' "$sdkman_zshrc") ]]; thenecho -e "\n$sdkman_init_snippet" >> "$sdkman_zshrc"echo "Updated existing ${sdkman_zshrc}"
fiecho -e "\n\n\nAll done!\n\n"echo "You are subscribed to the STABLE channel."echo ""
echo "Please open a new terminal, or run the following in the existing one:"
echo ""
echo "    source \"${SDKMAN_DIR}/bin/sdkman-init.sh\""
echo ""
echo "Then issue the following command:"
echo ""
echo "    sdk help"
echo ""
echo "Enjoy!!!"

完整的脚本及相关文件,我已经放在码云代码仓库sdkman-localized中了,需要的小伙伴可以前去下载。进入目录,执行如下命令即可安装:

cat sdkman.sh | bash

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/631731.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

HarmonyOS—构建第一个ArkTS应用(Stage模型)

创建ArkTS工程 构建第一个页面 若首次打开DevEco Studio&#xff0c;请点击Create Project创建工程。如果已经打开了一个工程&#xff0c;请在菜单栏选择File > New > Create Project来创建一个新工程。选择Application应用开发&#xff0c;选择模板“Empty Ability”&am…

写点东西《什么是网络抓取?》

写点东西《什么是网络抓取&#xff1f;》 什么是网络抓取&#xff1f; 网络抓取合法吗&#xff1f; 什么是网络爬虫&#xff0c;它是如何工作的&#xff1f; 网络爬虫示例 网络抓取工具 结论 您是否曾经想同时比较多个网站上同一件商品的价格&#xff1f;或者自动提取您最喜欢的…

Java-NIO 开篇(1)

NIO简介 高性能的Java通信&#xff0c;离不开Java NIO组件&#xff0c;现在主流的技术框架或中间件服务器&#xff0c;都使用了Java NIO组件&#xff0c;譬如Tomcat、 Jetty、 Netty、Redis、RabbitMQ等的网络通信模块。在1.4版本之前&#xff0c; Java IO类库是阻塞式IO&…

SpringCloud Gateway解决CROS跨域问题

目录 一、问题 二、原因 二、解决方法 1、gateway设置允许跨域 2、手动写一个 CorsResponseHeaderFilter 的 GlobalFilter 去修改Response中的头 一、问题 前端代码访问后端代码时候会出现 Access to XMLHttpRequest at http://localhost:8080/user/logout from origin…

从0开始python学习-49.pytest之日志封装和allure封装

目录 日志封装 1. 在pytest.ini中配置日志的格式 2. 生成日志对象--在请求封装中写 3. 把日志写入文件--在请求封装中写 allure封装 1. 在yaml用例中写入需要的模块、接口等内容 2. 在测试用例封装的函数中通过allure.dynamic的方法写入需要的数据 日志封装 1. 在pytest.…

uniapp写微信小程序实现电子签名

写电子签名一定要注意的是一切全部按照手机上的适配来&#xff0c;为啥这么说呢&#xff0c;因为你在微信开发者工具中调试的时候认为是好的&#xff0c;正常的非常nice,当你发布版本的时候你会发现问题出来了。我下边的写法你可以直接用很简单。就是要记住canvas的几个属性和用…

Android Studi安卓读写NDEF智能海报源码

本示例使用的发卡器&#xff1a;https://item.taobao.com/item.htm?id615391857885&spma1z10.5-c.w4002-21818769070.11.1f60789ey1EsPH <?xml version"1.0" encoding"utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmln…

【NPL】自然语言处理(Natural Language Processing,NLP)的发展简述

大家好&#xff0c;我是全栈小5&#xff0c;欢迎阅读文章&#xff01; 此篇是【话题达人】序列文章&#xff0c;这一次的话题是《自然语言处理的发展》 文章将以博主的角度进行讲述&#xff0c;理解和水平有限&#xff0c;不足之处&#xff0c;望指正。 目录 背景发展线路研发关…

AlphaFold2预测结构能否直接用于虚拟筛选?

AlphaFold2预测结构能否直接用于虚拟筛选&#xff1f; AlphaFold2已经从CASP14大会上横空出世了好久&#xff0c;也对外共享了预测结构数据库AlphaFold Protein Structure Database。对于做CADD的人而言&#xff0c;以前很多没有结构的蛋白靶点也终于有了结构数据可供分析计算…

Python高级编程之旅9:高级项目实战(中级版)

欢迎来到《Python高级编程之旅》系列的第九篇博客&#xff01;在前几篇中&#xff0c;我们介绍了面向对象编程、高级函数、高级语法、并发和多线程、文件处理、网络服务、Socket编程以及待办事项管理器的概念和应用。今天&#xff0c;我们将进行一个中级版的高级项目实战&#…

WordPress回收站自动清空时间?如何关闭回收站或设置自动清理天数?

我们在WordPress后台的文章、页面、评论等页面都可以看到有回收站&#xff0c;意思就是我们不能直接删除某篇文章、页面、评论&#xff0c;而是需要现将它们移至回收站&#xff0c;然后再到回收站永久删除&#xff0c;或等回收站自动清理。 如上图所示&#xff0c;WordPress 6.…

归并排序(C语言)

目录 1.归并排序图解 2.归并排序&#xff08;递归版&#xff09; 3.归并排序&#xff08;非递归版&#xff09; 1.归并排序图解 归并排序的核心思想是让左右两边有序的部分进行合并比较排序&#xff0c;具体什么意思呢&#xff1f;分两点&#xff1a; 1.分&#xff1a;左右两边…

Baumer工业相机堡盟工业相机如何通过NEOAPI SDK使用相机日志跟踪功能(C++)

Baumer工业相机堡盟工业相机如何通过NEOAPI SDK使用相机日志跟踪功能&#xff08;C&#xff09; Baumer工业相机Baumer工业相机NEOAPI SDK和短曝光功能的技术背景Baumer工业相机通过NEOAPI SDK使用相机日志跟踪功能1.引用合适的类文件2.通过NEOAPI SDK使用相机日志跟踪功能3.通…

每天一个vue知识点

①v-model和v-bind的简写方式 在Vue.js中&#xff0c;v-model和v-bind都是用于绑定数据的指令。为了简化代码&#xff0c;Vue提供了它们的简写方式。 v-model的简写方式是使用冒号&#xff08;:&#xff09;。 例如&#xff0c;下面的代码是使用v-model绑定一个输入框的值&a…

如何用Docker部署Nacos服务并结合内网穿透实现公网访问管理界面?

文章目录 1. Docker 运行Nacos2. 本地访问Nacos3. Linux安装Cpolar4. 配置Nacos UI界面公网地址5. 远程访问 Nacos UI界面6. 固定Nacos UI界面公网地址7. 固定地址访问Plik Nacos是阿里开放的一款中间件,也是一款服务注册中心&#xff0c;它主要提供三种功能&#xff1a;持久化…

【拆解设计模式】工厂方法及其Java示例

工厂方法 一、设计模式的基本概念 在我们的编程世界中&#xff0c;设计模式就如同一盏指路明灯&#xff0c;引领我们走向优雅、高效的代码之路。设计模式是一种在特定环境下解决特定问题的优秀方案&#xff0c;它是前人的经验总结&#xff0c;是我们编程的宝贵财富。 1.1 设…

软件系统的安全性:问题、方法、文献综述及结论

本人详解 作者:王文峰,参加过 CSDN 2020年度博客之星,《Java王大师王天师》 公众号:JAVA开发王大师,专注于天道酬勤的 Java 开发问题中国国学、传统文化和代码爱好者的程序人生,期待你的关注和支持!本人外号:神秘小峯 山峯 转载说明:务必注明来源(注明:作者:王文峰…

关于QT程序部署到linux及阿里云平台短信及语音

QT准备 在linux布署QT程序1. 需要在ubunt16.04下,编译QT程序,先安装2. 下载linuxdeployqt,这个与win下QT打包程序 windeployqt3. 加载库路径设置到bash,这个已经写成了qt.env,直接source一下就可以4. 生成release文件,生成前需要确认下数据库路径设置是否正常,因为是要放到…

区间预测 | Matlab实现GRU-Adaboost-ABKDE的集成门控循环单元自适应带宽核密度估计多变量回归区间预测

区间预测 | Matlab实现GRU-Adaboost-ABKDE的集成门控循环单元自适应带宽核密度估计多变量回归区间预测 目录 区间预测 | Matlab实现GRU-Adaboost-ABKDE的集成门控循环单元自适应带宽核密度估计多变量回归区间预测效果一览基本介绍程序设计参考资料 效果一览 基本介绍 1.Matlab实…