From 95d8c6f62cfc1281194364647975af2f068ba15f Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 4 Jul 2021 21:54:29 +0900 Subject: [PATCH] Add and adjust erro rhanding. Add error handling afer dd. Error message of pre-install is now conditional. --- script/lib.sh | 1 + script/void-kaiten-yaki.sh | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/script/lib.sh b/script/lib.sh index 895f331..c9c207e 100644 --- a/script/lib.sh +++ b/script/lib.sh @@ -158,6 +158,7 @@ function pre_install() { # Zap existing partition table echo "...Erasing partition table of \"${DEV}\"." dd if=/dev/zero of="${DEV}" bs=512 count=1 + if is_error ; then return 1 ; fi; # If error, terminate # Create MBR and allocate max storage for Linux partition echo "...Creating a Linux partition on ${DEV} with MBR." sfdisk "${DEV}" <<- HEREDOC diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index 6dd8da4..87cfcd4 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -56,8 +56,8 @@ function main() { # Common part of the pre-install stage if ! pre_install ; then # If error, restore the modification. - echo "...restoring modified /etc/default/grub." - sed -i -e "s#loglevel=4 ${GRUB_ADDITIONAL_PARAMETERS}#loglevel=4#" /etc/default/grub + echo "...restoring /etc/default/grub, if needed" + sed -i -e "s#${GRUB_ADDITIONAL_PARAMETERS}##" /etc/default/grub return 1 # with error status fi