diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bbe760d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +debian/files diff --git a/50-siduction.sh b/50-siduction.sh index 3e68efb..343ef00 100755 --- a/50-siduction.sh +++ b/50-siduction.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash # # Name: /usr/lib/snapper/plugins/50-siduction.sh # Part of siduction-btrfs @@ -38,7 +38,7 @@ case "$1" in "create-snapshot-post") echo "$(date +%T) Plugin 50-siduction: Inside create-snapshot-post" >> /var/log/snapper.log # If full apt-aktion is done, this script change snappers description. - /usr/share/siduction/snapshot-description.sh "$4" & + /usr/share/siduction-btrfs/snapshot-description.sh "$4" & ;; # This section is for systemd-boot only. @@ -84,7 +84,7 @@ case "$1" in if [ -e /boot/grub/grub.cfg ] && [ -w /boot/grub/grub.cfg ]; then echo "$(date +%T) Plugin 50-siduction: Forwarding to rollback-grub." >> /var/log/snapper.log - /usr/share/siduction/rollback-grub.sh "$new_sn" & + /usr/share/siduction-btrfs/rollback-grub.sh "$new_sn" & wait echo "$(date +%T) Plugin 50-siduction: Return from rollback-grub." >> /var/log/snapper.log true @@ -97,7 +97,7 @@ case "$1" in # Create a menu entry for the rollback target. echo "$(date +%T) Plugin 50-siduction: Forwarding to rollback-sd-boot." >> /var/log/snapper.log - /usr/share/siduction/rollback-sd-boot.sh "$new_sn" "$sd_boot_dir" "$entry_part" & + /usr/share/siduction-btrfs/rollback-sd-boot.sh "$new_sn" "$sd_boot_dir" "$entry_part" & wait echo "$(date +%T) Plugin 50-siduction: Return from rollback-sd-boot." >> /var/log/snapper.log @@ -134,4 +134,5 @@ case "$1" in fi ;; esac +update-grub exit 0 diff --git a/60-siduction-btrfs.preset b/60-siduction-btrfs.preset new file mode 100644 index 0000000..e38885e --- /dev/null +++ b/60-siduction-btrfs.preset @@ -0,0 +1,2 @@ +disable snapper-boot.timer +disable snapper-timeline.timer \ No newline at end of file diff --git a/91-siduction-entry-key.install b/91-siduction-entry-key.install index 62f42ff..4f0784b 100755 --- a/91-siduction-entry-key.install +++ b/91-siduction-entry-key.install @@ -8,7 +8,7 @@ set -e # Only run if / is btrfs -if [ ! -e /usr/share/siduction/btrfs ]; then +if [ ! -e /usr/share/siduction-btrfs/btrfs ]; then exit 0 fi diff --git a/Info.md b/Info.md index 298f15c..b89af12 100644 --- a/Info.md +++ b/Info.md @@ -31,16 +31,17 @@ The ESP is mounted under */efi*, or in the absence of the XBOOTLDR under */boot* and the scripts */usr/lib/snapper/plugins/50-siduction.sh* */usr/share/siduction/rollback-grub.sh* -*/usr/share/siduction/grub-menu-title.sh +*/usr/share/siduction/grub-menu-title.sh* */usr/share/siduction/rollback-sd-boot.sh* */usr/share/siduction/snapshot-description.sh* +*/usr/lib/systemd/system-preset/60-siduction-btrfs.preset* */usr/lib/kernel/install.d/91-siduction-entry-key.install* ### How the package works As of version 0.3.0, siduction-btrfs uses the Snapper plugin directory. There the script *50-siduction* listens to the Snapper actions in the root subvolume and executes the scripts *snapshot-description*, *rollback-grub*, *grub-menu-title*, or *rollback-sd-boot* if required. -To manage snapshots, snapper-gui is quite useful. However, a rollback requires a terminal with root rights. +The graphical program *btrfs-assistant* is very useful for managing snapshots. However, a rollback requires a terminal with root rights. **When using the boot manager GRUB** After a rollback, the file */boot/grub/grub.cfg* is recreated in the rollback target using chroot and GRUB is then reinstalled from the rollback target. This allows the user to access the rollback target directly with a simple reboot. All other subvolumes, including the previously used one, can be accessed via the *siduction snapshots* submenu. @@ -88,16 +89,17 @@ Die ESP hängt man unter */efi*, oder bei Abwesenheit der XBOOTLDR unter */boot* und die Skripte */usr/lib/snapper/plugins/50-siduction.sh* */usr/share/siduction/rollback-grub.sh* -*/usr/share/siduction/grub-menu-title.sh +*/usr/share/siduction/grub-menu-title.sh* */usr/share/siduction/rollback-sd-boot.sh* */usr/share/siduction/snapshot-description.sh* +*/usr/lib/systemd/system-preset/60-siduction-btrfs.preset* */usr/lib/kernel/install.d/91-siduction-entry-key.install* ### Wie das Paket arbeitet Ab Version 0.3.0 verwendet siduction-btrfs das Snapper Plugin Verzeichnis. Dort lauscht das Skript *50-siduction* auf die Snapper Aktionen im root Subvolumen und führt bei Bedarf die Skripte *snapshot-description*, *rollback-grub*, *grub-menu-title* oder *rollback-sd-boot* aus. -Um Schnappschüsse zu verwalten, ist snapper-gui ganz nützlich. Ein Rollback jedoch erfordert ein Terminal mit root Rechten. +Zur Verwaltung von Snapshots ist das graphische Programm *btrfs-assistant* sehr nützlich. Ein Rollback jedoch erfordert ein Terminal mit root Rechten. **Bei Verwendung des Bootmanagers GRUB** Nach einem Rollback wird im Rollbackziel mittels chroot die Datei */boot/grub/grub.cfg* neu erstellt und anschließend aus dem Rollbackziel heraus GRUB neu installiert. Dadurch gelangt der User mit einem einfachen Reboot direkt in das Rollbackziel. Alle anderen Subvolumen, auch das zuvor verwendete, sind über das Untermenü *siduction snapshots* erreichbar. diff --git a/btrfs b/btrfs new file mode 100644 index 0000000..e67124c --- /dev/null +++ b/btrfs @@ -0,0 +1,2 @@ +DO NOT REMOVE THIS FILE! +It is required by the siduction_btrfs systemd units. diff --git a/configs/home b/configs/home new file mode 100644 index 0000000..ad30f52 --- /dev/null +++ b/configs/home @@ -0,0 +1,61 @@ +# subvolume to snapshot +SUBVOLUME="/home" + +# filesystem type +FSTYPE="btrfs" + + +# btrfs qgroup for space aware cleanup algorithms +QGROUP="" + + +# fraction or absolute size of the filesystems space the snapshots may use +SPACE_LIMIT="0.5" + +# fraction or absolute size of the filesystems space that should be free +FREE_LIMIT="0.2" + + +# users and groups allowed to work with config +ALLOW_USERS="" +ALLOW_GROUPS="" + +# sync users and groups from ALLOW_USERS and ALLOW_GROUPS to .snapshots +# directory +SYNC_ACL="yes" + + +# start comparing pre- and post-snapshot in background after creating +# post-snapshot +BACKGROUND_COMPARISON="yes" + + +# run daily number cleanup +NUMBER_CLEANUP="yes" + +# limit for number cleanup +NUMBER_MIN_AGE="1800" +NUMBER_LIMIT="20" +NUMBER_LIMIT_IMPORTANT="5" + + +# create hourly snapshots +TIMELINE_CREATE="yes" + +# cleanup hourly snapshots after some time +TIMELINE_CLEANUP="yes" + +# limits for timeline cleanup +TIMELINE_MIN_AGE="1800" +TIMELINE_LIMIT_HOURLY="11" +TIMELINE_LIMIT_DAILY="6" +TIMELINE_LIMIT_WEEKLY="1" +TIMELINE_LIMIT_MONTHLY="" +TIMELINE_LIMIT_YEARLY="" + + +# cleanup empty pre-post-pairs +EMPTY_PRE_POST_CLEANUP="yes" + +# limits for empty pre-post-pair cleanup +EMPTY_PRE_POST_MIN_AGE="1800" diff --git a/configs/root b/configs/root new file mode 100644 index 0000000..624c7e0 --- /dev/null +++ b/configs/root @@ -0,0 +1,61 @@ +# subvolume to snapshot +SUBVOLUME="/" + +# filesystem type +FSTYPE="btrfs" + + +# btrfs qgroup for space aware cleanup algorithms +QGROUP="" + + +# fraction or absolute size of the filesystems space the snapshots may use +SPACE_LIMIT="0.5" + +# fraction or absolute size of the filesystems space that should be free +FREE_LIMIT="0.2" + + +# users and groups allowed to work with config +ALLOW_USERS="" +ALLOW_GROUPS="" + +# sync users and groups from ALLOW_USERS and ALLOW_GROUPS to .snapshots +# directory +SYNC_ACL="yes" + + +# start comparing pre- and post-snapshot in background after creating +# post-snapshot +BACKGROUND_COMPARISON="yes" + + +# run daily number cleanup +NUMBER_CLEANUP="yes" + +# limit for number cleanup +NUMBER_MIN_AGE="1800" +NUMBER_LIMIT="20" +NUMBER_LIMIT_IMPORTANT="5" + + +# create hourly snapshots +TIMELINE_CREATE="no" + +# cleanup hourly snapshots after some time +TIMELINE_CLEANUP="yes" + +# limits for timeline cleanup +TIMELINE_MIN_AGE="1800" +TIMELINE_LIMIT_HOURLY="" +TIMELINE_LIMIT_DAILY="6" +TIMELINE_LIMIT_WEEKLY="2" +TIMELINE_LIMIT_MONTHLY="1" +TIMELINE_LIMIT_YEARLY="" + + +# cleanup empty pre-post-pairs +EMPTY_PRE_POST_CLEANUP="yes" + +# limits for empty pre-post-pair cleanup +EMPTY_PRE_POST_MIN_AGE="1800" diff --git a/debian/README.Debian b/debian/README.Debian index e3289eb..dddd82e 100644 --- a/debian/README.Debian +++ b/debian/README.Debian @@ -4,8 +4,8 @@ Optimizes the boot menu and the description in Snapper After a rollback with Snapper, siduction-btrfs sets the default boot entry to the rollback target. When using Grub: -The default boot entry points to the new default subvolume. -After rebooting into the new default subvolume, grub is installed from there. +After a rollback, the file /boot/grub/grub.cfg is recreated in the rollback +target using chroot and then GRUB is reinstalled from the rollback target. When using systemd-boot: siduction-btrfs generates new menu entries. All kernels present in the rollback target are taken into account. After deleting subvolumes, @@ -19,4 +19,4 @@ based on Debian SID. The functionality of grub-btrfs remains unaffected. - -- Axel Konrad Sun, 26 Jul 2024 19:30:07 +0200 + -- Axel Konrad Thu, 25 Jun 2026 14:12:32 +0200 diff --git a/debian/changelog b/debian/changelog index 883b707..d2a578a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +siduction-btrfs (0.4.1-1) unstable; urgency=medium + + * add preconfigs for root and home + * fix paths /usr/share/siduction/ => /usr/share/siduction-btrfs/ + * use debhelper for systemd-units + + -- Torsten Wohlfarth Mon, 22 Jun 2026 10:20:01 +0200 + siduction-btrfs (0.4.0-3) unstable; urgency=medium [Axel Konrad] diff --git a/debian/control b/debian/control index c2ebd58..c7e60b4 100644 --- a/debian/control +++ b/debian/control @@ -6,15 +6,18 @@ Build-Depends: debhelper-compat (= 13) Standards-Version: 4.6.2 Homepage: https://github.com/siduction/siduction-btrfs Rules-Requires-Root: no -#Vcs-Git: https://salsa.debian.org/debian/siduction-btrfs.git -#Vcs-Browser: https://salsa.debian.org/debian/siduction-btrfs +Vcs-Git: https://github.com/siduction/siduction-btrfs +Vcs-Browser: https://github.com/siduction/siduction-btrfs Package: siduction-btrfs Architecture: all Depends: btrfs-progs, snapper, + ucf, ${misc:Depends}, ${shlibs:Depends} +Recommends: grub-btrfs, + btrfs-assistant Description: Optimizes the boot menu and the description in Snapper After a rollback with Snapper, siduction-btrfs sets the default boot entry to the rollback target. diff --git a/debian/copyright b/debian/copyright index a1e19c1..20b13be 100644 --- a/debian/copyright +++ b/debian/copyright @@ -3,13 +3,14 @@ Upstream-Name: siduction-btrfs Upstream-Contact: ak-li@siduction.org Source: https://github.com/siduction/siduction-btrfs -Files: debian/* +Files: configs/* + debian/* 50-siduction.sh + 60-siduction-btrfs.preset 91-siduction-entry-key.install grub-menu-title.sh rollback-grub.sh rollback-sd-boot.sh - rolling siduction_btrfs.path siduction_btrfs.service siduction_btrfs.timer diff --git a/debian/files b/debian/files deleted file mode 100644 index fbb3a06..0000000 --- a/debian/files +++ /dev/null @@ -1 +0,0 @@ -siduction-btrfs_0.3.0-8_source.buildinfo utils optional diff --git a/debian/install b/debian/install index 4008f7c..5b919cd 100644 --- a/debian/install +++ b/debian/install @@ -1,9 +1,14 @@ -50-siduction.sh /usr/lib/snapper/plugins/ -91-siduction-entry-key.install /usr/lib/kernel/install.d/ -rollback-grub.sh /usr/share/siduction/ -rollback-sd-boot.sh /usr/share/siduction/ -snapshot-description.sh /usr/share/siduction/ -grub-menu-title.sh /usr/share/siduction/ -siduction_btrfs.service /usr/lib/systemd/system/ -siduction_btrfs.path /usr/lib/systemd/system/ -rolling /usr/share/snapper/config-templates/ +50-siduction.sh /usr/lib/snapper/plugins/ +91-siduction-entry-key.install /usr/lib/kernel/install.d/ +btrfs /usr/share/siduction-btrfs/ +rollback-grub.sh /usr/share/siduction-btrfs/ +rollback-sd-boot.sh /usr/share/siduction-btrfs/ +snapshot-description.sh /usr/share/siduction-btrfs/ +grub-menu-title.sh /usr/share/siduction-btrfs/ +configs/* /usr/share/snapper/config-templates/ +siduction_btrfs.service /usr/lib/systemd/system/ +siduction_btrfs.path /usr/lib/systemd/system/ +60-siduction-btrfs.preset /usr/lib/systemd/system-preset/ +Info.md /usr/share/docs/siduction-btrfs/ +LICENSE /usr/share/docs/siduction-btrfs/ +README.md /usr/share/docs/siduction-btrfs/ diff --git a/debian/postinst b/debian/postinst index a22d0a6..72acb27 100755 --- a/debian/postinst +++ b/debian/postinst @@ -5,9 +5,60 @@ set -e -exec $(systemctl daemon-reload) +case "$1" in + configure) + if ! snapper list-configs | grep -q "^root " 2>/dev/null; then + echo "Create snapper-configuration for root..." + snapper --no-dbus create-config -f btrfs / || true + rm -f /etc/snapper/configs/root + fi + if ! snapper list-configs | grep -q "^home " 2>/dev/null; then + echo "Create snapper-configuration for home..." + if [ -d /home ]; then + snapper --no-dbus -c home create-config -f btrfs /home || true + rm -f /etc/snapper/configs/home + fi + fi + # register existing snapper configs with UCF + if [ -x "/usr/bin/ucf" ]; then + echo "check for existing snapper-configurations..." + ucf --three-way /usr/share/siduction-btrfs/configs/root /etc/snapper/configs/root + ucf --three-way /usr/share/siduction-btrfs/configs/home /etc/snapper/configs/home + + ucfr siduction-btrfs /etc/snapper/configs/root + ucfr siduction-btrfs /etc/snapper/configs/home + else + # Fallback force copy default configs + cp -an /usr/share/siduction-btrfs/configs/root /etc/snapper/configs/root + cp -an /usr/share/siduction-btrfs/configs/home /etc/snapper/configs/home + fi + # checking chroot + if systemd-detect-virt --chroot >/dev/null 2>&1; then + echo "Running in chroot. Force deactivating snapper-timera ..." + rm -f /etc/systemd/system/timers.target.wants/snapper-boot.timer + rm -f /etc/systemd/system/timers.target.wants/snapper-timeline.timer + + if [ -x "/usr/bin/deb-systemd-helper" ]; then + deb-systemd-helper disable snapper-boot.timer >/dev/null 2>&1 || true + deb-systemd-helper disable snapper-timeline.timer >/dev/null 2>&1 || true + fi + else + if [ -d /run/systemd/system ]; then + echo "Set siduction systemd-presets for snapper ..." + systemctl --system daemon-reload || true + systemctl --system preset snapper-boot.timer || true + systemctl --system preset snapper-timeline.timer || true + fi + fi + ;; + abort-upgrade|abort-remove|abort-deconfigure) + ;; -exec $(systemctl enable --now siduction_btrfs.path) + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac #DEBHELPER# diff --git a/debian/postrm b/debian/postrm new file mode 100755 index 0000000..5981d44 --- /dev/null +++ b/debian/postrm @@ -0,0 +1,26 @@ +#!/bin/sh +set -e + +case "$1" in + purge) + # purgeing ucf registered files + if [ -x "/usr/bin/ucf" ]; then + ucf --purge /etc/snapper/configs/root + ucf --purge /etc/snapper/configs/home + ucfr --purge siduction-btrfs /etc/snapper/configs/root + ucfr --purge siduction-btrfs /etc/snapper/configs/home + fi + + # force delete snapper configs + rm -f /etc/snapper/configs/root + rm -f /etc/snapper/configs/home + + if [ -d /run/systemd/system ]; then + systemctl --system daemon-reload >/dev/null || true + fi + ;; +esac + +#DEBHELPER# + +exit 0 \ No newline at end of file diff --git a/debian/preinst b/debian/preinst index 006d10b..57fbe1b 100755 --- a/debian/preinst +++ b/debian/preinst @@ -45,13 +45,6 @@ fi ################################### -# For the new systemd units we need a file with the name -# of the file system type of the root directory. -fstypename="/usr/share/siduction/$(findmnt -n -o FSTYPE /)" -touch "$fstypename" -echo "DO NOT REMOVE THIS FILE!" >> "$fstypename" -echo "It is required by the siduction_btrfs systemd units." >> "$fstypename" - # Now we use the snapper plugin dir. if [ ! -d /usr/lib/snapper/plugins/ ]; then mkdir /usr/lib/snapper/plugins diff --git a/debian/prerm b/debian/prerm index b2c3516..679a571 100755 --- a/debian/prerm +++ b/debian/prerm @@ -5,19 +5,6 @@ set -e -# Remove the systemd condition file. -fstypename="/usr/share/siduction/$(findmnt -n -o FSTYPE /)" -if [ -e "$fstypename" ]; then - rm "$fstypename" -fi - -# Cleanup systemd unit. -if [ -e /etc/systemd/system/siduction_btrfs.path ]; then - rm /etc/systemd/system/siduction_btrfs.path -fi - -exec $(systemctl disable --now siduction_btrfs.path) - #DEBHELPER# exit 0 diff --git a/debian/rules b/debian/rules index 2d33f6a..0d72f34 100755 --- a/debian/rules +++ b/debian/rules @@ -2,3 +2,6 @@ %: dh $@ + +override_dh_installsystemd: + dh_installsystemd --name=siduction_btrfs --no-stop-on-upgrade diff --git a/debian/upstream/metadata b/debian/upstream/metadata index 10b0a70..619e223 100644 --- a/debian/upstream/metadata +++ b/debian/upstream/metadata @@ -6,7 +6,7 @@ Reference: Author: Axel Konrad Title: siduction-btrfs Journal: - Year: 2024 + Year: 2026 Volume: Number: Pages: diff --git a/grub-menu-title.sh b/grub-menu-title.sh index 2102a22..a78fbf4 100755 --- a/grub-menu-title.sh +++ b/grub-menu-title.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Name: /usr/share/siduction/grub-menu-title.sh +# Name: /usr/share/siduction-btrfs/grub-menu-title.sh # Part of siduction-btrfs # Called by /usr/lib/systemd/system/siduction_grubmenutitle.service # or /usr/lib/snapper/plugins/50-siduction.sh diff --git a/rollback-grub.sh b/rollback-grub.sh index c2e4209..fa4ed59 100755 --- a/rollback-grub.sh +++ b/rollback-grub.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Name: /usr/share/siduction/rollback-grub.sh +# Name: /usr/share/siduction-btrfs/rollback-grub.sh # Part of siduction-btrfs # Called by /usr/lib/snapper/plugins/50-siduction.sh # diff --git a/rollback-sd-boot.sh b/rollback-sd-boot.sh index 9efe345..949a43c 100755 --- a/rollback-sd-boot.sh +++ b/rollback-sd-boot.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Name: /usr/share/siduction/rollback-sd-boot.sh +# Name: /usr/share/siduction-btrfs/rollback-sd-boot.sh # Part of siduction-btrfs # Called by /usr/lib/snapper/plugins/50-siduction.sh # Creates new boot entries after a "snapper rollback" command. diff --git a/siduction_btrfs.path b/siduction_btrfs.path index a28048e..5abe221 100644 --- a/siduction_btrfs.path +++ b/siduction_btrfs.path @@ -3,9 +3,8 @@ Description=Part of siduction-btrfs Description=Monitors changes of grub.cfg Documentation=https://github.com/siduction/siduction-btrfs -After=siduction_btrfs.service ConditionPathExists=/boot/grub/grub.cfg -ConditionPathExists=/usr/share/siduction/btrfs +ConditionPathExists=/usr/share/siduction-btrfs/btrfs [Path] PathChanged=/boot/grub/grub.cfg diff --git a/siduction_btrfs.service b/siduction_btrfs.service index 8559645..1c179a1 100644 --- a/siduction_btrfs.service +++ b/siduction_btrfs.service @@ -1,12 +1,11 @@ # /usr/lib/systemd/system/siduction_btrfs.service [Unit] -Description=Part of siduction-btrfs +Description=TUXEDO BTRFS Service Description=Update GRUB menu title. Documentation=https://github.com/siduction/siduction-btrfs -Before=siduction_btrfs.path ConditionPathExists=/boot/grub/grub.cfg -ConditionPathExists=/usr/share/siduction/btrfs +ConditionPathExists=/usr/share/siduction-btrfs/btrfs [Service] Type=oneshot -ExecStart=/usr/share/siduction/grub-menu-title.sh +ExecStart=/usr/share/siduction-btrfs/grub-menu-title.sh diff --git a/snapshot-description.sh b/snapshot-description.sh index 9dbe911..47650ed 100755 --- a/snapshot-description.sh +++ b/snapshot-description.sh @@ -1,6 +1,6 @@ #!/usr/bin/bash # -# Name: /usr/share/siduction/snapshot-description.sh +# Name: /usr/share/siduction-btrfs/snapshot-description.sh # Part of siduction-btrfs # Called by /usr/lib/snapper/plugins/50-siduction.sh #