Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

3.8 KB
Raw Blame
#!/bin/bash
set -euo pipefail
# Validate with the exact terminal version being shipped, before compressing it.
foot --check-config --config=/usr/share/harness-os/foot.ini
echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen
locale-gen
echo 'LANG=en_US.UTF-8' > /etc/locale.conf
echo harness > /etc/hostname
touch /etc/harness-live
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
useradd -m -G wheel,video,audio -s /bin/bash me
passwd -d me
passwd -d root
mkdir -p /etc/sudoers.d /home/me/projects /etc/systemd/system/[email protected]
echo 'me ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/10-live
chmod 440 /etc/sudoers.d/10-live
visudo -cf /etc/sudoers.d/20-harness-network
chown me:me /home/me/projects
systemctl enable NetworkManager systemd-resolved systemd-timesyncd [email protected]
systemctl enable harness-keyring.service
# Started from the recovery partition only (harness.recovery): it installs the computer again.
systemctl enable harness-recovery.service
# hn-screen starts the daemon after labwc has published the display environment.
# Linger keeps that runtime alive if its graphical client is restarted.
mkdir -p /var/lib/systemd/linger
touch /var/lib/systemd/linger/me
# Agent auth and browser downloads never block boot. No SSH listener by default.
systemctl disable NetworkManager-wait-online.service || true
systemctl disable archlinux-keyring-wkd-sync.timer
systemctl mask systemd-networkd.service systemd-networkd-wait-online.service
ln -sf /usr/lib/systemd/system/multi-user.target /etc/systemd/system/default.target
printf '[Service]\nExecStart=\nExecStart=-/usr/bin/agetty --autologin me --noclear %%I $TERM\n' > /etc/systemd/system/[email protected]/autologin.conf
# A serial console is useful for recovering a live USB; never carried into the install.
mkdir -p /etc/systemd/system/[email protected]
printf '[Service]\nExecStart=\nExecStart=-/usr/bin/agetty --autologin root --noclear %%I 115200\n' > /etc/systemd/system/[email protected]/live.conf
systemctl enable [email protected]
python3 - <<'PY'
import hashlib, json, importlib.util
from pathlib import Path
spec = importlib.util.spec_from_file_location('harness_boot_profile', '/usr/lib/harness-os/boot_profile.py')
boot = importlib.util.module_from_spec(spec)
spec.loader.exec_module(boot)
profile = boot.selected()
lock = json.loads(Path('/usr/share/harness-os/lock.json').read_text())
snapshot = lock['arch_snapshot']
Path('/etc/pacman.conf').write_text(
    '[options]\nArchitecture = auto\nCheckSpace\nSigLevel = Required DatabaseOptional\nLocalFileSigLevel = Optional\n' +
    ''.join(f'[{repo}]\nServer = https://archive.archlinux.org/repos/{snapshot}/$repo/os/$arch\n' for repo in ['core', 'extra']))
# archiso removes /boot from SquashFS after placing boot files on the ISO.
# Keep the exact package-owned kernel location for an offline disk install.
kernels = [p.parent / 'vmlinuz' for p in Path('/usr/lib/modules').glob('*/pkgbase') if p.read_text().strip() == profile['kernel']]
if len(kernels) != 1 or not kernels[0].is_file():
    raise SystemExit('Expected one package-owned platform kernel for the installer.')
kernel = kernels[0]
with kernel.open('rb') as handle:
    digest = hashlib.file_digest(handle, 'sha256').hexdigest()
Path('/usr/share/harness-os/kernel.json').write_text(json.dumps({'path': str(kernel.relative_to('/')), 'sha256': digest, 'platform': profile['id']}) + '\n')
PY
pacman -Q > /usr/share/harness-os/packages.txt
# Archiso removes pacman's sync databases during cleanup. Preserve the two
# dated repositories so the first package query/install works immediately.
install -d /usr/share/harness-os/repository-databases
for repo in core extra; do
    install -m 644 "/var/lib/pacman/sync/$repo.db" "/usr/share/harness-os/repository-databases/$repo.db"
done
rm -rf /var/cache/pacman/pkg/* /root/.cache