- gemini/ugemini_update.sh + .ps1 - codex/ucodex_update.sh + .ps1 - qwen/uqwen_update.sh + .ps1 - README.md: added Update section with one-line and cloned-repo commands - README.md: removed outdated Codex update instructions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
104 lines
3.3 KiB
Bash
104 lines
3.3 KiB
Bash
#!/usr/bin/env bash
|
|
# Codex CLI — Updater
|
|
# Downloads latest binary from GitHub + re-applies config patches.
|
|
#
|
|
# Usage: sudo bash ucodex_update.sh
|
|
set -euo pipefail
|
|
|
|
REPO_RAW="https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/codex"
|
|
GITHUB_API="https://api.github.com/repos/openai/codex/releases/latest"
|
|
|
|
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 " | Codex CLI — Updater |"
|
|
echo " +--------------------------------------+"
|
|
echo -e "${RESET}"
|
|
|
|
# ---- Check current version ----
|
|
|
|
OLD_VER="not installed"
|
|
if command -v codex &>/dev/null; then
|
|
OLD_VER=$(codex --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || echo "unknown")
|
|
info "Current version: $OLD_VER"
|
|
fi
|
|
|
|
# ---- Get latest version ----
|
|
|
|
info "Checking latest version..."
|
|
LATEST_VER=$(curl -s "$GITHUB_API" | grep -oP '"tag_name":\s*"rust-v\K[0-9]+\.[0-9]+\.[0-9]+' | head -1)
|
|
|
|
if [ -z "$LATEST_VER" ]; then
|
|
err "Could not fetch latest version from GitHub"
|
|
exit 1
|
|
fi
|
|
info "Latest version: $LATEST_VER"
|
|
|
|
if [ "$OLD_VER" = "$LATEST_VER" ]; then
|
|
log "Already up to date ($LATEST_VER)"
|
|
else
|
|
# ---- Download binary ----
|
|
ARCH=$(uname -m)
|
|
case "$ARCH" in
|
|
x86_64) BINARY_SUFFIX="x86_64-unknown-linux-musl" ;;
|
|
aarch64|arm64) BINARY_SUFFIX="aarch64-unknown-linux-musl" ;;
|
|
*) err "Unsupported architecture: $ARCH"; exit 1 ;;
|
|
esac
|
|
|
|
DOWNLOAD_URL="https://github.com/openai/codex/releases/download/rust-v${LATEST_VER}/codex-${BINARY_SUFFIX}.tar.gz"
|
|
TEMP_DIR=$(mktemp -d)
|
|
|
|
info "Downloading codex-${BINARY_SUFFIX}..."
|
|
curl -L -# -o "$TEMP_DIR/codex.tar.gz" "$DOWNLOAD_URL"
|
|
tar -xzf "$TEMP_DIR/codex.tar.gz" -C "$TEMP_DIR"
|
|
|
|
# Find binary
|
|
BINARY_FILE=$(find "$TEMP_DIR" -maxdepth 1 -name 'codex*' -type f ! -name '*.gz' | head -1)
|
|
if [ -z "$BINARY_FILE" ]; then
|
|
err "Binary not found in archive"
|
|
rm -rf "$TEMP_DIR"
|
|
exit 1
|
|
fi
|
|
|
|
# Kill running processes
|
|
pkill -9 -x "codex" 2>/dev/null || true
|
|
|
|
# Install
|
|
CODEX_PATH=$(which codex 2>/dev/null || echo "/usr/local/bin/codex")
|
|
chmod +x "$BINARY_FILE"
|
|
mv -f "$BINARY_FILE" "$CODEX_PATH"
|
|
rm -rf "$TEMP_DIR"
|
|
hash -r 2>/dev/null || true
|
|
|
|
NEW_VER=$(codex --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || echo "unknown")
|
|
log "Binary updated: $OLD_VER → $NEW_VER"
|
|
fi
|
|
|
|
# ---- Download and apply patches ----
|
|
|
|
PATCH_DIR=$(mktemp -d)
|
|
cleanup() { rm -rf "$PATCH_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/codex_patcher.py" -o "$PATCH_DIR/codex_patcher.py"
|
|
curl -fsSL -H "Authorization: token ${GITEA_TOKEN}" "$REPO_RAW/codex_config.json" -o "$PATCH_DIR/codex_config.json"
|
|
|
|
info "Applying patches..."
|
|
python3 "$PATCH_DIR/codex_patcher.py" --apply --config "$PATCH_DIR/codex_config.json"
|
|
|
|
log "Update complete!"
|
|
echo ""
|