clawd/scripts/check-updates.sh

74 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# Check and update Claude Code and inou MCP bundle
set -e
echo "=== Claude Code Update Check ==="
CURRENT=$(claude --version 2>/dev/null | head -1 || echo "not installed")
echo "Current: $CURRENT"
LATEST=$(npm show @anthropic-ai/claude-code version 2>/dev/null || echo "unknown")
echo "Latest: $LATEST"
if [ "$CURRENT" != "$LATEST (Claude Code)" ] && [ "$LATEST" != "unknown" ]; then
echo "Updating Claude Code..."
npm update -g @anthropic-ai/claude-code
echo "Updated to: $(claude --version)"
else
echo "Claude Code is up to date"
fi
echo ""
echo "=== inou MCP Bundle Check ==="
MCPB_PATH="/home/johan/clawd/inou.mcpb"
MCPB_EXTRACT="/home/johan/clawd/inou-mcp"
# Get current version
if [ -f "$MCPB_EXTRACT/manifest.json" ]; then
CURRENT_VER=$(grep -o '"version": *"[^"]*"' "$MCPB_EXTRACT/manifest.json" | cut -d'"' -f4)
echo "Current: $CURRENT_VER"
else
CURRENT_VER="not installed"
echo "Current: not installed"
fi
# Check if download URL is available
MCPB_URL="https://inou.com/download/inou.mcpb"
HTTP_STATUS=$(curl -sI -o /dev/null -w "%{http_code}" "$MCPB_URL" 2>/dev/null || echo "000")
if [ "$HTTP_STATUS" != "200" ]; then
echo "Latest: (download not available - HTTP $HTTP_STATUS)"
echo "Skipping inou MCP bundle update check"
exit 0
fi
# Download latest
TMP_MCPB="/tmp/inou-new.mcpb"
curl -sL -o "$TMP_MCPB" "$MCPB_URL"
# Verify it's a valid zip
if ! python3 -c "import zipfile; zipfile.ZipFile('$TMP_MCPB')" 2>/dev/null; then
echo "Downloaded file is not a valid zip - skipping"
rm -f "$TMP_MCPB"
exit 0
fi
# Extract version from downloaded
TMP_DIR=$(mktemp -d)
python3 -c "import zipfile; zipfile.ZipFile('$TMP_MCPB').extractall('$TMP_DIR')"
NEW_VER=$(grep -o '"version": *"[^"]*"' "$TMP_DIR/manifest.json" | cut -d'"' -f4)
echo "Latest: $NEW_VER"
if [ "$CURRENT_VER" != "$NEW_VER" ]; then
echo "Updating inou MCP bundle..."
mv "$TMP_MCPB" "$MCPB_PATH"
rm -rf "$MCPB_EXTRACT"
mkdir -p "$MCPB_EXTRACT"
python3 -c "import zipfile; zipfile.ZipFile('$MCPB_PATH').extractall('$MCPB_EXTRACT')"
echo "Updated to: $NEW_VER"
else
echo "inou MCP bundle is up to date"
fi
rm -rf "$TMP_DIR" "$TMP_MCPB" 2>/dev/null || true