refactor: Simplify startup - user manages containers and MCP
Changes: - Delete cfg/setup-claude.sh (MCP setup now manual) - Remove restore container creation (user manages backups) - Remove workspace auto-entry from .zshrc - Remove MCP auto-registration - Change ai user .zshrc to run claude once on login (not exec) - User now manually starts containers and registers MCP as needed New flow: 1. ai user auto-login 2. claude starts once (not exec, returns to shell after exit) 3. User manually starts workspace container if needed 4. User manually registers MCP servers
This commit is contained in:
@@ -86,14 +86,7 @@ bash ./cfg/setup-user.sh
|
|||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# ============================================
|
# ============================================
|
||||||
# 3. Claude & aigpt Setup
|
# 3. Create workspace container (after all configuration)
|
||||||
# ============================================
|
|
||||||
|
|
||||||
bash ./cfg/setup-claude.sh
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# ============================================
|
|
||||||
# 4. Create child containers (after all configuration)
|
|
||||||
# ============================================
|
# ============================================
|
||||||
|
|
||||||
bash ./cfg/user-continer.sh
|
bash ./cfg/user-continer.sh
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Claude Code MCP setup for aios
|
|
||||||
# Configures MCP, sets up shared memory
|
|
||||||
|
|
||||||
ROOTFS="root.x86_64"
|
|
||||||
|
|
||||||
echo "=== Claude MCP Setup ==="
|
|
||||||
|
|
||||||
# Setup Claude Code MCP configuration (shared via symlink)
|
|
||||||
echo "Configuring MCP..."
|
|
||||||
# Create actual config in syui/ai/claude (bind-mounted)
|
|
||||||
arch-chroot $ROOTFS /bin/sh -c 'mkdir -p /root/.config/syui/ai/claude'
|
|
||||||
cat > $ROOTFS/root/.config/syui/ai/claude/claude_desktop_config.json <<'EOF'
|
|
||||||
{
|
|
||||||
"mcpServers": {
|
|
||||||
"aigpt": {
|
|
||||||
"command": "aigpt",
|
|
||||||
"args": ["server", "--enable-layer4"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Create symlink for root
|
|
||||||
arch-chroot $ROOTFS /bin/sh -c 'ln -sf /root/.config/syui/ai/claude /root/.config/claude'
|
|
||||||
|
|
||||||
# Setup for ai user too
|
|
||||||
arch-chroot $ROOTFS /bin/sh -c 'mkdir -p /home/ai/.config/syui/ai/claude'
|
|
||||||
arch-chroot $ROOTFS /bin/sh -c 'cp /root/.config/syui/ai/claude/claude_desktop_config.json /home/ai/.config/syui/ai/claude/'
|
|
||||||
arch-chroot $ROOTFS /bin/sh -c 'ln -sf /home/ai/.config/syui/ai/claude /home/ai/.config/claude'
|
|
||||||
arch-chroot $ROOTFS /bin/sh -c 'chown -R ai:ai /home/ai/.config/syui'
|
|
||||||
|
|
||||||
# Create config directory
|
|
||||||
arch-chroot $ROOTFS /bin/sh -c 'mkdir -p /root/.config/syui/ai/gpt'
|
|
||||||
|
|
||||||
# Copy MCP and aios configuration
|
|
||||||
echo "Copying configuration files..."
|
|
||||||
cp -rf ./cfg/mcp.json $ROOTFS/root/.config/syui/ai/mcp.json
|
|
||||||
cp -rf ./cfg/config.toml $ROOTFS/root/.config/syui/ai/config.toml
|
|
||||||
|
|
||||||
# Initialize aigpt database with WAL mode
|
|
||||||
echo "Initializing aigpt database..."
|
|
||||||
arch-chroot $ROOTFS /bin/sh -c 'aigpt server --enable-layer4 &'
|
|
||||||
sleep 2
|
|
||||||
arch-chroot $ROOTFS /bin/sh -c 'pkill aigpt'
|
|
||||||
arch-chroot $ROOTFS /bin/sh -c 'if command -v sqlite3 &>/dev/null; then sqlite3 /root/.config/syui/ai/gpt/memory.db "PRAGMA journal_mode=WAL; PRAGMA synchronous=NORMAL;"; fi'
|
|
||||||
|
|
||||||
# Note: claude auto-start is configured in ai user's .zshrc (shared with workspace root via bind mount)
|
|
||||||
|
|
||||||
echo "✓ Claude MCP setup complete"
|
|
||||||
@@ -61,30 +61,14 @@ cp -rf ./cfg/zshrc $ROOTFS/root/.zshrc
|
|||||||
# Copy .zshrc for user 'ai'
|
# Copy .zshrc for user 'ai'
|
||||||
cp -rf ./cfg/zshrc $ROOTFS/home/ai/.zshrc
|
cp -rf ./cfg/zshrc $ROOTFS/home/ai/.zshrc
|
||||||
|
|
||||||
# Add workspace container auto-start and entry (shared .zshrc for ai user and workspace root)
|
# Add claude auto-start on login (once, not exec)
|
||||||
cat >> $ROOTFS/home/ai/.zshrc <<'EOF'
|
cat >> $ROOTFS/home/ai/.zshrc <<'EOF'
|
||||||
|
|
||||||
# MCP auto-setup (run once after .claude.json is created)
|
# Start claude on login (once)
|
||||||
if [[ -f ~/.claude.json ]] && ! grep -q '"aigpt"' ~/.claude.json 2>/dev/null; then
|
|
||||||
if command -v claude &>/dev/null && command -v aigpt &>/dev/null; then
|
|
||||||
claude mcp add aigpt aigpt server &>/dev/null || true
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# aios concept: container from start (ai user and workspace root share this .zshrc)
|
|
||||||
if [[ -o login ]] && [[ -o interactive ]]; then
|
if [[ -o login ]] && [[ -o interactive ]]; then
|
||||||
if [[ -z "$INSIDE_WORKSPACE" ]]; then
|
|
||||||
# Running as ai user on aios OS - enter workspace container
|
|
||||||
export INSIDE_WORKSPACE=1
|
|
||||||
sudo machinectl start workspace 2>/dev/null || true
|
|
||||||
sleep 1
|
|
||||||
exec sudo machinectl shell workspace
|
|
||||||
else
|
|
||||||
# Running as root inside workspace container - start claude
|
|
||||||
if command -v claude &>/dev/null; then
|
if command -v claude &>/dev/null; then
|
||||||
claude
|
claude
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Create child containers inside aios for ai user
|
# Create workspace container inside aios for ai user
|
||||||
# Backup aios before creating /var/lib/machines to avoid recursion
|
# Backup aios before creating /var/lib/machines to avoid recursion
|
||||||
|
|
||||||
ROOTFS="root.x86_64"
|
ROOTFS="root.x86_64"
|
||||||
|
|
||||||
echo "=== Creating child containers ==="
|
echo "=== Creating workspace container ==="
|
||||||
|
|
||||||
# Backup current aios to temp location (before creating /var/lib/machines)
|
# Backup current aios to temp location (before creating /var/lib/machines)
|
||||||
echo "Backing up aios..."
|
echo "Backing up aios..."
|
||||||
@@ -17,11 +17,7 @@ mkdir -p $ROOTFS/var/lib/machines
|
|||||||
echo "Creating workspace container..."
|
echo "Creating workspace container..."
|
||||||
cp -a /tmp/aios-backup-$$ $ROOTFS/var/lib/machines/workspace
|
cp -a /tmp/aios-backup-$$ $ROOTFS/var/lib/machines/workspace
|
||||||
|
|
||||||
# Copy backup as restore
|
|
||||||
echo "Creating restore container..."
|
|
||||||
cp -a /tmp/aios-backup-$$ $ROOTFS/var/lib/machines/restore
|
|
||||||
|
|
||||||
# Cleanup temp backup
|
# Cleanup temp backup
|
||||||
rm -rf /tmp/aios-backup-$$
|
rm -rf /tmp/aios-backup-$$
|
||||||
|
|
||||||
echo "✓ Child containers created"
|
echo "✓ Workspace container created"
|
||||||
|
|||||||
Reference in New Issue
Block a user