#!/bin/bash # Snap lane acceptance on an installed, disposable Phoebus qcow2 only. # Run as root through serial-driver.py BOOT_AUTHENTICATE=1. set -uo pipefail SYS=/tmp/phoebus-snap-sys SYS_URL="${SYS_URL:-http://10.0.2.2:8000/sys}" case "$(findmnt -n -o SOURCE /)" in /dev/mapper/*) ;; *) echo 'CASE snap-target FAIL root is not the installed encrypted VM'; exit 1 ;; esac if curl -fsSL "$SYS_URL" -o "$SYS" && chmod 755 "$SYS" && "$SYS" --version; then echo 'CASE snap-sys PASS current static sys is available' else echo 'CASE snap-sys FAIL could not fetch current static sys' exit 1 fi # Gentoo's snapd ebuild requires these two scoped squashfs-tools flags. The # minimal VM profile omits them, so record the prerequisite explicitly. install -d -m 0755 /etc/portage/package.use printf '%s\n' 'sys-fs/squashfs-tools lzma lzo' \ > /etc/portage/package.use/phoebus-snap if compgen -G '/var/db/pkg/app-containers/snapd-*' >/dev/null; then echo 'CASE snap-portage PASS snapd already installed through Portage' elif "$SYS" -y install app-containers/snapd --legacy --portage; then echo 'CASE snap-portage PASS reviewed snapd install' else echo 'CASE snap-portage FAIL reviewed snapd install failed' exit 1 fi if "$SYS" -y enable snapd.socket --legacy && "$SYS" -y start snapd.socket --legacy \ && systemctl is-active --quiet snapd.socket; then echo 'CASE snap-socket PASS enabled and active' else echo 'CASE snap-socket FAIL socket did not become active' exit 1 fi if snap debug confinement; then echo 'CASE snap-confinement PASS daemon reported confinement' else echo 'CASE snap-confinement FAIL could not determine confinement' exit 1 fi if snap list hello-world >/dev/null 2>&1; then echo 'CASE snap-install PASS snap already installed by sys' elif "$SYS" -y install hello-world --legacy --snap && snap list hello-world; then echo 'CASE snap-install PASS installed via reviewed sys plan' else echo 'CASE snap-install FAIL install or inventory failed' exit 1 fi if "$SYS" -y snap refresh hello-world --legacy; then echo 'CASE snap-refresh PASS refresh path completed' else echo 'CASE snap-refresh FAIL refresh path failed' exit 1 fi if "$SYS" -y snap remove hello-world --legacy && ! snap list hello-world >/dev/null 2>&1; then echo 'CASE snap-remove PASS snap removed' else echo 'CASE snap-remove FAIL removal or absence check failed' exit 1 fi echo '===SNAP-ACCEPTANCE-DONE==='