fix: Restructure containers - aios contains child containers internally
Changed from 3 separate containers to 1 container with child containers inside: - /var/lib/machines/aios/ (main container) - /var/lib/machines/restore-img/ (child container) - /var/lib/machines/workspace/ (child container) ai user operates child containers from within aios using machinectl.
This commit is contained in:
19
build.zsh
19
build.zsh
@@ -101,16 +101,25 @@ echo "=== Finalizing ==="
|
|||||||
# 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/var/lib/machines/arch/opt/aios-ctl.zsh
|
||||||
|
|
||||||
# Create backup and workspace containers
|
# Create child containers inside aios (not separate containers)
|
||||||
echo "Creating aiosback and workspace containers..."
|
echo "Creating child containers inside aios..."
|
||||||
cp -a root.x86_64/var/lib/machines/arch root.x86_64/var/lib/machines/aiosback
|
mkdir -p root.x86_64/var/lib/machines/arch/var/lib/machines
|
||||||
cp -a root.x86_64/var/lib/machines/arch root.x86_64/var/lib/machines/workspace
|
|
||||||
|
# Copy the base system to temporary location to avoid recursion
|
||||||
|
cp -a root.x86_64/var/lib/machines/arch /tmp/aios-base-$$
|
||||||
|
|
||||||
|
# Create child containers inside aios
|
||||||
|
cp -a /tmp/aios-base-$$ root.x86_64/var/lib/machines/arch/var/lib/machines/restore-img
|
||||||
|
cp -a /tmp/aios-base-$$ root.x86_64/var/lib/machines/arch/var/lib/machines/workspace
|
||||||
|
|
||||||
|
# Cleanup temporary
|
||||||
|
rm -rf /tmp/aios-base-$$
|
||||||
|
|
||||||
# Copy install script
|
# 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 all containers
|
# Create tarball with aios (contains child containers inside)
|
||||||
echo "Creating tarball..."
|
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
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -27,19 +27,17 @@ fi
|
|||||||
echo "1. Extracting $TARBALL..."
|
echo "1. Extracting $TARBALL..."
|
||||||
tar xf "$TARBALL"
|
tar xf "$TARBALL"
|
||||||
|
|
||||||
# Move all containers to /var/lib/machines/
|
# Install aios (contains child containers inside)
|
||||||
echo "2. Installing containers to /var/lib/machines/..."
|
echo "2. Installing aios to /var/lib/machines/..."
|
||||||
rm -rf /var/lib/machines/$NAME /var/lib/machines/$BACKUP /var/lib/machines/workspace
|
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/arch /var/lib/machines/$NAME
|
||||||
mv root.x86_64/var/lib/machines/aiosback /var/lib/machines/$BACKUP
|
|
||||||
mv root.x86_64/var/lib/machines/workspace /var/lib/machines/workspace
|
|
||||||
|
|
||||||
# Copy nspawn configuration
|
# Copy nspawn configuration
|
||||||
echo "3. Installing systemd-nspawn configuration..."
|
echo "3. Installing systemd-nspawn configuration..."
|
||||||
mkdir -p /etc/systemd/nspawn
|
mkdir -p /etc/systemd/nspawn
|
||||||
|
|
||||||
# Create aios.nspawn
|
# Create aios.nspawn (only one container needed)
|
||||||
cat > /etc/systemd/nspawn/$NAME.nspawn <<'EOF'
|
cat > /etc/systemd/nspawn/$NAME.nspawn <<'EOF'
|
||||||
[Exec]
|
[Exec]
|
||||||
Boot=yes
|
Boot=yes
|
||||||
@@ -53,34 +51,6 @@ Bind=/root/.config/syui/ai:/root/.config/syui/ai
|
|||||||
VirtualEthernet=no
|
VirtualEthernet=no
|
||||||
EOF
|
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
|
# Create bind mount directory
|
||||||
mkdir -p /root/.config/syui/ai
|
mkdir -p /root/.config/syui/ai
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user