feat: add cleaning facilities

This commit is contained in:
Adrian Wannenmacher 2021-02-12 02:05:34 +01:00
parent 7282ad8025
commit 473c2e9a61
Signed by: tfld
GPG Key ID: 19D986ECB1E492D5
4 changed files with 31 additions and 0 deletions

View File

@ -4,3 +4,6 @@ echo "installed creation script."
cp ./pacman/* /usr/share/libalpm/hooks/ cp ./pacman/* /usr/share/libalpm/hooks/
echo "installed pacman hooks." echo "installed pacman hooks."
cp ./systemd/* /etc/systemd/system/
echo "installed systemd unit files"

View File

@ -151,6 +151,19 @@ function main
cp "$CFG_BUILD_DIR/current/arch-linux-fallback.efi" "$CFG_UKI_DIR" cp "$CFG_BUILD_DIR/current/arch-linux-fallback.efi" "$CFG_UKI_DIR"
echo " -> copied ukis into uki directory" echo " -> copied ukis into uki directory"
case "clean"
echo "==> cleaning ukis"
set ids (snapper -c $CFG_SNAPSHOT_CONFIG --jsonout ls | jq ".$CFG_SNAPSHOT_CONFIG [] | .number")
for uki in (ls "$CFG_UKI_DIR" | rg "[0-9]" | sed "s/arch-linux-\([0-9]*\).efi/\1/")
if not contains "$uki" $ids
echo " -> cleaning uki and boot entry for removed snapshot $uki"
rm "$CFG_UKI_DIR/arch-linux-$uki.efi"
efibootmgr -q -b (efibootmgr -v | rg "arch-linux-$uki.efi" | sed "s/\*//;s/Boot0*\(.*\) Arch .*/\1/") -B
end
end
case "*" case "*"
error "unknown command" error "unknown command"
end end

View File

@ -0,0 +1,6 @@
[Unit]
Description=cleaning up ukis
[Service]
Type=oneshot
ExecStart=/usr/local/bin/snap-pac-uki clean

View File

@ -0,0 +1,9 @@
[Unit]
Description="timer for triggering uki cleanup
[Timer]
OnBootSec=15min
OnUnitActiveSec=1d
[Install]
WantedBy=timers.target