feat: ✨ add cleaning facilities
This commit is contained in:
parent
7282ad8025
commit
473c2e9a61
@ -4,3 +4,6 @@ echo "installed creation script."
|
||||
|
||||
cp ./pacman/* /usr/share/libalpm/hooks/
|
||||
echo "installed pacman hooks."
|
||||
|
||||
cp ./systemd/* /etc/systemd/system/
|
||||
echo "installed systemd unit files"
|
||||
|
@ -151,6 +151,19 @@ function main
|
||||
cp "$CFG_BUILD_DIR/current/arch-linux-fallback.efi" "$CFG_UKI_DIR"
|
||||
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 "*"
|
||||
error "unknown command"
|
||||
end
|
||||
|
6
systemd/snap-pac-uki-cleanup.service
Normal file
6
systemd/snap-pac-uki-cleanup.service
Normal file
@ -0,0 +1,6 @@
|
||||
[Unit]
|
||||
Description=cleaning up ukis
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/bin/snap-pac-uki clean
|
9
systemd/snap-pac-uki-cleanup.timer
Normal file
9
systemd/snap-pac-uki-cleanup.timer
Normal file
@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description="timer for triggering uki cleanup
|
||||
|
||||
[Timer]
|
||||
OnBootSec=15min
|
||||
OnUnitActiveSec=1d
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
Loading…
Reference in New Issue
Block a user