Files
unlimitedcoding/qwen/uqwen_update.sh
delta-cloud-208e b829db3e93 fix: add auth headers to all Linux .sh gitea downloads
- gemini/ugemini_install.sh: CURL_AUTH was defined but never used, fixed
- gemini/ugemini_update.sh: added GITEA_TOKEN + auth header
- qwen/uqwen_install.sh: use GITEA_TOKEN (was already defined but unused)
- qwen/uqwen_update.sh: added GITEA_TOKEN + auth header

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 08:34:31 +00:00

97 lines
2.8 KiB
Bash

#!/usr/bin/env bash
# Qwen Code — Updater
# Re-installs latest version from registry + re-applies patches.
#
# Usage: sudo bash uqwen_update.sh
set -euo pipefail
REGISTRY_URL="https://npm.sensey24.ru/"
NPM_SCOPE="@qwen-code"
NPM_PACKAGE="@qwen-code/qwen-code"
REPO_RAW="https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen"
GREEN="\033[92m"
CYAN="\033[96m"
YELLOW="\033[93m"
RED="\033[91m"
BOLD="\033[1m"
RESET="\033[0m"
log() { echo -e "${GREEN}[+]${RESET} $*"; }
info() { echo -e "${CYAN}[i]${RESET} $*"; }
warn() { echo -e "${YELLOW}[~]${RESET} $*"; }
err() { echo -e "${RED}[!]${RESET} $*" >&2; }
echo -e "${BOLD}"
echo " +--------------------------------------+"
echo " | Qwen Code — Updater |"
echo " +--------------------------------------+"
echo -e "${RESET}"
# ---- Check current version ----
OLD_VER=""
QWEN_BIN=""
for candidate in qwen qwen-code; do
if command -v "$candidate" &>/dev/null; then
QWEN_BIN="$candidate"
break
fi
done
if [ -n "$QWEN_BIN" ]; then
OLD_VER=$($QWEN_BIN --version 2>/dev/null || echo "unknown")
info "Current: $QWEN_BIN $OLD_VER"
else
warn "Qwen Code not found. Will install fresh."
fi
# ---- Configure npm registry ----
info "Configuring npm registry: ${REGISTRY_URL}"
npm config set "${NPM_SCOPE}:registry" "${REGISTRY_URL}" 2>/dev/null || true
# ---- Update package ----
info "Installing latest ${NPM_PACKAGE}..."
if npm install -g "${NPM_PACKAGE}" 2>&1; then
log "Package updated"
else
err "npm install failed. Try: npm config set ${NPM_SCOPE}:registry http://npm.sensey24.ru/"
exit 1
fi
# Find binary after update
for candidate in qwen qwen-code; do
if command -v "$candidate" &>/dev/null; then
QWEN_BIN="$candidate"
break
fi
done
NEW_VER=$($QWEN_BIN --version 2>/dev/null || echo "unknown")
log "Version: $OLD_VER$NEW_VER"
# ---- Download and apply patches ----
TEMP_DIR=$(mktemp -d)
cleanup() { rm -rf "$TEMP_DIR" 2>/dev/null || true; }
trap cleanup EXIT
info "Downloading patcher..."
GITEA_TOKEN="${GITEA_TOKEN:-cadffcb0a6a3be728ac1ff619bb40c86588f6837}"
curl -fsSL -H "Authorization: token ${GITEA_TOKEN}" "$REPO_RAW/qwen_patcher.py" -o "$TEMP_DIR/qwen_patcher.py"
curl -fsSL -H "Authorization: token ${GITEA_TOKEN}" "$REPO_RAW/qwen_config.json" -o "$TEMP_DIR/qwen_config.json"
info "Applying patches..."
python3 "$TEMP_DIR/qwen_patcher.py" --settings-only --config "$TEMP_DIR/qwen_config.json"
PATCH_EXIT=$?
if [ $PATCH_EXIT -ne 0 ]; then
warn "Settings-only patch returned $PATCH_EXIT, trying full patch..."
python3 "$TEMP_DIR/qwen_patcher.py" --apply --config "$TEMP_DIR/qwen_config.json"
fi
log "Update complete!"
echo ""