File: cleanup.in

package info (click to toggle)
fwupdate 12-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 588 kB
  • sloc: ansic: 4,329; makefile: 358; sh: 49
file content (31 lines) | stat: -rwxr-xr-x 791 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
set -e
if [ -e "@@SHAREDSTATEDIR@@/fwupdate/done" ]; then
	exit 0
fi

efibootmgr -q

BOOTNUM=$(efibootmgr | grep "Linux.Firmware.Updater" | sed "s/\ .*//; s/*//; s/Boot//")
if [ -n "$BOOTNUM" ]; then
	for num in $BOOTNUM; do
		efibootmgr -q -b "$num" -B
	done
fi


for x in @@ESPMOUNTPOINT@@/EFI/@@EFIDIR@@/fw/fwupdate-* ; do
	if [ "${x}" != "@@ESPMOUNTPOINT@@/EFI/@@EFIDIR@@/fw/fwupdate-*" ]; then
		rm -f "${x}"
	fi
done
for x in /sys/firmware/efi/efivars/fwupdate-*-0abba7dc-e516-4167-bbf5-4d9d1c739416 ; do
	if [ "${x}" != "/sys/firmware/efi/efivars/fwupdate-*-0abba7dc-e516-4167-bbf5-4d9d1c739416" ]; then
		if lsattr "${x}" 2>/dev/null | cut -d\  -f1 | cut -d- -f5 | grep -q i ; then
			chattr -i "${x}"
		fi
		rm -f "${x}"
	fi
done

touch "@@SHAREDSTATEDIR@@/fwupdate/done"