#!/bin/bash set -e echo ">>> [snapper-setup] Running INSIDE target system" if [ "$(findmnt -no FSTYPE /)" != "btrfs" ]; then echo ">>> [snapper-setup] Root is not btrfs, skipping." exit 0 fi if ! command -v snapper >/dev/null 2>&1; then echo ">>> [snapper-setup] snapper is not installed, skipping." exit 0 fi if ! findmnt -no SOURCE /.snapshots >/dev/null 2>&1; then echo ">>> [snapper-setup] /.snapshots is not mounted, skipping." exit 0 fi SABLON=/usr/share/snapper/config-templates/default [ -f "$SABLON" ] || { echo ">>> [snapper-setup] Missing template $SABLON"; exit 1; } install -d -m 755 /etc/snapper/configs sed -e 's/^SUBVOLUME=.*/SUBVOLUME="\/"/' \ -e 's/^FSTYPE=.*/FSTYPE="btrfs"/' \ -e 's/^ALLOW_GROUPS=.*/ALLOW_GROUPS="wheel"/' \ -e 's/^SYNC_ACL=.*/SYNC_ACL="yes"/' \ -e 's/^NUMBER_CLEANUP=.*/NUMBER_CLEANUP="yes"/' \ -e 's/^NUMBER_LIMIT=.*/NUMBER_LIMIT="10"/' \ -e 's/^NUMBER_LIMIT_IMPORTANT=.*/NUMBER_LIMIT_IMPORTANT="5"/' \ -e 's/^TIMELINE_CREATE=.*/TIMELINE_CREATE="no"/' \ -e 's/^TIMELINE_CLEANUP=.*/TIMELINE_CLEANUP="yes"/' \ -e 's/^EMPTY_PRE_POST_CLEANUP=.*/EMPTY_PRE_POST_CLEANUP="yes"/' \ "$SABLON" > /etc/snapper/configs/root chmod 640 /etc/snapper/configs/root if [ -f /etc/conf.d/snapper ]; then sed -i 's/^SNAPPER_CONFIGS=.*/SNAPPER_CONFIGS="root"/' /etc/conf.d/snapper else install -d /etc/conf.d echo 'SNAPPER_CONFIGS="root"' > /etc/conf.d/snapper fi chmod 750 /.snapshots chown root:wheel /.snapshots systemctl enable snapper-cleanup.timer systemctl disable snapper-timeline.timer 2>/dev/null || true snapper --no-dbus -c root create --type single --cleanup-algorithm number \ --userdata important=yes --description "Telepítés utáni állapot" echo ">>> [snapper-setup] Done." snapper --no-dbus -c root list