mirror of
https://git.proxmox.com/git/pve-kernel-meta
synced 2025-08-14 22:19:13 +00:00
pve-efiboot-tool: add and use list file helpers
in preparation of adding another file for custom kernels with the same semantics Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
4bd56b83e1
commit
2955b2b7fe
@ -4,6 +4,35 @@ set -e
|
|||||||
|
|
||||||
. /usr/share/pve-kernel-helper/scripts/functions
|
. /usr/share/pve-kernel-helper/scripts/functions
|
||||||
|
|
||||||
|
_add_entry_to_list_file() {
|
||||||
|
file="$1"
|
||||||
|
entry="$2"
|
||||||
|
|
||||||
|
if [ -e "$file" ]; then
|
||||||
|
cp "$file" "$file.new"
|
||||||
|
fi
|
||||||
|
echo "$entry" >> "$file.new"
|
||||||
|
sort -uo "$file.new" "$file.new"
|
||||||
|
mv "$file.new" "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
_remove_entry_from_list_file() {
|
||||||
|
file="$1"
|
||||||
|
entry="$2"
|
||||||
|
|
||||||
|
# guard against removing whole file by accident!
|
||||||
|
if [ -z "$entry" ]; then
|
||||||
|
echo "cannot remove empty entry from '$file'."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e "$file" ]; then
|
||||||
|
grep -vFx "$entry" "$file" > "$file.new" || true
|
||||||
|
mv "$file.new" "$file"
|
||||||
|
else
|
||||||
|
echo "'$file' does not exist.."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
_get_partition_info() {
|
_get_partition_info() {
|
||||||
if [ ! -e "$1" ]; then
|
if [ ! -e "$1" ]; then
|
||||||
@ -130,12 +159,7 @@ init() {
|
|||||||
umount "$part"
|
umount "$part"
|
||||||
|
|
||||||
echo "Adding '$part' to list of synced ESPs.."
|
echo "Adding '$part' to list of synced ESPs.."
|
||||||
if [ -e "$ESP_LIST" ]; then
|
_add_entry_to_list_file "$ESP_LIST" "$UUID"
|
||||||
cp "$ESP_LIST" "$ESP_LIST.new"
|
|
||||||
fi
|
|
||||||
echo "$UUID" >> "$ESP_LIST.new"
|
|
||||||
sort -uo "$ESP_LIST.new" "$ESP_LIST.new"
|
|
||||||
mv "$ESP_LIST.new" "$ESP_LIST"
|
|
||||||
|
|
||||||
echo "Refreshing kernels and initrds.."
|
echo "Refreshing kernels and initrds.."
|
||||||
refresh
|
refresh
|
||||||
|
Loading…
Reference in New Issue
Block a user