feat: Add optional auto-startup for claude
- Create cfg/aios.zsh startup script with config-based claude launch
- Install startup script to /usr/local/bin/aios-startup
- Create default config at ~/.config/syui/ai/os/config.json
- Source startup script from user 'ai' .zshrc
- Enable optional "shell mode" via config {"shell": true}
This commit is contained in:
40
.github/workflows/release.yml
vendored
40
.github/workflows/release.yml
vendored
@@ -47,12 +47,52 @@ jobs:
|
|||||||
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 'chsh -s /bin/zsh'
|
||||||
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'npm i -g @anthropic-ai/claude-code'
|
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
|
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" >> /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/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 '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 ~/.config/claude'
|
||||||
|
cat > root.x86_64/var/lib/machines/arch/root/.config/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 '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 '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'
|
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/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
|
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'
|
||||||
tar -zcvf aios-bootstrap.tar.gz root.x86_64/
|
tar -zcvf aios-bootstrap.tar.gz root.x86_64/
|
||||||
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
|
||||||
|
|||||||
20
build.zsh
20
build.zsh
@@ -47,6 +47,26 @@ 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
|
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'
|
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chown ai:ai /home/ai/.zshrc'
|
||||||
|
|
||||||
|
# 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'
|
||||||
|
|
||||||
|
# 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'
|
||||||
|
|
||||||
|
# Update .zshrc to source startup script
|
||||||
|
cat >> root.x86_64/var/lib/machines/arch/home/ai/.zshrc <<'EOF'
|
||||||
|
|
||||||
|
# aios startup
|
||||||
|
source /usr/local/bin/aios-startup
|
||||||
|
EOF
|
||||||
|
|
||||||
# Install aigpt (AI memory system)
|
# 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/'
|
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/'
|
||||||
|
|
||||||
|
|||||||
28
cfg/aios.zsh
Normal file
28
cfg/aios.zsh
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/zsh
|
||||||
|
# aios startup script
|
||||||
|
|
||||||
|
CONFIG_DIR="$HOME/.config/syui/ai/os"
|
||||||
|
CONFIG_FILE="$CONFIG_DIR/config.json"
|
||||||
|
|
||||||
|
# 設定ファイルが存在しない場合は何もしない
|
||||||
|
if [ ! -f "$CONFIG_FILE" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# jqで設定読み込み
|
||||||
|
if ! command -v jq &>/dev/null; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
SHELL_MODE=$(cat "$CONFIG_FILE" | jq -r '.shell // false')
|
||||||
|
|
||||||
|
if [ "$SHELL_MODE" = "true" ]; then
|
||||||
|
echo "aios - AI-managed OS"
|
||||||
|
echo " Shell mode enabled"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# claudeを起動
|
||||||
|
if command -v claude &>/dev/null; then
|
||||||
|
exec claude
|
||||||
|
fi
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user