diff --git a/src/gpu_rent/remote/install_llamacpp.sh b/src/gpu_rent/remote/install_llamacpp.sh index baca59b..bf71bd9 100644 --- a/src/gpu_rent/remote/install_llamacpp.sh +++ b/src/gpu_rent/remote/install_llamacpp.sh @@ -147,7 +147,7 @@ ensure_vulkan_runtime() { install_from_archive_url() { local url="$1" - local tmp + local tmp kind tmp="$(mktemp -d)" ( cd "$tmp" @@ -158,20 +158,32 @@ install_from_archive_url() { else log "WARN: LLAMACPP_SHA256 не задан — checksum skip" fi - if file pkg.bin | grep -qi zip; then - apt-get install -y -qq unzip >/dev/null 2>&1 || true - unzip -qo pkg.bin -d out - else - mkdir -p out - tar -xaf pkg.bin -C out 2>/dev/null || tar -xzf pkg.bin -C out - fi + mkdir -p out + # Do NOT grep -i zip — that matches "gzip" and breaks .tar.gz. + kind="$(file -b pkg.bin 2>/dev/null || true)" + case "$url" in + *.zip) + apt-get install -y -qq unzip >/dev/null 2>&1 || true + unzip -qo pkg.bin -d out + ;; + *) + if [[ "$kind" == Zip\ archive* ]] || [[ "$kind" == *"Zip archive"* ]]; then + apt-get install -y -qq unzip >/dev/null 2>&1 || true + unzip -qo pkg.bin -d out + else + tar -xaf pkg.bin -C out 2>/dev/null \ + || tar -xzf pkg.bin -C out 2>/dev/null \ + || tar -xf pkg.bin -C out + fi + ;; + esac local found found="$(find out -type f -name 'llama-server' | head -n1 || true)" if [[ -z "$found" ]]; then found="$(find out -type f -name 'server' | head -n1 || true)" fi if [[ -z "$found" ]]; then - log "в архиве нет llama-server" + log "в архиве нет llama-server (file says: ${kind:-unknown})" exit 1 fi install -m 755 "$found" "$SERVER_BIN" @@ -204,7 +216,9 @@ install_linux_release() { else log "WARN: Linux prebuilt без GPU backend (CPU) — ${url##*/}" fi - install_from_archive_url "$url" + if ! install_from_archive_url "$url"; then + return 1 + fi echo "asset:${tag}" >"$STAMP" chown "${SWARM_USER}:${SWARM_USER}" "$STAMP" }