]> git.proxmox.com Git - pve-kernel-meta.git/commitdiff
rename pveesptool to pve-efiboot-tool
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 10 Jul 2019 19:11:28 +0000 (21:11 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 10 Jul 2019 19:11:28 +0000 (21:11 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
bin/Makefile
bin/pve-efiboot-tool [new file with mode: 0755]
bin/pveesptool [deleted file]
debian/pve-kernel-helper.install

index c5ac674dddf80fc5be710dc0215d8d99b92be461..058c86f52567d73213d7840c439657516d9b4665 100644 (file)
@@ -5,7 +5,7 @@ all:
 
 install:
        install -d ${SBINDIR}
-       install -m 0755 pveesptool ${SBINDIR}/
+       install -m 0755 pve-efiboot-tool ${SBINDIR}/
 
 .PHONY: clean distclean
 distclean:
diff --git a/bin/pve-efiboot-tool b/bin/pve-efiboot-tool
new file mode 100755 (executable)
index 0000000..6bbf679
--- /dev/null
@@ -0,0 +1,220 @@
+#!/bin/sh
+
+set -e
+
+. /usr/share/pve-kernel-helper/scripts/functions
+
+
+_get_partition_info() {
+       if [ ! -e "$1" ]; then
+               warn "E: '$1' does not exist!"
+               exit 1
+       fi
+       bdev=$(realpath "$1")
+       if [ ! -b "$bdev" ]; then
+               warn "E: '$bdev' is not a block device!"
+               exit 1
+       fi
+
+       bdev_info=$( \
+                 lsblk \
+                 --bytes \
+                 --pairs \
+                 -o 'UUID,SIZE,FSTYPE,PARTTYPE,PKNAME,MOUNTPOINT' \
+                 "$bdev" \
+                 )
+       if [ -z "$bdev_info" ]; then
+               warn "E: unable to get information about block device '$1'!"
+               exit 1
+       fi
+
+       count=$(echo "$bdev_info" | grep -c '^')
+       if [ "$count" -ne '1' ]; then
+               echo "$bdev_info"
+               warn "E: block device '$1' has children!"
+               exit 1
+       fi
+
+       echo "$bdev_info"
+       eval "$bdev_info"
+
+       if [ -z "$PKNAME" ]; then
+               warn "E: cannot determine parent device of '$1' - please provide a partition, not a full disk."
+               exit 1
+       fi
+
+       if [ -n "$SIZE" ] && [ "$SIZE" -lt 268435456 ]; then
+               warn "E: '$1' is too small (<256M)."
+               exit 1
+       fi
+
+       if [ -n "$MOUNTPOINT" ]; then
+               warn "E: '$1' is mounted on '$MOUNTPOINT' - exiting."
+               exit 1
+       fi
+}
+
+format() {
+       part="$1"
+       force="$2"
+
+       _get_partition_info "$part"
+
+       if [ -n "$FSTYPE" ]; then
+               if [ -z "$force" ] || [ "$force" != '--force' ]; then
+                       warn "E: '$part' contains a filesystem ('$FSTYPE') - exiting (use --force to override)"
+                       exit 1
+               fi
+       fi
+
+       part_basename=$(basename "$part")
+       if [ -z "$part_basename" ]; then
+               warn "E: unable to determine basename of '$part'"
+               exit 1
+       fi
+
+       part_num=$(cat /sys/block/"$PKNAME"/"$part_basename"/partition)
+       if [ -z "$part_num" ]; then
+               warn "E: unable to determine partition number of '$part'"
+               exit 1
+       fi
+
+       if [ -z "$PARTTYPE" ] || [ "$PARTTYPE" != "$ESPTYPE" ]; then
+               echo "Setting partition type of '$part' to '$ESPTYPE'.."
+               sgdisk "-t$part_num:$ESPTYPE" "/dev/$PKNAME"
+               echo "Calling 'udevadm settle'.."
+               udevadm settle --timeout=5
+       fi
+
+       echo "Formatting '$part' as vfat.."
+       mkfs.vfat -F 32 "$part"
+       echo "Done."
+       exit 0
+}
+
+init() {
+       part="$1"
+
+       _get_partition_info "$part"
+
+       if [ -z "$PARTTYPE" ] || [ "$PARTTYPE" != "$ESPTYPE" ]; then
+               warn "E: '$part' has wrong partition type (!= $ESPTYPE)."
+               exit 1
+       fi
+
+       if [ -z "$FSTYPE" ] || [ "$FSTYPE" != 'vfat' ]; then
+               warn "E: '$part' has wrong filesystem (!= vfat)."
+               exit 1
+       fi
+
+       if [ -z "$UUID" ]; then
+               warn "E: '$part' has no UUID set, required for mounting."
+               exit 1
+       fi
+
+       esp_mp="/var/tmp/espmounts/$UUID"
+
+       mkdir -p "$esp_mp"
+       echo "Mounting '$part' on '$esp_mp'."
+       mount -t vfat "$part" "$esp_mp"
+
+       echo "Installing systemd-boot.."
+       mkdir -p "$esp_mp/$PMX_ESP_DIR"
+       bootctl --path "$esp_mp" install
+
+       echo "Configuring systemd-boot.."
+       echo "timeout 3" > "$esp_mp/$PMX_LOADER_CONF.tmp"
+       echo "default proxmox-*" >> "$esp_mp/$PMX_LOADER_CONF.tmp"
+       mv "$esp_mp/$PMX_LOADER_CONF.tmp" "$esp_mp/$PMX_LOADER_CONF"
+       echo "Unmounting '$part'."
+       umount "$part"
+
+       echo "Adding '$part' to list of synced ESPs.."
+       if [ -e "$ESP_LIST" ]; then
+               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.."
+       refresh
+}
+
+refresh() {
+       hookscript='/etc/kernel/postinst.d/zz-pve-efiboot'
+       echo "Running hook script '$hookscript'.."
+       exec $hookscript
+}
+
+usage() {
+       warn "USAGE: $0 <commands> [ARGS]"
+       warn ""
+       warn "       $0 format <partition> [--force]"
+       warn "       $0 init <partition>"
+       warn "       $0 refresh"
+       warn "       $0 help"
+}
+
+help() {
+       echo "USAGE: $0 format <partition> [--force]"
+       echo ""
+       echo "    format <partition> as EFI system partition. Use --force to format even if <partition> is currently in use."
+       echo ""
+       echo "USAGE: $0 init <partition>"
+       echo ""
+       echo "    initialize EFI system partition at <partition> for automatic synchronization of pve-kernels and their associated initrds."
+       echo ""
+       echo "USAGE: $0 refresh"
+       echo ""
+       echo "    refresh all configured EFI system partitions."
+       echo ""
+}
+
+if [ -z "$1" ]; then
+    usage
+    exit 0
+fi
+
+case "$1" in
+       'format')
+               shift
+               if [ -z "$1"  ]; then
+                       warn "E: <partition> is mandatory."
+                       warn ""
+                       usage
+                       exit 1
+               fi
+               format "$@"
+               exit 0
+       ;;
+       'init')
+               shift
+               if [ -z "$1"  ]; then
+                       warn "E: <partition> is mandatory."
+                       warn ""
+                       usage
+                       exit 1
+               fi
+               init "$@"
+               exit 0
+       ;;
+       'refresh')
+               shift
+               refresh
+               exit 0
+       ;;
+       'help')
+               shift
+               help
+               exit 0
+       ;;
+       *)
+               warn "Invalid/unknown command '$1'."
+               warn ""
+               usage
+               exit 1
+       ;;
+esac
+
+exit 1
diff --git a/bin/pveesptool b/bin/pveesptool
deleted file mode 100755 (executable)
index 6bbf679..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-#!/bin/sh
-
-set -e
-
-. /usr/share/pve-kernel-helper/scripts/functions
-
-
-_get_partition_info() {
-       if [ ! -e "$1" ]; then
-               warn "E: '$1' does not exist!"
-               exit 1
-       fi
-       bdev=$(realpath "$1")
-       if [ ! -b "$bdev" ]; then
-               warn "E: '$bdev' is not a block device!"
-               exit 1
-       fi
-
-       bdev_info=$( \
-                 lsblk \
-                 --bytes \
-                 --pairs \
-                 -o 'UUID,SIZE,FSTYPE,PARTTYPE,PKNAME,MOUNTPOINT' \
-                 "$bdev" \
-                 )
-       if [ -z "$bdev_info" ]; then
-               warn "E: unable to get information about block device '$1'!"
-               exit 1
-       fi
-
-       count=$(echo "$bdev_info" | grep -c '^')
-       if [ "$count" -ne '1' ]; then
-               echo "$bdev_info"
-               warn "E: block device '$1' has children!"
-               exit 1
-       fi
-
-       echo "$bdev_info"
-       eval "$bdev_info"
-
-       if [ -z "$PKNAME" ]; then
-               warn "E: cannot determine parent device of '$1' - please provide a partition, not a full disk."
-               exit 1
-       fi
-
-       if [ -n "$SIZE" ] && [ "$SIZE" -lt 268435456 ]; then
-               warn "E: '$1' is too small (<256M)."
-               exit 1
-       fi
-
-       if [ -n "$MOUNTPOINT" ]; then
-               warn "E: '$1' is mounted on '$MOUNTPOINT' - exiting."
-               exit 1
-       fi
-}
-
-format() {
-       part="$1"
-       force="$2"
-
-       _get_partition_info "$part"
-
-       if [ -n "$FSTYPE" ]; then
-               if [ -z "$force" ] || [ "$force" != '--force' ]; then
-                       warn "E: '$part' contains a filesystem ('$FSTYPE') - exiting (use --force to override)"
-                       exit 1
-               fi
-       fi
-
-       part_basename=$(basename "$part")
-       if [ -z "$part_basename" ]; then
-               warn "E: unable to determine basename of '$part'"
-               exit 1
-       fi
-
-       part_num=$(cat /sys/block/"$PKNAME"/"$part_basename"/partition)
-       if [ -z "$part_num" ]; then
-               warn "E: unable to determine partition number of '$part'"
-               exit 1
-       fi
-
-       if [ -z "$PARTTYPE" ] || [ "$PARTTYPE" != "$ESPTYPE" ]; then
-               echo "Setting partition type of '$part' to '$ESPTYPE'.."
-               sgdisk "-t$part_num:$ESPTYPE" "/dev/$PKNAME"
-               echo "Calling 'udevadm settle'.."
-               udevadm settle --timeout=5
-       fi
-
-       echo "Formatting '$part' as vfat.."
-       mkfs.vfat -F 32 "$part"
-       echo "Done."
-       exit 0
-}
-
-init() {
-       part="$1"
-
-       _get_partition_info "$part"
-
-       if [ -z "$PARTTYPE" ] || [ "$PARTTYPE" != "$ESPTYPE" ]; then
-               warn "E: '$part' has wrong partition type (!= $ESPTYPE)."
-               exit 1
-       fi
-
-       if [ -z "$FSTYPE" ] || [ "$FSTYPE" != 'vfat' ]; then
-               warn "E: '$part' has wrong filesystem (!= vfat)."
-               exit 1
-       fi
-
-       if [ -z "$UUID" ]; then
-               warn "E: '$part' has no UUID set, required for mounting."
-               exit 1
-       fi
-
-       esp_mp="/var/tmp/espmounts/$UUID"
-
-       mkdir -p "$esp_mp"
-       echo "Mounting '$part' on '$esp_mp'."
-       mount -t vfat "$part" "$esp_mp"
-
-       echo "Installing systemd-boot.."
-       mkdir -p "$esp_mp/$PMX_ESP_DIR"
-       bootctl --path "$esp_mp" install
-
-       echo "Configuring systemd-boot.."
-       echo "timeout 3" > "$esp_mp/$PMX_LOADER_CONF.tmp"
-       echo "default proxmox-*" >> "$esp_mp/$PMX_LOADER_CONF.tmp"
-       mv "$esp_mp/$PMX_LOADER_CONF.tmp" "$esp_mp/$PMX_LOADER_CONF"
-       echo "Unmounting '$part'."
-       umount "$part"
-
-       echo "Adding '$part' to list of synced ESPs.."
-       if [ -e "$ESP_LIST" ]; then
-               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.."
-       refresh
-}
-
-refresh() {
-       hookscript='/etc/kernel/postinst.d/zz-pve-efiboot'
-       echo "Running hook script '$hookscript'.."
-       exec $hookscript
-}
-
-usage() {
-       warn "USAGE: $0 <commands> [ARGS]"
-       warn ""
-       warn "       $0 format <partition> [--force]"
-       warn "       $0 init <partition>"
-       warn "       $0 refresh"
-       warn "       $0 help"
-}
-
-help() {
-       echo "USAGE: $0 format <partition> [--force]"
-       echo ""
-       echo "    format <partition> as EFI system partition. Use --force to format even if <partition> is currently in use."
-       echo ""
-       echo "USAGE: $0 init <partition>"
-       echo ""
-       echo "    initialize EFI system partition at <partition> for automatic synchronization of pve-kernels and their associated initrds."
-       echo ""
-       echo "USAGE: $0 refresh"
-       echo ""
-       echo "    refresh all configured EFI system partitions."
-       echo ""
-}
-
-if [ -z "$1" ]; then
-    usage
-    exit 0
-fi
-
-case "$1" in
-       'format')
-               shift
-               if [ -z "$1"  ]; then
-                       warn "E: <partition> is mandatory."
-                       warn ""
-                       usage
-                       exit 1
-               fi
-               format "$@"
-               exit 0
-       ;;
-       'init')
-               shift
-               if [ -z "$1"  ]; then
-                       warn "E: <partition> is mandatory."
-                       warn ""
-                       usage
-                       exit 1
-               fi
-               init "$@"
-               exit 0
-       ;;
-       'refresh')
-               shift
-               refresh
-               exit 0
-       ;;
-       'help')
-               shift
-               help
-               exit 0
-       ;;
-       *)
-               warn "Invalid/unknown command '$1'."
-               warn ""
-               usage
-               exit 1
-       ;;
-esac
-
-exit 1
index 283459d6809f5cfb3fa5f847608e8200c6d40489..ad265a5712c919a02b712f8fd002f174e1692c65 100644 (file)
@@ -1,4 +1,4 @@
 etc/kernel/postinst.d/*
 etc/kernel/postrm.d/*
-usr/sbin/pveesptool
+usr/sbin/pve-efiboot-tool
 usr/share/pve-kernel-helper/scripts/functions