From f9e5de33641d363fd3dc0c13ea7fdd970d4a4219 Mon Sep 17 00:00:00 2001 From: Alexander Zhirov Date: Mon, 14 Oct 2024 15:23:10 +0300 Subject: [PATCH] fix errors --- install.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index b98e410..1a62a15 100755 --- a/install.sh +++ b/install.sh @@ -2,10 +2,18 @@ [ ${GFU_DEBUG} ] && set -x +# set -x + SCRIPT_NAME="${0}" SCRIPT_PATH=$(realpath ${SCRIPT_NAME}) -# [ ! "$(id -u)" == 0 ] && echo "Need to run as superuser" && exit 1 +GFU_PARTED=$(which parted 2>/dev/null) +GFU_GRUB=$(which grub-install 2>/dev/null) + +[ -z "${GFU_PARTED}" ] && echo "The parted utility is not installed" && exit 1 +[ -z "${GFU_GRUB}" ] && echo "The grub-install utility is not installed" && exit 1 + +[ ! "$(id -u)" == 0 ] && echo "Need to run as superuser" && exit 1 main () { local GFU_KEY="" @@ -96,6 +104,13 @@ main () { esac done + for partition in $(mount | grep "${GFU_DEVICE}[0-9]" | awk '{print $1}') ; do + if ! umount -f ${partition} ; then + echo "Failed to unmount ${partition}" + exit 1 + fi + done + if ${GFU_LEGACY_MODE} ; then parted ${GFU_DEVICE} -s mklabel msdos else