Compare commits
35 Commits
e0e012da9e
...
66a95b912b
| Author | SHA1 | Date | |
|---|---|---|---|
|
66a95b912b
|
|||
|
|
68817ba8de | ||
|
|
4352a7d0e3 | ||
|
|
b41052b9a8 | ||
|
|
100471646e | ||
|
|
5264e9866c | ||
|
|
1ca53c489c | ||
|
|
d1c3ab94cb | ||
|
|
fd25a50395 | ||
|
|
642ccb28a6 | ||
|
|
d575a489ce | ||
|
|
e2b0d7a51d | ||
|
|
1aab33cb04 | ||
|
|
cdf38812fc | ||
|
|
abdb399552 | ||
|
|
49da9ec86a | ||
|
|
e88b241519 | ||
|
|
a35a6bc870 | ||
|
|
a447cb98f0 | ||
|
|
a833a60bac | ||
|
|
7b889fd5a2 | ||
|
|
87738e1e0b | ||
|
|
19337566a9 | ||
|
|
fb31108cf7 | ||
|
|
355c3dceb4 | ||
|
|
511cf960d6 | ||
|
|
506b93b5f4 | ||
|
|
d65b1242fe | ||
|
|
7abf48a8fd | ||
|
|
4caa0bbbc6 | ||
|
|
a66d080a30 | ||
|
|
5f4384d812 | ||
|
|
74f6eea1a3 | ||
|
|
ea207bedd5 | ||
|
|
4cbc1562f5 |
86
.github/workflows/release.yml
vendored
86
.github/workflows/release.yml
vendored
@@ -2,8 +2,8 @@ name: release
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
branches:
|
||||||
- 'v*'
|
- main
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -24,84 +24,12 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Initialize
|
|
||||||
run: |
|
|
||||||
pacman -Syuu --noconfirm base-devel archiso docker git nodejs bc
|
|
||||||
git clone https://gitlab.archlinux.org/archlinux/archiso
|
|
||||||
cp -rf ./cfg/profiledef.sh /usr/share/archiso/configs/releng/
|
|
||||||
cp -rf ./cfg/profiledef.sh ./archiso/configs/releng/profiledef.sh
|
|
||||||
cp -rf ./cfg/profiledef.sh ./archiso/configs/baseline/profiledef.sh
|
|
||||||
cp -rf ./scpt/mkarchiso ./archiso/archiso/mkarchiso
|
|
||||||
./archiso/archiso/mkarchiso -v -o ./ ./archiso/configs/releng/
|
|
||||||
tar xf aios-bootstrap*.tar.gz
|
|
||||||
mkdir -p root.x86_64/var/lib/machines/arch
|
|
||||||
pacstrap -c root.x86_64/var/lib/machines/arch base
|
|
||||||
echo -e 'Server = http://mirrors.cat.net/archlinux/$repo/os/$arch
|
|
||||||
Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch' >> ./root.x86_64/var/lib/machines/arch/etc/pacman.d/mirrorlist
|
|
||||||
sed -i s/CheckSpace/#CheckeSpace/ root.x86_64/var/lib/machines/arch/etc/pacman.conf
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'pacman-key --init'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'pacman-key --populate archlinux'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'pacman -Syu --noconfirm base base-devel linux vim git zsh rust openssh openssl jq go nodejs npm docker podman bc sqlite'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /etc/containers/registries.conf.d'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'curl -sL -o /etc/containers/registries.conf.d/ai.conf https://git.syui.ai/ai/os/raw/branch/main/cfg/ai.conf'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chsh -s /bin/zsh'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'npm i -g @anthropic-ai/claude-code'
|
|
||||||
cp -rf ./cfg/os-release root.x86_64/var/lib/machines/arch/etc/os-release
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'useradd -m -G wheel -s /bin/zsh ai'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'echo "ai:root" | chpasswd'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'echo "%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/pacman -Syu --noconfirm, /usr/bin/rm -rf /var/lib/pacman/db.lck, /usr/bin/poweroff, /usr/bin/reboot, /usr/bin/machinectl" >> /etc/sudoers'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /etc/systemd/system/getty@tty1.service.d'
|
|
||||||
cat > root.x86_64/var/lib/machines/arch/etc/systemd/system/getty@tty1.service.d/override.conf <<'EOF'
|
|
||||||
[Service]
|
|
||||||
ExecStart=
|
|
||||||
ExecStart=-/usr/bin/agetty --autologin ai --noclear %I $TERM
|
|
||||||
EOF
|
|
||||||
cp -rf ./cfg/zshrc root.x86_64/var/lib/machines/arch/root/.zshrc
|
|
||||||
cp -rf ./cfg/zshrc root.x86_64/var/lib/machines/arch/home/ai/.zshrc
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chown ai:ai /home/ai/.zshrc'
|
|
||||||
cp -rf ./cfg/aios.zsh root.x86_64/var/lib/machines/arch/usr/local/bin/aios-startup
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chmod +x /usr/local/bin/aios-startup'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /home/ai/.config/syui/ai/os'
|
|
||||||
cat > root.x86_64/var/lib/machines/arch/home/ai/.config/syui/ai/os/config.json <<'EOF'
|
|
||||||
{
|
|
||||||
"shell": false
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chown -R ai:ai /home/ai/.config'
|
|
||||||
cat >> root.x86_64/var/lib/machines/arch/home/ai/.zshrc <<'EOF'
|
|
||||||
|
|
||||||
# aios startup
|
- name: Build aios
|
||||||
source /usr/local/bin/aios-startup
|
run: bash ./build.zsh
|
||||||
EOF
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'git clone https://git.syui.ai/ai/gpt && cd gpt && cargo build --release && cp -rf ./target/release/aigpt /bin/'
|
- name: Create Docker images
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /root/.config/syui/ai/claude'
|
run: |
|
||||||
cat > root.x86_64/var/lib/machines/arch/root/.config/syui/ai/claude/claude_desktop_config.json <<'EOF'
|
|
||||||
{
|
|
||||||
"mcpServers": {
|
|
||||||
"aigpt": {
|
|
||||||
"command": "aigpt",
|
|
||||||
"args": ["server", "--enable-layer4"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'ln -sf /root/.config/syui/ai/claude /root/.config/claude'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /home/ai/.config/syui/ai/claude'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'cp /root/.config/syui/ai/claude/claude_desktop_config.json /home/ai/.config/syui/ai/claude/'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'ln -sf /home/ai/.config/syui/ai/claude /home/ai/.config/claude'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chown -R ai:ai /home/ai/.config/syui'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'git clone https://git.syui.ai/ai/bot && cd bot && cargo build && cp -rf ./target/debug/ai /bin/ && ai ai'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /root/.config/syui/ai/gpt'
|
|
||||||
cp -rf ./cfg/mcp.json root.x86_64/var/lib/machines/arch/root/.config/syui/ai/mcp.json
|
|
||||||
cp -rf ./cfg/config.toml root.x86_64/var/lib/machines/arch/root/.config/syui/ai/config.toml
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'aigpt server --enable-layer4 &'
|
|
||||||
sleep 2
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'pkill aigpt'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /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'
|
|
||||||
cp -rf ./cfg/aios-ctl.zsh root.x86_64/var/lib/machines/arch/opt/aios-ctl.zsh
|
|
||||||
cp -rf ./cfg/install.sh ./install.sh
|
|
||||||
chmod +x ./install.sh
|
|
||||||
tar -zcvf aios-bootstrap.tar.gz root.x86_64/ install.sh
|
|
||||||
tar -C ./root.x86_64 -c . | docker import - ${{ env.IMAGE_NAME }}
|
tar -C ./root.x86_64 -c . | docker import - ${{ env.IMAGE_NAME }}
|
||||||
echo "${{ env.DOCKER_TOKEN }}" | docker login -u syui --password-stdin
|
echo "${{ env.DOCKER_TOKEN }}" | docker login -u syui --password-stdin
|
||||||
docker push ${{ env.IMAGE_NAME }}
|
docker push ${{ env.IMAGE_NAME }}
|
||||||
|
|||||||
175
build.zsh
175
build.zsh
@@ -1,119 +1,122 @@
|
|||||||
#!/bin/zsh
|
#!/bin/zsh
|
||||||
|
# aios build script
|
||||||
|
# 1. Build minimal Arch Linux base
|
||||||
|
# 2. Setup user (ai) and shell
|
||||||
|
# 3. Setup Claude Code and aigpt
|
||||||
|
|
||||||
|
echo "=== aios build ==="
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Clean up previous build artifacts
|
||||||
|
echo "Cleaning up previous build..."
|
||||||
|
rm -rf root.x86_64/ archiso/ install.sh
|
||||||
|
rm -f aios-bootstrap*.tar.gz 2>/dev/null || true
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# 1. Arch Linux Base Construction
|
||||||
|
# ============================================
|
||||||
|
|
||||||
|
echo "=== Step 1: Arch Linux Base ==="
|
||||||
|
|
||||||
|
# Install build dependencies
|
||||||
pacman -Syuu --noconfirm base-devel archiso docker git nodejs bc
|
pacman -Syuu --noconfirm base-devel archiso docker git nodejs bc
|
||||||
|
|
||||||
|
# Clone archiso
|
||||||
git clone https://gitlab.archlinux.org/archlinux/archiso
|
git clone https://gitlab.archlinux.org/archlinux/archiso
|
||||||
|
|
||||||
|
# Copy configuration
|
||||||
cp -rf ./cfg/profiledef.sh /usr/share/archiso/configs/releng/
|
cp -rf ./cfg/profiledef.sh /usr/share/archiso/configs/releng/
|
||||||
cp -rf ./cfg/profiledef.sh ./archiso/configs/releng/profiledef.sh
|
cp -rf ./cfg/profiledef.sh ./archiso/configs/releng/profiledef.sh
|
||||||
cp -rf ./cfg/profiledef.sh ./archiso/configs/baseline/profiledef.sh
|
cp -rf ./cfg/profiledef.sh ./archiso/configs/baseline/profiledef.sh
|
||||||
cp -rf ./scpt/mkarchiso ./archiso/archiso/mkarchiso
|
cp -rf ./scpt/mkarchiso ./archiso/archiso/mkarchiso
|
||||||
|
|
||||||
|
# Build bootstrap
|
||||||
./archiso/archiso/mkarchiso -v -o ./ ./archiso/configs/releng/
|
./archiso/archiso/mkarchiso -v -o ./ ./archiso/configs/releng/
|
||||||
|
|
||||||
|
# Extract and prepare
|
||||||
tar xf aios-bootstrap*.tar.gz
|
tar xf aios-bootstrap*.tar.gz
|
||||||
mkdir -p root.x86_64/var/lib/machines/arch
|
mkdir -p root.x86_64
|
||||||
pacstrap -c root.x86_64/var/lib/machines/arch base
|
pacstrap -c root.x86_64 base
|
||||||
|
|
||||||
|
# Configure pacman
|
||||||
echo -e 'Server = http://mirrors.cat.net/archlinux/$repo/os/$arch
|
echo -e 'Server = http://mirrors.cat.net/archlinux/$repo/os/$arch
|
||||||
Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch' >> ./root.x86_64/var/lib/machines/arch/etc/pacman.d/mirrorlist
|
Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch' >> ./root.x86_64/etc/pacman.d/mirrorlist
|
||||||
sed -i s/CheckSpace/#CheckeSpace/ root.x86_64/var/lib/machines/arch/etc/pacman.conf
|
sed -i s/CheckSpace/#CheckeSpace/ root.x86_64/etc/pacman.conf
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'pacman-key --init'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'pacman-key --populate archlinux'
|
# Initialize pacman keys
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'pacman -Syu --noconfirm base base-devel linux vim git zsh rust openssh openssl jq go nodejs npm docker podman bc sqlite'
|
arch-chroot root.x86_64 /bin/sh -c 'pacman-key --init'
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /etc/containers/registries.conf.d'
|
arch-chroot root.x86_64 /bin/sh -c 'pacman-key --populate archlinux'
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'curl -sL -o /etc/containers/registries.conf.d/ai.conf https://git.syui.ai/ai/os/raw/branch/main/cfg/ai.conf'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chsh -s /bin/zsh'
|
# Install base packages (including systemd-container for machinectl)
|
||||||
|
arch-chroot root.x86_64 /bin/sh -c 'pacman -Syu --noconfirm base base-devel linux vim git zsh rust openssh openssl jq go nodejs npm docker podman bc sqlite systemd arch-install-scripts'
|
||||||
|
|
||||||
|
# Configure containers
|
||||||
|
arch-chroot root.x86_64 /bin/sh -c 'mkdir -p /etc/containers/registries.conf.d'
|
||||||
|
arch-chroot root.x86_64 /bin/sh -c 'curl -sL -o /etc/containers/registries.conf.d/ai.conf https://git.syui.ai/ai/os/raw/branch/main/cfg/ai.conf'
|
||||||
|
|
||||||
|
# Set default shell
|
||||||
|
arch-chroot root.x86_64 /bin/sh -c 'chsh -s /bin/zsh'
|
||||||
|
|
||||||
# Install Claude Code
|
# Install Claude Code
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'npm i -g @anthropic-ai/claude-code'
|
arch-chroot root.x86_64 /bin/sh -c 'npm i -g @anthropic-ai/claude-code'
|
||||||
|
|
||||||
# Copy os-release
|
# Copy os-release
|
||||||
cp -rf ./cfg/os-release root.x86_64/var/lib/machines/arch/etc/os-release
|
cp -rf ./cfg/os-release root.x86_64/etc/os-release
|
||||||
|
|
||||||
# Create default user 'ai'
|
# Configure sudoers for wheel group
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'useradd -m -G wheel -s /bin/zsh ai'
|
echo "Configuring sudoers..."
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'echo "ai:root" | chpasswd'
|
arch-chroot root.x86_64 /bin/sh -c 'echo "%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/pacman, /usr/bin/pacstrap, /usr/bin/arch-chroot, /usr/bin/rm, /usr/bin/mkdir, /usr/bin/mv, /usr/bin/cp, /usr/bin/poweroff, /usr/bin/reboot, /usr/bin/machinectl, /bin/bash" >> /etc/sudoers'
|
||||||
|
|
||||||
# Enable wheel group for sudo (specific commands without password)
|
# Install aigpt (aios core package)
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'echo "%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/pacman -Syu --noconfirm, /usr/bin/rm -rf /var/lib/pacman/db.lck, /usr/bin/poweroff, /usr/bin/reboot, /usr/bin/machinectl" >> /etc/sudoers'
|
echo "Installing aigpt..."
|
||||||
|
arch-chroot root.x86_64 /bin/sh -c 'git clone https://git.syui.ai/ai/gpt && cd gpt && cargo build --release && cp -rf ./target/release/aigpt /bin/'
|
||||||
|
|
||||||
# Setup auto-login for user 'ai'
|
# Install aibot (aios core package)
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /etc/systemd/system/getty@tty1.service.d'
|
echo "Installing aibot..."
|
||||||
cat > root.x86_64/var/lib/machines/arch/etc/systemd/system/getty@tty1.service.d/override.conf <<'EOF'
|
arch-chroot root.x86_64 /bin/sh -c 'git clone https://git.syui.ai/ai/bot && cd bot && cargo build && cp -rf ./target/debug/aibot /bin/ && aibot ai'
|
||||||
[Service]
|
|
||||||
ExecStart=
|
|
||||||
ExecStart=-/usr/bin/agetty --autologin ai --noclear %I $TERM
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Copy .zshrc for root
|
echo "✓ Arch Linux base complete"
|
||||||
cp -rf ./cfg/zshrc root.x86_64/var/lib/machines/arch/root/.zshrc
|
echo ""
|
||||||
|
|
||||||
# Copy .zshrc for user 'ai'
|
# ============================================
|
||||||
cp -rf ./cfg/zshrc root.x86_64/var/lib/machines/arch/home/ai/.zshrc
|
# 2. User Setup
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chown ai:ai /home/ai/.zshrc'
|
# ============================================
|
||||||
|
|
||||||
# Copy aios startup script
|
bash ./cfg/setup-user.sh
|
||||||
cp -rf ./cfg/aios.zsh root.x86_64/var/lib/machines/arch/usr/local/bin/aios-startup
|
echo ""
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chmod +x /usr/local/bin/aios-startup'
|
|
||||||
|
|
||||||
# Create default config directory and file for user 'ai'
|
# ============================================
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /home/ai/.config/syui/ai/os'
|
# 3. Claude & aigpt Setup
|
||||||
cat > root.x86_64/var/lib/machines/arch/home/ai/.config/syui/ai/os/config.json <<'EOF'
|
# ============================================
|
||||||
{
|
|
||||||
"shell": false
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chown -R ai:ai /home/ai/.config'
|
|
||||||
|
|
||||||
# Update .zshrc to source startup script
|
bash ./cfg/setup-claude.sh
|
||||||
cat >> root.x86_64/var/lib/machines/arch/home/ai/.zshrc <<'EOF'
|
echo ""
|
||||||
|
|
||||||
# aios startup
|
# ============================================
|
||||||
source /usr/local/bin/aios-startup
|
# 4. Create child containers (after all configuration)
|
||||||
EOF
|
# ============================================
|
||||||
|
|
||||||
# Install aigpt (AI memory system)
|
bash ./cfg/user-continer.sh
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'git clone https://git.syui.ai/ai/gpt && cd gpt && cargo build --release && cp -rf ./target/release/aigpt /bin/'
|
echo ""
|
||||||
|
|
||||||
# Setup Claude Code MCP configuration (shared via symlink)
|
# ============================================
|
||||||
# Create actual config in syui/ai/claude (bind-mounted)
|
# Finalize
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /root/.config/syui/ai/claude'
|
# ============================================
|
||||||
cat > root.x86_64/var/lib/machines/arch/root/.config/syui/ai/claude/claude_desktop_config.json <<'EOF'
|
|
||||||
{
|
|
||||||
"mcpServers": {
|
|
||||||
"aigpt": {
|
|
||||||
"command": "aigpt",
|
|
||||||
"args": ["server", "--enable-layer4"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Create symlink for root
|
echo "=== Finalizing ==="
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'ln -sf /root/.config/syui/ai/claude /root/.config/claude'
|
|
||||||
|
|
||||||
# Setup for ai user too
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /home/ai/.config/syui/ai/claude'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'cp /root/.config/syui/ai/claude/claude_desktop_config.json /home/ai/.config/syui/ai/claude/'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'ln -sf /home/ai/.config/syui/ai/claude /home/ai/.config/claude'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chown -R ai:ai /home/ai/.config/syui'
|
|
||||||
|
|
||||||
# Install ai/bot (optional, for backward compatibility)
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'git clone https://git.syui.ai/ai/bot && cd bot && cargo build && cp -rf ./target/debug/ai /bin/ && ai ai'
|
|
||||||
|
|
||||||
# Create config directory
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /root/.config/syui/ai/gpt'
|
|
||||||
|
|
||||||
# Copy MCP and aios configuration
|
|
||||||
cp -rf ./cfg/mcp.json root.x86_64/var/lib/machines/arch/root/.config/syui/ai/mcp.json
|
|
||||||
cp -rf ./cfg/config.toml root.x86_64/var/lib/machines/arch/root/.config/syui/ai/config.toml
|
|
||||||
|
|
||||||
# Initialize aigpt database with WAL mode
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'aigpt server --enable-layer4 &'
|
|
||||||
sleep 2
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'pkill aigpt'
|
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /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'
|
|
||||||
|
|
||||||
# Copy aios-ctl.zsh for host machine control
|
# Copy aios-ctl.zsh for host machine control
|
||||||
cp -rf ./cfg/aios-ctl.zsh root.x86_64/var/lib/machines/arch/opt/aios-ctl.zsh
|
cp -rf ./cfg/aios-ctl.zsh root.x86_64/opt/aios-ctl.zsh
|
||||||
|
|
||||||
# Copy install script to root for easy access
|
# Copy install script
|
||||||
cp -rf ./cfg/install.sh ./install.sh
|
cp -rf ./cfg/install.sh ./install.sh
|
||||||
chmod +x ./install.sh
|
chmod +x ./install.sh
|
||||||
|
|
||||||
|
# Create tarball with aios (includes child containers)
|
||||||
|
echo "Creating tarball..."
|
||||||
tar -zcvf aios-bootstrap.tar.gz root.x86_64/ install.sh
|
tar -zcvf aios-bootstrap.tar.gz root.x86_64/ install.sh
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== Build Complete ==="
|
||||||
|
echo "Output: aios-bootstrap.tar.gz"
|
||||||
|
echo ""
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ function aios-shell() {
|
|||||||
sudo machinectl shell $NAME
|
sudo machinectl shell $NAME
|
||||||
}
|
}
|
||||||
|
|
||||||
# Login to aios container
|
# Login to aios container as ai user
|
||||||
function aios-login() {
|
function aios-login() {
|
||||||
sudo machinectl login $NAME
|
sudo machinectl shell $NAME /bin/su - ai
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create backup of current aios
|
# Create backup of current aios
|
||||||
|
|||||||
109
cfg/install.sh
109
cfg/install.sh
@@ -1,118 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# aios installation script
|
# aios installation script
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
NAME="aios"
|
NAME="aios"
|
||||||
BACKUP="${NAME}back"
|
|
||||||
TARBALL="aios-bootstrap.tar.gz"
|
TARBALL="aios-bootstrap.tar.gz"
|
||||||
|
|
||||||
echo "=== aios installation ==="
|
echo "=== aios installation ==="
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Check if running as root
|
# Extract and install
|
||||||
if [ "$EUID" -ne 0 ]; then
|
|
||||||
echo "Error: This script must be run as root"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if tarball exists
|
|
||||||
if [ ! -f "$TARBALL" ]; then
|
|
||||||
echo "Error: $TARBALL not found"
|
|
||||||
echo "Please download aios-bootstrap.tar.gz first"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Extract tarball
|
|
||||||
echo "1. Extracting $TARBALL..."
|
|
||||||
tar xf "$TARBALL"
|
tar xf "$TARBALL"
|
||||||
|
|
||||||
# Move to /var/lib/machines/
|
|
||||||
echo "2. Installing to /var/lib/machines/$NAME..."
|
|
||||||
rm -rf /var/lib/machines/$NAME
|
|
||||||
mkdir -p /var/lib/machines
|
mkdir -p /var/lib/machines
|
||||||
mv root.x86_64/var/lib/machines/arch /var/lib/machines/$NAME
|
mv root.x86_64 /var/lib/machines/$NAME
|
||||||
|
|
||||||
# Copy nspawn configuration
|
|
||||||
echo "3. Installing systemd-nspawn configuration..."
|
|
||||||
mkdir -p /etc/systemd/nspawn
|
|
||||||
|
|
||||||
# Create aios.nspawn
|
|
||||||
cat > /etc/systemd/nspawn/$NAME.nspawn <<'EOF'
|
|
||||||
[Exec]
|
|
||||||
Boot=yes
|
|
||||||
PrivateUsers=pick
|
|
||||||
ResolvConf=copy-host
|
|
||||||
|
|
||||||
[Files]
|
|
||||||
Bind=/root/.config/syui/ai:/root/.config/syui/ai
|
|
||||||
|
|
||||||
[Network]
|
|
||||||
VirtualEthernet=no
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Create aiosback.nspawn
|
|
||||||
cat > /etc/systemd/nspawn/$BACKUP.nspawn <<'EOF'
|
|
||||||
[Exec]
|
|
||||||
Boot=yes
|
|
||||||
PrivateUsers=pick
|
|
||||||
ResolvConf=copy-host
|
|
||||||
|
|
||||||
[Files]
|
|
||||||
Bind=/root/.config/syui/ai:/root/.config/syui/ai
|
|
||||||
|
|
||||||
[Network]
|
|
||||||
VirtualEthernet=no
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Create workspace.nspawn
|
|
||||||
cat > /etc/systemd/nspawn/workspace.nspawn <<'EOF'
|
|
||||||
[Exec]
|
|
||||||
Boot=yes
|
|
||||||
PrivateUsers=pick
|
|
||||||
ResolvConf=copy-host
|
|
||||||
|
|
||||||
[Files]
|
|
||||||
Bind=/root/.config/syui/ai:/root/.config/syui/ai
|
|
||||||
|
|
||||||
[Network]
|
|
||||||
VirtualEthernet=no
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Create bind mount directory
|
|
||||||
mkdir -p /root/.config/syui/ai
|
|
||||||
|
|
||||||
# Enable systemd-machined
|
|
||||||
echo "4. Enabling systemd-machined..."
|
|
||||||
systemctl enable --now systemd-machined
|
|
||||||
|
|
||||||
# Create initial backup
|
|
||||||
echo "5. Creating initial backup image..."
|
|
||||||
machinectl clone $NAME $BACKUP
|
|
||||||
|
|
||||||
# Create workspace container for AI operations
|
|
||||||
echo "6. Creating workspace container..."
|
|
||||||
machinectl clone $NAME workspace
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "=== Installation complete ==="
|
echo "=== Installation complete ==="
|
||||||
echo ""
|
echo ""
|
||||||
echo "Next steps for each user:"
|
echo "Usage:"
|
||||||
echo " 1. Copy control script to your home:"
|
echo " sudo machinectl start $NAME"
|
||||||
echo " cp /var/lib/machines/$NAME/opt/aios-ctl.zsh ~/.aios-ctl.zsh"
|
echo " sudo machinectl shell $NAME /bin/su - ai"
|
||||||
echo ""
|
|
||||||
echo " 2. Add to your .zshrc:"
|
|
||||||
echo " echo 'source ~/.aios-ctl.zsh' >> ~/.zshrc"
|
|
||||||
echo " source ~/.zshrc"
|
|
||||||
echo ""
|
|
||||||
echo " 3. Start aios:"
|
|
||||||
echo " aios-start"
|
|
||||||
echo ""
|
|
||||||
echo " 4. Login to aios:"
|
|
||||||
echo " aios-login"
|
|
||||||
echo ""
|
|
||||||
echo "Available commands:"
|
|
||||||
echo " aios-start, aios-stop, aios-shell, aios-login"
|
|
||||||
echo " aios-backup, aios-reset, aios-update"
|
|
||||||
echo " aios-help for full list"
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
50
cfg/setup-claude.sh
Executable file
50
cfg/setup-claude.sh
Executable file
@@ -0,0 +1,50 @@
|
|||||||
|
#!/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"
|
||||||
114
cfg/setup-user.sh
Executable file
114
cfg/setup-user.sh
Executable file
@@ -0,0 +1,114 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# User setup for aios
|
||||||
|
# Creates ai user, configures auto-login, sudo, zshrc
|
||||||
|
|
||||||
|
ROOTFS="root.x86_64"
|
||||||
|
|
||||||
|
echo "=== User Setup ==="
|
||||||
|
|
||||||
|
# Create default user 'ai'
|
||||||
|
echo "Creating user 'ai'..."
|
||||||
|
arch-chroot $ROOTFS /bin/sh -c 'useradd -m -G wheel -s /bin/zsh ai'
|
||||||
|
arch-chroot $ROOTFS /bin/sh -c 'echo "ai:root" | chpasswd'
|
||||||
|
|
||||||
|
# Configure securetty for pts login (required for systemd-nspawn)
|
||||||
|
echo "Configuring securetty..."
|
||||||
|
cat >> $ROOTFS/etc/securetty <<'EOF'
|
||||||
|
pts/0
|
||||||
|
pts/1
|
||||||
|
pts/2
|
||||||
|
pts/3
|
||||||
|
pts/4
|
||||||
|
pts/5
|
||||||
|
pts/6
|
||||||
|
pts/7
|
||||||
|
pts/8
|
||||||
|
pts/9
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Enable systemd-machined for container management
|
||||||
|
echo "Enabling systemd-machined..."
|
||||||
|
arch-chroot $ROOTFS /bin/sh -c 'systemctl enable systemd-machined'
|
||||||
|
|
||||||
|
# Create workspace container configuration (bind ai user dir to container root)
|
||||||
|
echo "Creating workspace container configuration..."
|
||||||
|
mkdir -p $ROOTFS/etc/systemd/nspawn
|
||||||
|
cat > $ROOTFS/etc/systemd/nspawn/workspace.nspawn <<'EOF'
|
||||||
|
[Exec]
|
||||||
|
Boot=yes
|
||||||
|
PrivateUsers=pick
|
||||||
|
ResolvConf=copy-host
|
||||||
|
|
||||||
|
[Files]
|
||||||
|
Bind=/home/ai:/root
|
||||||
|
|
||||||
|
[Network]
|
||||||
|
VirtualEthernet=no
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Setup auto-login for user 'ai'
|
||||||
|
echo "Setting up auto-login..."
|
||||||
|
arch-chroot $ROOTFS /bin/sh -c 'mkdir -p /etc/systemd/system/getty@tty1.service.d'
|
||||||
|
cat > $ROOTFS/etc/systemd/system/getty@tty1.service.d/override.conf <<'EOF'
|
||||||
|
[Service]
|
||||||
|
ExecStart=
|
||||||
|
ExecStart=-/usr/bin/agetty --autologin ai --noclear %I $TERM
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Copy .zshrc for root
|
||||||
|
echo "Copying zshrc..."
|
||||||
|
cp -rf ./cfg/zshrc $ROOTFS/root/.zshrc
|
||||||
|
|
||||||
|
# Copy .zshrc for user 'ai'
|
||||||
|
cp -rf ./cfg/zshrc $ROOTFS/home/ai/.zshrc
|
||||||
|
|
||||||
|
# Add workspace container auto-start and entry (shared .zshrc for ai user and workspace root)
|
||||||
|
cat >> $ROOTFS/home/ai/.zshrc <<'EOF'
|
||||||
|
|
||||||
|
# MCP auto-setup (run once after .claude.json is created)
|
||||||
|
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 [[ -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
|
||||||
|
claude
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
EOF
|
||||||
|
|
||||||
|
arch-chroot $ROOTFS /bin/sh -c 'chown ai:ai /home/ai/.zshrc'
|
||||||
|
|
||||||
|
# Copy aios startup script
|
||||||
|
cp -rf ./cfg/aios.zsh $ROOTFS/usr/local/bin/aios-startup
|
||||||
|
arch-chroot $ROOTFS /bin/sh -c 'chmod +x /usr/local/bin/aios-startup'
|
||||||
|
|
||||||
|
# Create default config directory and file for user 'ai'
|
||||||
|
arch-chroot $ROOTFS /bin/sh -c 'mkdir -p /home/ai/.config/syui/ai/os'
|
||||||
|
cat > $ROOTFS/home/ai/.config/syui/ai/os/config.json <<'EOF'
|
||||||
|
{
|
||||||
|
"shell": false
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
arch-chroot $ROOTFS /bin/sh -c 'chown -R ai:ai /home/ai/.config'
|
||||||
|
|
||||||
|
# Update .zshrc to source startup script
|
||||||
|
cat >> $ROOTFS/home/ai/.zshrc <<'EOF'
|
||||||
|
|
||||||
|
# aios startup
|
||||||
|
source /usr/local/bin/aios-startup
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "✓ User setup complete"
|
||||||
20
cfg/user-continer.sh
Normal file
20
cfg/user-continer.sh
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Create child containers inside aios for ai user
|
||||||
|
# Simply copy the aios itself as child containers
|
||||||
|
|
||||||
|
ROOTFS="root.x86_64"
|
||||||
|
|
||||||
|
echo "=== Creating child containers ==="
|
||||||
|
|
||||||
|
# Create directory for child containers
|
||||||
|
mkdir -p $ROOTFS/var/lib/machines
|
||||||
|
|
||||||
|
# Copy aios as workspace
|
||||||
|
echo "Creating workspace container..."
|
||||||
|
cp -a $ROOTFS $ROOTFS/var/lib/machines/workspace
|
||||||
|
|
||||||
|
# Copy aios as restore-img
|
||||||
|
echo "Creating restore-img container..."
|
||||||
|
cp -a $ROOTFS $ROOTFS/var/lib/machines/restore-img
|
||||||
|
|
||||||
|
echo "✓ Child containers created"
|
||||||
@@ -1335,6 +1335,7 @@ _validate_requirements_buildmode_bootstrap() {
|
|||||||
local bootstrap_pkg_list_from_file=()
|
local bootstrap_pkg_list_from_file=()
|
||||||
|
|
||||||
# Check if packages for the bootstrap image are specified
|
# Check if packages for the bootstrap image are specified
|
||||||
|
if [[ -n "${bootstrap_packages}" ]]; then
|
||||||
if [[ -e "${bootstrap_packages}" ]]; then
|
if [[ -e "${bootstrap_packages}" ]]; then
|
||||||
mapfile -t bootstrap_pkg_list_from_file < \
|
mapfile -t bootstrap_pkg_list_from_file < \
|
||||||
<(sed '/^[[:blank:]]*#.*/d;s/#.*//;/^[[:blank:]]*$/d' "${bootstrap_packages}")
|
<(sed '/^[[:blank:]]*#.*/d;s/#.*//;/^[[:blank:]]*$/d' "${bootstrap_packages}")
|
||||||
@@ -1347,6 +1348,7 @@ _validate_requirements_buildmode_bootstrap() {
|
|||||||
(( validation_error=validation_error+1 ))
|
(( validation_error=validation_error+1 ))
|
||||||
_msg_error "Bootstrap packages file '${bootstrap_packages}' does not exist." 0
|
_msg_error "Bootstrap packages file '${bootstrap_packages}' does not exist." 0
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
_validate_common_requirements_buildmode_all
|
_validate_common_requirements_buildmode_all
|
||||||
if ! command -v bsdtar &>/dev/null; then
|
if ! command -v bsdtar &>/dev/null; then
|
||||||
|
|||||||
Reference in New Issue
Block a user