From 54f80d7f80bea2ebd0cf2ebc5385c97149e0af1e Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 07:14:46 +0900 Subject: [PATCH] Refactoed common function These common function is renamed with _common explicitly. --- ...confirmation.sh => confirmation_common.sh} | 2 +- ...stall_msg.sh => parainstall_msg_common.sh} | 2 +- .../{preinstall.sh => preinstall_common.sh} | 2 +- script/ubuntu-kaiten-yaki.sh | 28 +++++++++---------- script/void-kaiten-yaki.sh | 23 ++++++++------- 5 files changed, 28 insertions(+), 29 deletions(-) rename script/lib/{confirmation.sh => confirmation_common.sh} (99%) rename script/lib/{parainstall_msg.sh => parainstall_msg_common.sh} (95%) rename script/lib/{preinstall.sh => preinstall_common.sh} (99%) diff --git a/script/lib/confirmation.sh b/script/lib/confirmation_common.sh similarity index 99% rename from script/lib/confirmation.sh rename to script/lib/confirmation_common.sh index 768c52d..ddf6caa 100644 --- a/script/lib/confirmation.sh +++ b/script/lib/confirmation_common.sh @@ -3,7 +3,7 @@ # Confirmation and Passphrase setting # ******************************************************************************* -function confirmation(){ +function confirmation_common(){ # Consistency check for the OVERWRITEINSTALL and ERASEALL if [ ${ERASEALL} -eq 1 -a ${OVERWRITEINSTALL} -eq 1 ] ; then diff --git a/script/lib/parainstall_msg.sh b/script/lib/parainstall_msg_common.sh similarity index 95% rename from script/lib/parainstall_msg.sh rename to script/lib/parainstall_msg_common.sh index 3b84a88..84abf42 100644 --- a/script/lib/parainstall_msg.sh +++ b/script/lib/parainstall_msg_common.sh @@ -1,6 +1,6 @@ #!/bin/bash -u -function parainstall_msg() { +function para_install_msg_common() { cat <<- HEREDOC ****************************************************************************** diff --git a/script/lib/preinstall.sh b/script/lib/preinstall_common.sh similarity index 99% rename from script/lib/preinstall.sh rename to script/lib/preinstall_common.sh index fe13d6f..82d679c 100644 --- a/script/lib/preinstall.sh +++ b/script/lib/preinstall_common.sh @@ -3,7 +3,7 @@ # Pre-install stage # ******************************************************************************* -function pre_install() { +function pre_install_common() { # ----- Erase entire disk, create partitions, format them and encrypt the LUKS partition ----- diff --git a/script/ubuntu-kaiten-yaki.sh b/script/ubuntu-kaiten-yaki.sh index 77420c9..11c1c0a 100644 --- a/script/ubuntu-kaiten-yaki.sh +++ b/script/ubuntu-kaiten-yaki.sh @@ -5,9 +5,9 @@ function main() { source config.sh # Load functions - source lib/confirmation.sh - source lib/preinstall.sh - source lib/parainstall_msg.sh + source lib/confirmation_common.sh + source lib/pre_install_common.sh + source lib/para_install_msg_common.sh # This is the mount point of the install target. @@ -38,7 +38,7 @@ function main() { # ******************************************************************************* # Common part of the parameter confirmation - if ! confirmation ; then + if ! confirmation_common ; then return 1 # with error status fi @@ -47,7 +47,7 @@ function main() { # ******************************************************************************* # Common part of the pre-install stage - if ! pre_install ; then + if ! pre_install_common ; then return 1 # with error status fi @@ -57,7 +57,7 @@ function main() { # ******************************************************************************* # Show common message to let the operator focus on the critical part - parainstall_msg + para_install_msg_common # Ubuntu dependent message cat <<- HEREDOC @@ -80,10 +80,10 @@ function main() { # Record the PID of the installer. export INSTALLER_PID=$! - # Common part of the para-install. + # Record the install PID, modify the /etc/default/grub of the target, - # and then, wait for the end of sintaller. - if ! grub_check_and_modify_ubuntu ; then + # and then, wait for the end of the intaller. + if ! grub_check_and_modify ; then return 1 # with error status fi @@ -92,7 +92,7 @@ function main() { # ******************************************************************************* # Finalizing. Embedd encryption key into the ramfs image. - post_install_ubuntu + post_install # Normal end return 0 @@ -102,7 +102,7 @@ function main() { # ******************************************************************************* # Ubuntu dependent post-installation process -function post_install_ubuntu() { +function post_install() { ## Mount the target file system # ${TARGETMOUNTPOINT} is created by the GUI/TUI installer echo "...Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${TARGETMOUNTPOINT}." @@ -162,12 +162,12 @@ function post_install_ubuntu() { retrun 0 -} # End of post_install_ubuntu() +} # End of post_install() # ******************************************************************************* # This function will be executed in the foreguround context, to watch the GUI installer. -function grub_check_and_modify_ubuntu() { +function grub_check_and_modify() { # While the /etc/default/grub in the install target is NOT existing, keep sleeping. # If installer terminated without file copy, this script also terminates. @@ -211,7 +211,7 @@ function grub_check_and_modify_ubuntu() { # succesfull return return 0 -} # grub_check_and_modify_ubuntu() +} # grub_check_and_modify() # ******************************************************************************* # Execute diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index b5c4c09..ffc1e53 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -5,9 +5,9 @@ function main() { source config.sh # Load functions - source lib/confirmation.sh - source lib/preinstall.sh - source lib/parainstall_msg.sh + source lib/confirmation_common.sh + source lib/pre_install_common.sh + source lib/para_install_msg_common.sh # This is the mount point of the install target. @@ -38,7 +38,7 @@ function main() { # ******************************************************************************* # Common part of the parameter confirmation - if ! confirmation ; then + if ! confirmation_common ; then return 1 # with error status fi @@ -50,7 +50,7 @@ function main() { xbps-install -y -Su xbps gptfdisk # Common part of the pre-install stage - if ! pre_install ; then + if ! pre_install_common ; then return 1 # with error status fi @@ -66,7 +66,8 @@ function main() { # ******************************************************************************* # Show common message to let the operator focus on the critical part - parainstall_msg + para_install_msg_common + # Void-Linux dependent message cat <<- HEREDOC @@ -112,14 +113,12 @@ function main() { return 1 # with error status fi - # At here, the installation was successful. - # ******************************************************************************* # Post-install stage # ******************************************************************************* # Finalizing. Embedd encryption key into the ramfs image. - post_install_void + post_install # Normal end return 0 @@ -129,7 +128,7 @@ function main() { # ******************************************************************************* # Void Linux dependent post-installation process -function post_install_void() { +function post_install() { ## Mount the target file system # ${TARGETMOUNTPOINT} is created by the GUI/TUI installer echo "...Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${TARGETMOUNTPOINT}." @@ -192,7 +191,7 @@ function post_install_void() { retrun 0 -} # End of post_install_void() +} # End of post_install() # ******************************************************************************* @@ -217,7 +216,7 @@ function grub_check_and_modify_void() { # succesfull return return 0 -} # gurb_check_and_modify_void() +} # grub_check_and_modify() # ******************************************************************************* # Execute