2026-07-29 15:33:51 +00:00
|
|
|
#!/usr/bin/env bash
|
2026-08-03 09:08:04 +00:00
|
|
|
# Keeps the machine's Flatpak apps in sync with /usr/share/kamos/flatpaks.list.
|
|
|
|
|
# Runs on every boot but does nothing unless the list changed since last time,
|
|
|
|
|
# so adding an app to the list + rebuilding the image is enough — installed
|
|
|
|
|
# machines pick it up on their next update, no reinstall needed.
|
2026-07-29 15:33:51 +00:00
|
|
|
set -u
|
|
|
|
|
|
|
|
|
|
LIST=/usr/share/kamos/flatpaks.list
|
2026-08-03 09:08:04 +00:00
|
|
|
STATE=/var/lib/kamos-flatpaks.sha
|
2026-07-29 15:33:51 +00:00
|
|
|
|
2026-08-03 09:08:04 +00:00
|
|
|
[ -f "$LIST" ] || exit 0
|
|
|
|
|
|
|
|
|
|
NEW="$(sha256sum "$LIST" | awk '{print $1}')"
|
|
|
|
|
OLD="$(cat "$STATE" 2>/dev/null || true)"
|
|
|
|
|
[ "$NEW" = "$OLD" ] && exit 0
|
2026-07-29 15:33:51 +00:00
|
|
|
|
|
|
|
|
flatpak remote-add --if-not-exists --system flathub \
|
|
|
|
|
https://dl.flathub.org/repo/flathub.flatpakrepo || true
|
|
|
|
|
|
|
|
|
|
ok=1
|
|
|
|
|
while IFS= read -r app; do
|
|
|
|
|
case "$app" in ''|\#*) continue ;; esac
|
|
|
|
|
app="${app%%#*}"; app="$(echo "$app" | xargs)"
|
|
|
|
|
[ -z "$app" ] && continue
|
2026-08-03 09:08:04 +00:00
|
|
|
echo "KAMOS: installing $app"
|
2026-07-29 15:33:51 +00:00
|
|
|
flatpak install --system --noninteractive --or-update flathub "$app" || ok=0
|
|
|
|
|
done < "$LIST"
|
|
|
|
|
|
2026-08-03 09:08:04 +00:00
|
|
|
# Only record success, so a failed run (e.g. no network yet) retries next boot
|
|
|
|
|
[ "$ok" = 1 ] && echo "$NEW" > "$STATE"
|
2026-07-29 15:33:51 +00:00
|
|
|
exit 0
|