docs: cross-platform install/update/uninstall instructions for codex/gemini/qwen
- Add Linux / macOS / Windows PowerShell / Windows CMD sections to all CLI READMEs - Update product table versions (claude v2.1.112, codex v0.116.0, qwen v0.14.5) - Make qwen install/update/uninstall scripts macOS-aware (sedi wrapper, launchctl, /Users scan, ~/.zshrc) - Make gemini uninstall script macOS-aware (matching install/update) - Fix CRLF line endings in qwen/gemini uninstall scripts Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
302
qwen/README.md
302
qwen/README.md
@@ -1,99 +1,203 @@
|
||||
# Qwen Code Patcher
|
||||
|
||||
Patches [QwenCode CLI](https://github.com/QwenLM/qwen-code) (`@qwen-code/qwen-code`) to route all API requests through a custom AI proxy, disable telemetry, and auto-configure settings.
|
||||
|
||||
**[RU]** Патчер для QwenCode CLI — перенаправляет API запросы через пользовательский AI прокси, отключает телеметрию, автоматически настраивает окружение.
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# 1. Install from private registry
|
||||
npm config set @qwen-code:registry https://npm.sensey24.ru/
|
||||
npm install -g @qwen-code/qwen-code
|
||||
|
||||
# 2. Apply settings (env vars + settings.json)
|
||||
python3 qwen_patcher.py --settings-only
|
||||
|
||||
# 3. Verify
|
||||
qwen -p "Say hello"
|
||||
```
|
||||
|
||||
## Windows
|
||||
|
||||
```powershell
|
||||
npm config set "@qwen-code:registry" "https://npm.sensey24.ru/"
|
||||
npm install -g @qwen-code/qwen-code
|
||||
python3 qwen_patcher.py --settings-only
|
||||
```
|
||||
|
||||
## Update
|
||||
|
||||
Same two commands — npm will pull the latest patched version:
|
||||
|
||||
```bash
|
||||
npm config set @qwen-code:registry https://npm.sensey24.ru/
|
||||
npm install -g @qwen-code/qwen-code
|
||||
```
|
||||
|
||||
## What Gets Patched
|
||||
|
||||
| # | Target | Description |
|
||||
|---|--------|-------------|
|
||||
| 1 | telemetry_flag | Force `getTelemetryEnabled()` -> false |
|
||||
| 2 | telemetry_log_prompts | Force `getTelemetryLogPromptsEnabled()` -> false |
|
||||
| 3 | telemetry_init_guard | Early return in `initializeTelemetry()` |
|
||||
| 4 | dashscope_base_url | `DEFAULT_DASHSCOPE_BASE_URL` -> proxy |
|
||||
| 5 | coding_plan_urls | `coding.dashscope.aliyuncs.com` -> proxy |
|
||||
| 6 | default_model | Validate `DEFAULT_QWEN_MODEL = "coder-model"` |
|
||||
| 7 | mainline_model | Validate `MAINLINE_CODER_MODEL = "qwen3.5-plus"` |
|
||||
| 8 | auto_update_registry | `registry.npmjs.org` -> private registry |
|
||||
| 9 | auto_update_command | Add `--registry` to update commands |
|
||||
| 10 | user_settings | Auth type=openai, telemetry=false, model |
|
||||
| 11 | trusted_folders | Trust /home, /root, /tmp |
|
||||
| 12 | system_env | OPENAI_API_KEY, OPENAI_BASE_URL, telemetry vars |
|
||||
|
||||
Targets 1-9 are pre-patched in the npm package. Targets 10-12 require running `qwen_patcher.py --settings-only`.
|
||||
|
||||
## Models
|
||||
|
||||
| Model | Description |
|
||||
|-------|-------------|
|
||||
| `qwen3.5-plus` | Qwen 3.5 Plus — default |
|
||||
| `coder-model` | Direct OAuth model name |
|
||||
| `qwen3-coder-plus` | Qwen3 Coder Plus |
|
||||
| `qwen3-coder-flash` | Qwen3 Coder Flash (fast) |
|
||||
|
||||
## CLI Usage
|
||||
|
||||
```bash
|
||||
# Detection
|
||||
python3 qwen_patcher.py --detect
|
||||
|
||||
# Validation (GREEN/YELLOW/RED for each target)
|
||||
python3 qwen_patcher.py --validate
|
||||
|
||||
# Full patch (cli.js + settings + env)
|
||||
python3 qwen_patcher.py --apply
|
||||
|
||||
# Settings only (no cli.js modification)
|
||||
python3 qwen_patcher.py --settings-only
|
||||
|
||||
# Rollback cli.js from backup
|
||||
python3 qwen_patcher.py --rollback
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "model not supported" error
|
||||
|
||||
Make sure your proxy has `qwen3.5-plus` mapped to `coder-model` in the OAuth model alias config. The Qwen OAuth endpoint only accepts `coder-model` as the model name.
|
||||
|
||||
### CLI doesn't start after patching
|
||||
|
||||
If you applied `--apply` and the CLI fails to start, run `--rollback` to restore from backup, then use the pre-patched npm package instead:
|
||||
|
||||
```bash
|
||||
python3 qwen_patcher.py --rollback
|
||||
npm install -g @qwen-code/qwen-code # Re-installs pre-patched version
|
||||
python3 qwen_patcher.py --settings-only
|
||||
```
|
||||
# Qwen Code Patcher
|
||||
|
||||
Patches [QwenCode CLI](https://github.com/QwenLM/qwen-code) (`@qwen-code/qwen-code`) to route all API requests through a custom AI proxy, disable telemetry, and auto-configure settings.
|
||||
|
||||
**[RU]** Патчер для QwenCode CLI — перенаправляет API запросы через пользовательский AI прокси, отключает телеметрию, автоматически настраивает окружение.
|
||||
|
||||
Latest target version: **v0.14.5** (12 patches).
|
||||
|
||||
## Install
|
||||
|
||||
> Node.js v20+ required. Установщик подтянет Node.js если его нет.
|
||||
|
||||
### One-liner — все платформы
|
||||
|
||||
**Linux (Debian/Ubuntu/RHEL/Fedora):**
|
||||
```bash
|
||||
curl -fsSL -H "Authorization: token cadffcb0a6a3be728ac1ff619bb40c86588f6837" \
|
||||
https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_install.sh \
|
||||
-o /tmp/uqwen_install.sh && sudo bash /tmp/uqwen_install.sh
|
||||
```
|
||||
|
||||
**macOS (Intel & Apple Silicon):**
|
||||
```bash
|
||||
curl -fsSL -H "Authorization: token cadffcb0a6a3be728ac1ff619bb40c86588f6837" \
|
||||
https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_install.sh \
|
||||
-o /tmp/uqwen_install.sh && sudo bash /tmp/uqwen_install.sh
|
||||
```
|
||||
|
||||
> macOS: env vars (`OPENAI_API_KEY`, `OPENAI_BASE_URL`) добавляются в `~/.zshrc`.
|
||||
> Если sudo попросит — введите пароль.
|
||||
|
||||
**Windows (PowerShell as Administrator):**
|
||||
```powershell
|
||||
$h=@{Authorization="token cadffcb0a6a3be728ac1ff619bb40c86588f6837"}
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force
|
||||
iwr "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_install.ps1" -OutFile "$env:TEMP\uqwen_install.ps1" -Headers $h
|
||||
. "$env:TEMP\uqwen_install.ps1"
|
||||
```
|
||||
|
||||
**Windows (CMD as Administrator):**
|
||||
```cmd
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command "$h=@{Authorization='token cadffcb0a6a3be728ac1ff619bb40c86588f6837'}; iwr 'https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_install.ps1' -OutFile \"$env:TEMP\uqwen_install.ps1\" -Headers $h; & \"$env:TEMP\uqwen_install.ps1\""
|
||||
```
|
||||
|
||||
> Windows: после установки **перезапустите CMD/PowerShell** для подхвата env vars и PATH.
|
||||
|
||||
### Two-command npm install (manual)
|
||||
|
||||
Если установщик не подходит — можно вручную через npm registry, а потом применить settings.
|
||||
|
||||
**Linux / macOS:**
|
||||
```bash
|
||||
npm config set @qwen-code:registry https://npm.sensey24.ru/
|
||||
npm install -g @qwen-code/qwen-code
|
||||
python3 qwen_patcher.py --settings-only
|
||||
```
|
||||
|
||||
**Windows (PowerShell):**
|
||||
```powershell
|
||||
npm config set "@qwen-code:registry" "https://npm.sensey24.ru/"
|
||||
npm install -g @qwen-code/qwen-code
|
||||
python qwen_patcher.py --settings-only
|
||||
```
|
||||
|
||||
**Windows (CMD):**
|
||||
```cmd
|
||||
npm config set "@qwen-code:registry" "https://npm.sensey24.ru/"
|
||||
npm install -g @qwen-code/qwen-code
|
||||
python qwen_patcher.py --settings-only
|
||||
```
|
||||
|
||||
### Verify
|
||||
|
||||
```bash
|
||||
qwen -p "Say hello"
|
||||
```
|
||||
|
||||
## Update
|
||||
|
||||
### One-liner
|
||||
|
||||
**Linux / macOS:**
|
||||
```bash
|
||||
curl -fsSL -H "Authorization: token cadffcb0a6a3be728ac1ff619bb40c86588f6837" \
|
||||
https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_update.sh \
|
||||
-o /tmp/uqwen_update.sh && sudo bash /tmp/uqwen_update.sh
|
||||
```
|
||||
|
||||
**Windows (PowerShell as Administrator):**
|
||||
```powershell
|
||||
$h=@{Authorization="token cadffcb0a6a3be728ac1ff619bb40c86588f6837"}
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force
|
||||
iwr "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_update.ps1" -OutFile "$env:TEMP\uqwen_update.ps1" -Headers $h
|
||||
. "$env:TEMP\uqwen_update.ps1"
|
||||
```
|
||||
|
||||
**Windows (CMD as Administrator):**
|
||||
```cmd
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command "$h=@{Authorization='token cadffcb0a6a3be728ac1ff619bb40c86588f6837'}; iwr 'https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_update.ps1' -OutFile \"$env:TEMP\uqwen_update.ps1\" -Headers $h; & \"$env:TEMP\uqwen_update.ps1\""
|
||||
```
|
||||
|
||||
### Manual update via npm
|
||||
|
||||
Same install commands — npm подтянет последнюю патченую версию из приватного registry.
|
||||
|
||||
```bash
|
||||
npm install -g @qwen-code/qwen-code
|
||||
```
|
||||
|
||||
## Uninstall
|
||||
|
||||
**Linux / macOS:**
|
||||
```bash
|
||||
curl -fsSL -H "Authorization: token cadffcb0a6a3be728ac1ff619bb40c86588f6837" \
|
||||
https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_uninstall.sh \
|
||||
-o /tmp/uqwen_uninstall.sh && sudo bash /tmp/uqwen_uninstall.sh
|
||||
```
|
||||
|
||||
**Windows (PowerShell as Administrator):**
|
||||
```powershell
|
||||
$h=@{Authorization="token cadffcb0a6a3be728ac1ff619bb40c86588f6837"}
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force
|
||||
iwr "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_uninstall.ps1" -OutFile "$env:TEMP\uqwen_uninstall.ps1" -Headers $h
|
||||
. "$env:TEMP\uqwen_uninstall.ps1"
|
||||
```
|
||||
|
||||
Удаляются: npm-пакет, `~/.qwen/`, env vars, npm registry config.
|
||||
|
||||
## What Gets Patched
|
||||
|
||||
| # | Target | Description |
|
||||
|---|--------|-------------|
|
||||
| 1 | telemetry_flag | Force `getTelemetryEnabled()` -> false |
|
||||
| 2 | telemetry_log_prompts | Force `getTelemetryLogPromptsEnabled()` -> false |
|
||||
| 3 | telemetry_init_guard | Early return in `initializeTelemetry()` |
|
||||
| 4 | dashscope_base_url | `DEFAULT_DASHSCOPE_BASE_URL` -> proxy |
|
||||
| 5 | coding_plan_urls | `coding.dashscope.aliyuncs.com` -> proxy |
|
||||
| 6 | default_model | Validate `DEFAULT_QWEN_MODEL = "coder-model"` |
|
||||
| 7 | mainline_model | Validate `MAINLINE_CODER_MODEL = "qwen3.5-plus"` |
|
||||
| 8 | auto_update_registry | `registry.npmjs.org` -> private registry |
|
||||
| 9 | auto_update_command | Add `--registry` to update commands |
|
||||
| 10 | user_settings | Auth type=openai, telemetry=false, model |
|
||||
| 11 | trusted_folders | Trust /home, /root, /tmp |
|
||||
| 12 | system_env | OPENAI_API_KEY, OPENAI_BASE_URL, telemetry vars |
|
||||
|
||||
Targets 1-9 are pre-patched in the npm package. Targets 10-12 require running `qwen_patcher.py --settings-only`.
|
||||
|
||||
## Models
|
||||
|
||||
| Model | Description |
|
||||
|-------|-------------|
|
||||
| `qwen3.5-plus` | Qwen 3.5 Plus — default |
|
||||
| `qwen3-coder-plus` | Qwen3 Coder Plus |
|
||||
| `qwen3-coder-flash` | Qwen3 Coder Flash (fast) |
|
||||
|
||||
## CLI Usage
|
||||
|
||||
```bash
|
||||
# Detection
|
||||
python3 qwen_patcher.py --detect
|
||||
|
||||
# Validation (GREEN/YELLOW/RED for each target)
|
||||
python3 qwen_patcher.py --validate
|
||||
|
||||
# Full patch (cli.js + settings + env)
|
||||
python3 qwen_patcher.py --apply
|
||||
|
||||
# Settings only (no cli.js modification)
|
||||
python3 qwen_patcher.py --settings-only
|
||||
|
||||
# Rollback cli.js from backup
|
||||
python3 qwen_patcher.py --rollback
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "model not supported" error
|
||||
|
||||
Make sure your proxy has `qwen3.5-plus` mapped to `coder-model` in the OAuth model alias config. The Qwen OAuth endpoint only accepts `coder-model` as the model name.
|
||||
|
||||
### CLI doesn't start after patching
|
||||
|
||||
If you applied `--apply` and the CLI fails to start, run `--rollback` to restore from backup, then use the pre-patched npm package instead:
|
||||
|
||||
```bash
|
||||
python3 qwen_patcher.py --rollback
|
||||
npm install -g @qwen-code/qwen-code # Re-installs pre-patched version
|
||||
python3 qwen_patcher.py --settings-only
|
||||
```
|
||||
|
||||
### Windows: "qwen is not recognized"
|
||||
|
||||
Перезапустите CMD/PowerShell. Либо вручную обновите PATH в текущей сессии:
|
||||
```powershell
|
||||
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
|
||||
```
|
||||
|
||||
### macOS: env vars not picked up
|
||||
|
||||
Перезайдите в shell или загрузите вручную:
|
||||
```bash
|
||||
source ~/.zshrc
|
||||
```
|
||||
|
||||
@@ -14,7 +14,24 @@ REGISTRY_URL="https://npm.sensey24.ru/"
|
||||
NPM_SCOPE="@qwen-code"
|
||||
NPM_PACKAGE="@qwen-code/qwen-code"
|
||||
|
||||
ENV_FILE="/etc/profile.d/qwen-code.sh"
|
||||
OS="$(uname -s)"
|
||||
IS_MACOS=false
|
||||
[ "$OS" = "Darwin" ] && IS_MACOS=true
|
||||
|
||||
if $IS_MACOS; then
|
||||
ENV_FILE="/etc/qwen-code-env.sh"
|
||||
else
|
||||
ENV_FILE="/etc/profile.d/qwen-code.sh"
|
||||
fi
|
||||
|
||||
# Cross-platform sed -i (macOS BSD sed requires -i '' while GNU sed uses -i)
|
||||
sedi() {
|
||||
if $IS_MACOS; then
|
||||
sed -i '' "$@"
|
||||
else
|
||||
sed -i "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
GREEN="\033[92m"
|
||||
RED="\033[91m"
|
||||
@@ -211,23 +228,55 @@ info "Setting environment variables..."
|
||||
API_KEY=$(python3 -c "import json; print(json.load(open('$INSTALL_DIR/qwen_config.json'))['api_key'])")
|
||||
BASE_URL=$(python3 -c "import json; print(json.load(open('$INSTALL_DIR/qwen_config.json'))['base_url'])")
|
||||
|
||||
ETC_ENV="/etc/environment"
|
||||
for kv in "QWEN_API_KEY=\"$API_KEY\"" "QWEN_BASE_URL=\"$BASE_URL\""; do
|
||||
KEY="${kv%%=*}"
|
||||
if grep -q "^${KEY}=" "$ETC_ENV" 2>/dev/null; then
|
||||
sed -i "s|^${KEY}=.*|${kv}|" "$ETC_ENV"
|
||||
else
|
||||
echo "$kv" >> "$ETC_ENV"
|
||||
fi
|
||||
done
|
||||
log "Env vars written to $ETC_ENV"
|
||||
if $IS_MACOS; then
|
||||
# macOS: no /etc/environment, no /etc/profile.d
|
||||
launchctl setenv QWEN_API_KEY "$API_KEY" 2>/dev/null || true
|
||||
launchctl setenv QWEN_BASE_URL "$BASE_URL" 2>/dev/null || true
|
||||
log "Env vars set via launchctl"
|
||||
|
||||
cat > "$ENV_FILE" << PROF_EOF
|
||||
cat > "$ENV_FILE" << ENVEOF
|
||||
export QWEN_API_KEY="$API_KEY"
|
||||
export QWEN_BASE_URL="$BASE_URL"
|
||||
ENVEOF
|
||||
chmod 644 "$ENV_FILE"
|
||||
log "Env file: $ENV_FILE"
|
||||
|
||||
# Add source to user shell rc files
|
||||
REAL_HOME="$HOME"
|
||||
if [ -n "${SUDO_USER:-}" ] && [ "$SUDO_USER" != "root" ]; then
|
||||
REAL_HOME=$(eval echo "~$SUDO_USER")
|
||||
fi
|
||||
for rc_file in "$REAL_HOME/.zshrc" "$REAL_HOME/.bashrc"; do
|
||||
if [ -f "$rc_file" ] || [ "$rc_file" = "$REAL_HOME/.zshrc" ]; then
|
||||
if [ -f "$rc_file" ]; then
|
||||
sedi '/# Qwen env/d' "$rc_file"
|
||||
sedi '/qwen-code-env\.sh/d' "$rc_file"
|
||||
fi
|
||||
echo "[ -f $ENV_FILE ] && . $ENV_FILE # Qwen env" >> "$rc_file"
|
||||
log "Added source to $rc_file"
|
||||
fi
|
||||
done
|
||||
else
|
||||
# Linux: /etc/environment for all users
|
||||
ETC_ENV="/etc/environment"
|
||||
for kv in "QWEN_API_KEY=\"$API_KEY\"" "QWEN_BASE_URL=\"$BASE_URL\""; do
|
||||
KEY="${kv%%=*}"
|
||||
if grep -q "^${KEY}=" "$ETC_ENV" 2>/dev/null; then
|
||||
sedi "s|^${KEY}=.*|${kv}|" "$ETC_ENV"
|
||||
else
|
||||
echo "$kv" >> "$ETC_ENV"
|
||||
fi
|
||||
done
|
||||
log "Env vars written to $ETC_ENV"
|
||||
|
||||
mkdir -p /etc/profile.d
|
||||
cat > "$ENV_FILE" << PROF_EOF
|
||||
export QWEN_API_KEY="$API_KEY"
|
||||
export QWEN_BASE_URL="$BASE_URL"
|
||||
PROF_EOF
|
||||
chmod 644 "$ENV_FILE"
|
||||
log "Env file: $ENV_FILE"
|
||||
chmod 644 "$ENV_FILE"
|
||||
log "Env file: $ENV_FILE"
|
||||
fi
|
||||
|
||||
# ---- Create wrapper (auto-loads env) ----
|
||||
|
||||
|
||||
@@ -1,85 +1,115 @@
|
||||
#!/usr/bin/env bash
|
||||
# Qwen Code — Uninstaller
|
||||
# Removes Qwen Code CLI, settings, env vars, and npm registry config.
|
||||
#
|
||||
# Usage: sudo bash uqwen_uninstall.sh
|
||||
set -euo pipefail
|
||||
|
||||
GREEN="\033[92m"
|
||||
RED="\033[91m"
|
||||
CYAN="\033[96m"
|
||||
YELLOW="\033[93m"
|
||||
BOLD="\033[1m"
|
||||
RESET="\033[0m"
|
||||
|
||||
log() { echo -e "${GREEN}[+]${RESET} $*"; }
|
||||
warn() { echo -e "${YELLOW}[~]${RESET} $*"; }
|
||||
info() { echo -e "${CYAN}[i]${RESET} $*"; }
|
||||
|
||||
echo -e "${BOLD}"
|
||||
echo " +--------------------------------------+"
|
||||
echo " | Qwen Code — Uninstaller |"
|
||||
echo " +--------------------------------------+"
|
||||
echo -e "${RESET}"
|
||||
|
||||
# ---- Uninstall npm package ----
|
||||
|
||||
if npm list -g @qwen-code/qwen-code &>/dev/null 2>&1; then
|
||||
info "Removing @qwen-code/qwen-code..."
|
||||
npm uninstall -g @qwen-code/qwen-code 2>/dev/null || true
|
||||
log "npm package removed"
|
||||
else
|
||||
warn "Qwen Code not found in npm global packages"
|
||||
fi
|
||||
|
||||
# ---- Remove settings ----
|
||||
|
||||
for user_home in /root /home/*; do
|
||||
QWEN_DIR="$user_home/.qwen"
|
||||
if [ -d "$QWEN_DIR" ]; then
|
||||
info "Removing $QWEN_DIR..."
|
||||
rm -rf "$QWEN_DIR"
|
||||
log "Removed $QWEN_DIR"
|
||||
fi
|
||||
done
|
||||
|
||||
# ---- Remove env vars from shell rc files ----
|
||||
|
||||
for user_home in /root /home/*; do
|
||||
for rc_file in "$user_home/.bashrc" "$user_home/.zshrc"; do
|
||||
if [ -f "$rc_file" ] && grep -q 'QWEN_API_KEY\|QWEN_BASE_URL\|Qwen Code' "$rc_file" 2>/dev/null; then
|
||||
info "Cleaning env vars from $rc_file..."
|
||||
sed -i '/# Qwen Code/d' "$rc_file"
|
||||
sed -i '/QWEN_API_KEY/d' "$rc_file"
|
||||
sed -i '/QWEN_BASE_URL/d' "$rc_file"
|
||||
log "Cleaned $rc_file"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# ---- Remove /etc/profile.d script ----
|
||||
|
||||
if [ -f "/etc/profile.d/qwen-code.sh" ]; then
|
||||
info "Removing /etc/profile.d/qwen-code.sh..."
|
||||
rm -f "/etc/profile.d/qwen-code.sh"
|
||||
log "Removed /etc/profile.d/qwen-code.sh"
|
||||
fi
|
||||
|
||||
# ---- Remove env vars from /etc/environment ----
|
||||
|
||||
if [ -f "/etc/environment" ] && grep -q 'QWEN_API_KEY\|QWEN_BASE_URL' /etc/environment 2>/dev/null; then
|
||||
info "Cleaning /etc/environment..."
|
||||
sed -i '/QWEN_API_KEY/d' /etc/environment
|
||||
sed -i '/QWEN_BASE_URL/d' /etc/environment
|
||||
log "Cleaned /etc/environment"
|
||||
fi
|
||||
|
||||
# ---- Remove npm registry config ----
|
||||
|
||||
info "Removing npm registry config..."
|
||||
npm config delete @qwen-code:registry 2>/dev/null || true
|
||||
log "npm registry config removed"
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}${BOLD} Qwen Code fully uninstalled!${RESET}"
|
||||
echo ""
|
||||
#!/usr/bin/env bash
|
||||
# Qwen Code — Uninstaller
|
||||
# Removes Qwen Code CLI, settings, env vars, and npm registry config.
|
||||
#
|
||||
# Usage: sudo bash uqwen_uninstall.sh
|
||||
set -euo pipefail
|
||||
|
||||
GREEN="\033[92m"
|
||||
RED="\033[91m"
|
||||
CYAN="\033[96m"
|
||||
YELLOW="\033[93m"
|
||||
BOLD="\033[1m"
|
||||
RESET="\033[0m"
|
||||
|
||||
log() { echo -e "${GREEN}[+]${RESET} $*"; }
|
||||
warn() { echo -e "${YELLOW}[~]${RESET} $*"; }
|
||||
info() { echo -e "${CYAN}[i]${RESET} $*"; }
|
||||
|
||||
OS="$(uname -s)"
|
||||
IS_MACOS=false
|
||||
[ "$OS" = "Darwin" ] && IS_MACOS=true
|
||||
|
||||
sedi() {
|
||||
if $IS_MACOS; then
|
||||
sed -i '' "$@"
|
||||
else
|
||||
sed -i "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
if $IS_MACOS; then
|
||||
SCAN_DIRS="/Users"
|
||||
else
|
||||
SCAN_DIRS="/home"
|
||||
fi
|
||||
|
||||
echo -e "${BOLD}"
|
||||
echo " +--------------------------------------+"
|
||||
echo " | Qwen Code — Uninstaller |"
|
||||
echo " +--------------------------------------+"
|
||||
echo -e "${RESET}"
|
||||
|
||||
# ---- Uninstall npm package ----
|
||||
|
||||
if npm list -g @qwen-code/qwen-code &>/dev/null 2>&1; then
|
||||
info "Removing @qwen-code/qwen-code..."
|
||||
npm uninstall -g @qwen-code/qwen-code 2>/dev/null || true
|
||||
log "npm package removed"
|
||||
else
|
||||
warn "Qwen Code not found in npm global packages"
|
||||
fi
|
||||
|
||||
# ---- Remove settings ----
|
||||
|
||||
for user_home in /root $SCAN_DIRS/*; do
|
||||
QWEN_DIR="$user_home/.qwen"
|
||||
if [ -d "$QWEN_DIR" ]; then
|
||||
info "Removing $QWEN_DIR..."
|
||||
rm -rf "$QWEN_DIR"
|
||||
log "Removed $QWEN_DIR"
|
||||
fi
|
||||
done
|
||||
|
||||
# ---- Remove env vars from shell rc files ----
|
||||
|
||||
for user_home in /root $SCAN_DIRS/*; do
|
||||
for rc_file in "$user_home/.bashrc" "$user_home/.zshrc"; do
|
||||
if [ -f "$rc_file" ] && grep -q 'QWEN_API_KEY\|QWEN_BASE_URL\|Qwen Code\|Qwen env\|qwen-code-env' "$rc_file" 2>/dev/null; then
|
||||
info "Cleaning env vars from $rc_file..."
|
||||
sedi '/# Qwen Code/d' "$rc_file"
|
||||
sedi '/# Qwen env/d' "$rc_file"
|
||||
sedi '/qwen-code-env\.sh/d' "$rc_file"
|
||||
sedi '/QWEN_API_KEY/d' "$rc_file"
|
||||
sedi '/QWEN_BASE_URL/d' "$rc_file"
|
||||
log "Cleaned $rc_file"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# ---- Remove env files ----
|
||||
|
||||
for env_file in "/etc/profile.d/qwen-code.sh" "/etc/qwen-code-env.sh"; do
|
||||
if [ -f "$env_file" ]; then
|
||||
info "Removing $env_file..."
|
||||
rm -f "$env_file"
|
||||
log "Removed $env_file"
|
||||
fi
|
||||
done
|
||||
|
||||
# ---- Remove launchctl env vars (macOS) ----
|
||||
|
||||
if $IS_MACOS; then
|
||||
launchctl unsetenv QWEN_API_KEY 2>/dev/null || true
|
||||
launchctl unsetenv QWEN_BASE_URL 2>/dev/null || true
|
||||
log "launchctl env vars cleared"
|
||||
fi
|
||||
|
||||
# ---- Remove env vars from /etc/environment (Linux) ----
|
||||
|
||||
if [ -f "/etc/environment" ] && grep -q 'QWEN_API_KEY\|QWEN_BASE_URL' /etc/environment 2>/dev/null; then
|
||||
info "Cleaning /etc/environment..."
|
||||
sedi '/QWEN_API_KEY/d' /etc/environment
|
||||
sedi '/QWEN_BASE_URL/d' /etc/environment
|
||||
log "Cleaned /etc/environment"
|
||||
fi
|
||||
|
||||
# ---- Remove npm registry config ----
|
||||
|
||||
info "Removing npm registry config..."
|
||||
npm config delete @qwen-code:registry 2>/dev/null || true
|
||||
log "npm registry config removed"
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}${BOLD} Qwen Code fully uninstalled!${RESET}"
|
||||
echo ""
|
||||
|
||||
@@ -12,7 +12,23 @@ NPM_SCOPE="@qwen-code"
|
||||
NPM_PACKAGE="@qwen-code/qwen-code"
|
||||
REPO_RAW="https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen"
|
||||
|
||||
ENV_FILE="/etc/profile.d/qwen-code.sh"
|
||||
OS="$(uname -s)"
|
||||
IS_MACOS=false
|
||||
[ "$OS" = "Darwin" ] && IS_MACOS=true
|
||||
|
||||
if $IS_MACOS; then
|
||||
ENV_FILE="/etc/qwen-code-env.sh"
|
||||
else
|
||||
ENV_FILE="/etc/profile.d/qwen-code.sh"
|
||||
fi
|
||||
|
||||
sedi() {
|
||||
if $IS_MACOS; then
|
||||
sed -i '' "$@"
|
||||
else
|
||||
sed -i "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
GREEN="\033[92m"
|
||||
CYAN="\033[96m"
|
||||
@@ -133,21 +149,47 @@ fi
|
||||
API_KEY=$(python3 -c "import json; print(json.load(open('$TEMP_DIR/qwen_config.json'))['api_key'])")
|
||||
BASE_URL=$(python3 -c "import json; print(json.load(open('$TEMP_DIR/qwen_config.json'))['base_url'])")
|
||||
|
||||
ETC_ENV="/etc/environment"
|
||||
for kv in "QWEN_API_KEY=\"$API_KEY\"" "QWEN_BASE_URL=\"$BASE_URL\""; do
|
||||
KEY="${kv%%=*}"
|
||||
if grep -q "^${KEY}=" "$ETC_ENV" 2>/dev/null; then
|
||||
sed -i "s|^${KEY}=.*|${kv}|" "$ETC_ENV"
|
||||
else
|
||||
echo "$kv" >> "$ETC_ENV"
|
||||
fi
|
||||
done
|
||||
if $IS_MACOS; then
|
||||
launchctl setenv QWEN_API_KEY "$API_KEY" 2>/dev/null || true
|
||||
launchctl setenv QWEN_BASE_URL "$BASE_URL" 2>/dev/null || true
|
||||
|
||||
cat > "$ENV_FILE" << PROF_EOF
|
||||
cat > "$ENV_FILE" << ENVEOF
|
||||
export QWEN_API_KEY="$API_KEY"
|
||||
export QWEN_BASE_URL="$BASE_URL"
|
||||
ENVEOF
|
||||
chmod 644 "$ENV_FILE"
|
||||
|
||||
REAL_HOME="$HOME"
|
||||
if [ -n "${SUDO_USER:-}" ] && [ "$SUDO_USER" != "root" ]; then
|
||||
REAL_HOME=$(eval echo "~$SUDO_USER")
|
||||
fi
|
||||
for rc_file in "$REAL_HOME/.zshrc" "$REAL_HOME/.bashrc"; do
|
||||
if [ -f "$rc_file" ] || [ "$rc_file" = "$REAL_HOME/.zshrc" ]; then
|
||||
if [ -f "$rc_file" ]; then
|
||||
sedi '/# Qwen env/d' "$rc_file"
|
||||
sedi '/qwen-code-env\.sh/d' "$rc_file"
|
||||
fi
|
||||
echo "[ -f $ENV_FILE ] && . $ENV_FILE # Qwen env" >> "$rc_file"
|
||||
fi
|
||||
done
|
||||
else
|
||||
ETC_ENV="/etc/environment"
|
||||
for kv in "QWEN_API_KEY=\"$API_KEY\"" "QWEN_BASE_URL=\"$BASE_URL\""; do
|
||||
KEY="${kv%%=*}"
|
||||
if grep -q "^${KEY}=" "$ETC_ENV" 2>/dev/null; then
|
||||
sedi "s|^${KEY}=.*|${kv}|" "$ETC_ENV"
|
||||
else
|
||||
echo "$kv" >> "$ETC_ENV"
|
||||
fi
|
||||
done
|
||||
|
||||
mkdir -p /etc/profile.d
|
||||
cat > "$ENV_FILE" << PROF_EOF
|
||||
export QWEN_API_KEY="$API_KEY"
|
||||
export QWEN_BASE_URL="$BASE_URL"
|
||||
PROF_EOF
|
||||
chmod 644 "$ENV_FILE"
|
||||
chmod 644 "$ENV_FILE"
|
||||
fi
|
||||
|
||||
# ---- Create wrapper (auto-loads env) ----
|
||||
|
||||
|
||||
Reference in New Issue
Block a user