From 784b219cdc79c1791f2b41598db9f03c29e5b178 Mon Sep 17 00:00:00 2001 From: boypt <1033514+boypt@users.noreply.github.com> Date: Mon, 1 Jun 2026 10:01:49 +0800 Subject: [PATCH] update lazy script --- lazy_install.sh | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/lazy_install.sh b/lazy_install.sh index 6ae3954..5c5f9e7 100755 --- a/lazy_install.sh +++ b/lazy_install.sh @@ -5,8 +5,8 @@ set -o pipefail set -o nounset set -o xtrace trap 'echo -e "Aborted, error $? in command: $BASH_COMMAND"; trap ERR; exit 1' ERR -# make sure you have the tools -sudo apt install -y wget jq lsb-release + +sudo apt install -y wget jq lsb-release tar #GH_PROXY=https://tvv.tw/ #GH_PROXY=https://gh-proxy.com/ @@ -25,24 +25,33 @@ fi _WORKDIR=$(mktemp -d) _CN=$(lsb_release -sc) _AR=$(dpkg --print-architecture) +_TARGET_ARCH="${_AR}" pushd $_WORKDIR -mapfile -t DEB_URLS < <(wget -O- "$_LATEST_API" \ - | jq -r ".assets[] | select(.name | contains(\"${_CN}_${_AR}\") or contains(\"${_CN}_all\")) | .browser_download_url" ) +TAR_URL=$(wget -O- "$_LATEST_API" \ + | jq -r ".assets[] | select(.name | contains(\"${_CN}\") and contains(\"${_TARGET_ARCH}\") and (endswith(\".tar.gz\"))) | .browser_download_url" | head -n 1) -if [[ -n ${GH_PROXY:-} ]] && ! printf '%s\n' "${DEB_URLS[@]}" | grep ${GH_PROXY}; then - printf '%s\n' "${DEB_URLS[@]}" | sed "s|https://github.com|${GH_PROXY:-}https://github.com|g" | wget -i - -else - printf '%s\n' "${DEB_URLS[@]}" | wget -i - +if [[ -z "$TAR_URL" ]]; then + echo "Error: No matching release package found for ${_CN}-${_TARGET_ARCH}." + exit 1 fi -if [[ $(find . -type f -name "*${_CN}*.deb" | wc -l) -gt 0 ]]; then - echo "> These DEBs is going to be installed... Ctrl+C to interrupt" - find . -type f -name "*${_CN}*.deb" -print +if [[ -n ${GH_PROXY:-} ]] && ! [[ "$TAR_URL" =~ ^${GH_PROXY}.* ]]; then + TAR_URL=$(echo "$TAR_URL" | sed "s|https://github.com|${GH_PROXY:-}https://github.com|g") +fi + +wget -O- "$TAR_URL" | tar -xzf - + +if [[ $(find . -type f -name "*.deb" | wc -l) -gt 0 ]]; then + echo "> These DEBs are going to be installed... Ctrl+C to interrupt" + find . -type f -name "*.deb" -print sleep 3 - find . -type f -name "*${_CN}*.deb" -print | xargs sudo apt install -y + find . -type f -name "*.deb" -print | xargs sudo apt install -y +else + echo "Error: No .deb packages found inside the archive." + exit 1 fi popd [[ -d $_WORKDIR ]] && rm -rfv $_WORKDIR -ssh -V +ssh -V \ No newline at end of file