Compare commits
58 Commits
e0e012da9e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
872bb0c432
|
|||
|
27658209d3
|
|||
|
18d2860397
|
|||
|
|
66b416ebde | ||
|
|
b7b59f593a | ||
|
|
3d86677dd2 | ||
|
|
c20c49d5e0 | ||
|
|
c93f972c4a | ||
|
|
5d7f06282e | ||
|
|
2162463382 | ||
|
|
f965547b6c | ||
|
|
d3ea2cc78d | ||
|
|
66f3fe4045 | ||
|
|
30ebfcf933 | ||
|
|
66a5c6d16f | ||
|
|
62db018527 | ||
|
|
111fa7b828 | ||
|
|
7b0cb8e183 | ||
|
|
2d98f58232 | ||
|
|
fe1f150634 | ||
|
|
e62288c872 | ||
|
|
fd922287c0 | ||
|
|
2773101035 | ||
|
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:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -24,84 +24,12 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
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
|
||||
source /usr/local/bin/aios-startup
|
||||
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/'
|
||||
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
|
||||
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
|
||||
- name: Build aios
|
||||
run: bash ./build.zsh
|
||||
|
||||
- name: Create Docker images
|
||||
run: |
|
||||
tar -C ./root.x86_64 -c . | docker import - ${{ env.IMAGE_NAME }}
|
||||
echo "${{ env.DOCKER_TOKEN }}" | docker login -u syui --password-stdin
|
||||
docker push ${{ env.IMAGE_NAME }}
|
||||
|
||||
174
build.zsh
174
build.zsh
@@ -1,119 +1,119 @@
|
||||
#!/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
|
||||
|
||||
# Clone 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 ./archiso/configs/releng/profiledef.sh
|
||||
cp -rf ./cfg/profiledef.sh ./archiso/configs/baseline/profiledef.sh
|
||||
cp -rf ./scpt/mkarchiso ./archiso/archiso/mkarchiso
|
||||
|
||||
# Build bootstrap
|
||||
./archiso/archiso/mkarchiso -v -o ./ ./archiso/configs/releng/
|
||||
|
||||
# Extract and prepare
|
||||
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
|
||||
mkdir -p root.x86_64
|
||||
pacstrap -c root.x86_64 base
|
||||
|
||||
# Configure pacman
|
||||
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'
|
||||
Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch' >> ./root.x86_64/etc/pacman.d/mirrorlist
|
||||
sed -i s/CheckSpace/#CheckeSpace/ root.x86_64/etc/pacman.conf
|
||||
|
||||
# Initialize pacman keys
|
||||
arch-chroot root.x86_64 /bin/sh -c 'pacman-key --init'
|
||||
arch-chroot root.x86_64 /bin/sh -c 'pacman-key --populate archlinux'
|
||||
|
||||
# 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
|
||||
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
|
||||
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'
|
||||
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'
|
||||
# Configure sudoers for wheel group (full access for container operation)
|
||||
echo "Configuring sudoers..."
|
||||
arch-chroot root.x86_64 /bin/sh -c 'echo "%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/pacman -Syu --noconfirm, /usr/bin/poweroff, /usr/bin/reboot" >> /etc/sudoers'
|
||||
arch-chroot root.x86_64 /bin/sh -c 'echo "ai ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers'
|
||||
|
||||
# Enable wheel group for sudo (specific commands without password)
|
||||
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'
|
||||
# Install aigpt (aios core package)
|
||||
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/ && cd .. && rm -rf gpt'
|
||||
|
||||
# Setup auto-login for user 'ai'
|
||||
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
|
||||
# Install aibot (aios core package)
|
||||
echo "Installing aibot..."
|
||||
arch-chroot root.x86_64 /bin/sh -c 'git clone https://git.syui.ai/ai/bot && cd bot && cargo build --release && cp -rf ./target/release/aibot /bin/ && aibot ai && cd .. && rm -rf bot'
|
||||
|
||||
# Copy .zshrc for root
|
||||
cp -rf ./cfg/zshrc root.x86_64/var/lib/machines/arch/root/.zshrc
|
||||
echo "Installing aishell..."
|
||||
arch-chroot root.x86_64 /bin/sh -c 'git clone https://git.syui.ai/ai/shell && cd shell && cargo build --release && cp -rf ./target/release/aishell /bin/ && cd .. && rm -rf shell'
|
||||
|
||||
# Copy .zshrc for user 'ai'
|
||||
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'
|
||||
echo "✓ Arch Linux base complete"
|
||||
echo ""
|
||||
|
||||
# Copy aios startup script
|
||||
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'
|
||||
# ============================================
|
||||
# 2. User Setup
|
||||
# ============================================
|
||||
|
||||
# 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'
|
||||
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'
|
||||
bash ./cfg/setup-user.sh
|
||||
echo ""
|
||||
|
||||
# Update .zshrc to source startup script
|
||||
cat >> root.x86_64/var/lib/machines/arch/home/ai/.zshrc <<'EOF'
|
||||
# ============================================
|
||||
# 3. Create workspace container (after all configuration)
|
||||
# ============================================
|
||||
|
||||
# aios startup
|
||||
source /usr/local/bin/aios-startup
|
||||
EOF
|
||||
bash ./cfg/user-continer.sh
|
||||
echo ""
|
||||
|
||||
# Install aigpt (AI memory system)
|
||||
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/'
|
||||
# ============================================
|
||||
# Finalize
|
||||
# ============================================
|
||||
|
||||
# Setup Claude Code MCP configuration (shared via symlink)
|
||||
# Create actual config in syui/ai/claude (bind-mounted)
|
||||
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
|
||||
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'
|
||||
echo "=== Finalizing ==="
|
||||
|
||||
# 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
|
||||
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
|
||||
|
||||
echo ""
|
||||
echo "=== Build Complete ==="
|
||||
echo "Output: aios-bootstrap.tar.gz"
|
||||
echo ""
|
||||
|
||||
@@ -21,9 +21,9 @@ function aios-shell() {
|
||||
sudo machinectl shell $NAME
|
||||
}
|
||||
|
||||
# Login to aios container
|
||||
# Login to aios container as ai user
|
||||
function aios-login() {
|
||||
sudo machinectl login $NAME
|
||||
sudo machinectl shell $NAME /bin/su - ai
|
||||
}
|
||||
|
||||
# Create backup of current aios
|
||||
|
||||
104
cfg/install.sh
104
cfg/install.sh
@@ -1,118 +1,30 @@
|
||||
#!/bin/bash
|
||||
# aios installation script
|
||||
|
||||
set -e
|
||||
|
||||
NAME="aios"
|
||||
BACKUP="${NAME}back"
|
||||
TARBALL="aios-bootstrap.tar.gz"
|
||||
|
||||
echo "=== aios installation ==="
|
||||
echo ""
|
||||
|
||||
# Check if running as root
|
||||
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..."
|
||||
# Extract and install
|
||||
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
|
||||
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..."
|
||||
# Create aios.nspawn for network access
|
||||
echo "Creating network 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
|
||||
Private=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 ""
|
||||
echo "Next steps for each user:"
|
||||
echo " 1. Copy control script to your home:"
|
||||
echo " cp /var/lib/machines/$NAME/opt/aios-ctl.zsh ~/.aios-ctl.zsh"
|
||||
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 "Usage:"
|
||||
echo " sudo machinectl start $NAME"
|
||||
echo " sudo machinectl shell $NAME /bin/su - ai"
|
||||
echo ""
|
||||
|
||||
84
cfg/setup-user.sh
Executable file
84
cfg/setup-user.sh
Executable file
@@ -0,0 +1,84 @@
|
||||
#!/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
|
||||
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 auto-entry and claude auto-start
|
||||
cat >> $ROOTFS/home/ai/.zshrc <<'EOF'
|
||||
|
||||
# aios: auto-enter workspace container
|
||||
if [[ -o login ]] && [[ -o interactive ]]; then
|
||||
if [[ -z "$INSIDE_WORKSPACE" ]]; then
|
||||
# Enter workspace container
|
||||
export INSIDE_WORKSPACE=1
|
||||
exec sudo systemd-nspawn -q -D /var/lib/machines/workspace /bin/zsh
|
||||
else
|
||||
# Inside workspace - start claude with skip permissions
|
||||
if command -v claude &>/dev/null; then
|
||||
claude --dangerously-skip-permissions
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
EOF
|
||||
|
||||
arch-chroot $ROOTFS /bin/sh -c 'chown ai:ai /home/ai/.zshrc'
|
||||
|
||||
echo "✓ User setup complete"
|
||||
23
cfg/user-continer.sh
Normal file
23
cfg/user-continer.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
# Create workspace container inside aios for ai user
|
||||
# Backup aios before creating /var/lib/machines to avoid recursion
|
||||
|
||||
ROOTFS="root.x86_64"
|
||||
|
||||
echo "=== Creating workspace container ==="
|
||||
|
||||
# Backup current aios to temp location (before creating /var/lib/machines)
|
||||
echo "Backing up aios..."
|
||||
cp -a $ROOTFS /tmp/aios-backup-$$
|
||||
|
||||
# Create directory for child containers
|
||||
mkdir -p $ROOTFS/var/lib/machines
|
||||
|
||||
# Copy backup as workspace
|
||||
echo "Creating workspace container..."
|
||||
cp -a /tmp/aios-backup-$$ $ROOTFS/var/lib/machines/workspace
|
||||
|
||||
# Cleanup temp backup
|
||||
rm -rf /tmp/aios-backup-$$
|
||||
|
||||
echo "✓ Workspace container created"
|
||||
@@ -13,8 +13,8 @@ export AIGPT_CONFIG="$HOME/.config/syui/ai/config.toml"
|
||||
export AIGPT_MCP="$HOME/.config/syui/ai/mcp.json"
|
||||
|
||||
# Aliases
|
||||
alias ai='claude'
|
||||
alias c='claude'
|
||||
alias claude='claude --dangerously-skip-permissions'
|
||||
alias c='claude --dangerously-skip-permissions'
|
||||
|
||||
# Prompt
|
||||
autoload -Uz promptinit
|
||||
|
||||
@@ -1335,6 +1335,7 @@ _validate_requirements_buildmode_bootstrap() {
|
||||
local bootstrap_pkg_list_from_file=()
|
||||
|
||||
# Check if packages for the bootstrap image are specified
|
||||
if [[ -n "${bootstrap_packages}" ]]; then
|
||||
if [[ -e "${bootstrap_packages}" ]]; then
|
||||
mapfile -t bootstrap_pkg_list_from_file < \
|
||||
<(sed '/^[[:blank:]]*#.*/d;s/#.*//;/^[[:blank:]]*$/d' "${bootstrap_packages}")
|
||||
@@ -1347,6 +1348,7 @@ _validate_requirements_buildmode_bootstrap() {
|
||||
(( validation_error=validation_error+1 ))
|
||||
_msg_error "Bootstrap packages file '${bootstrap_packages}' does not exist." 0
|
||||
fi
|
||||
fi
|
||||
|
||||
_validate_common_requirements_buildmode_all
|
||||
if ! command -v bsdtar &>/dev/null; then
|
||||
|
||||
Reference in New Issue
Block a user