From 2fe693aa72dfc55bce2f5ba48a273b69835892e6 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Fri, 2 Jul 2021 22:01:15 +0900 Subject: [PATCH 01/35] Revise the install.md --- INSTALL.md | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 6a8df17..d6ac499 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -5,15 +5,13 @@ Installation requires mainly 2 steps. - Configure the parameters in config.sh. - Run the kaiten-yaki script -Each script have to be executed as sourced style. For example : +You can execute the install script without command line parameter. For example : ```shell source ubuntu-kaiten-yaki.sh ``` -If you execute these script as independent command style, it will show an error message and terminate the process immediately. - The first stage of the script is preparation like : erasing disk, format partition, and encryption. This is most critical stage of the entire installation process. This part is controlled by the configuration parameter. Thus, you have to edit the config.txt carefully. -In the second stage, the distribution dependent installer is invoked. That is the Ubiquity/void-installer of Ubuntu/Void linux, respectively. +In the second stage, the distribution dependent GUI/TUI installer is invoked from the running script. That is the Ubiquity/void-installer of Ubuntu/Void linux, respectively. The third stage is easy. There is nothing user can do. Everything is automatic. # Installation @@ -33,16 +31,17 @@ sudo -i bash xbps-install -Su xbps nano ``` -The nano is editor package to configure the config.txt. The editor choice is up to you. Kaiten-yaki script doesn't use any editor during execution. +The nano is editor package to configure the config.txt. The editor choice is up to you. Kaiten-yaki script doesn't have dependency to nano editor. Then, edit the config.txt. ## Configuration parameters -This is very critical part of the installation. The configuration parameters are in the top of the config.sh. Edit these parameters before the installation. +This is very critical part of the installation. The configuration parameters are in the the config.sh. Edit these parameters before the installation. -Followings are set of the default settings of the parameters : +Followings are the set of the default settings of the parameters : - Install to **/dev/sda** (DEV). - Erase entire disk (ERASEALL). +- Overwrite install is disabled. - In case of EFI firmware, 200MB is allocated to the EFI partition (EFISIZE). - Create a logical volume group named "vg1" in the encrypted volume (VGNAME) - Create a swap logical volume named "swap" in the "vg1". The size is 8GB (LVSWAPNAME,LVSWAPSIZE) @@ -92,16 +91,16 @@ There are several restrictions : - The LVSWAPNAME must be unique among all installations in a computer. Otherwise, Kaiten-yaki creates an unnecessary logical volume. This is waste of storage resource. - The EFISIZE and the LVSWAPSIZE are refereed during the first distribution installation only. - The LVROOTSIZE is the size of a logical volume to create. This is a relative value to the existing free space in the volume group. If you want to install 3 distributions in a computer, you may want to set 33%FREE, 50%FREE, and 100%FREE for the first, second, and third distribution installation, respectively. -- The name with "-" is not allowed for the VGNAME, LVROOTNAME, and LVSWAPNAME. I saw some installed doesn't work if "-" in in the name. -## About overwrite install -The OVERWRITEINSTALL parameter allow you to use an existing logical volume as root volume of the new installation. -This is very danger because of the several aspect like, destroying wrong volume and security. But sometimes it is +- The name with "-" is not allowed for the VGNAME, LVROOTNAME, and LVSWAPNAME. I saw some installer doesn't work if "-" in in the name. +## About the overwrite-install +The OVERWRITEINSTALL parameter allows you to use an existing logical volume as root volume of the new installation. +This is very danger because of the several aspect like destroying wrong volume and risk of security. But sometimes it is very useful. -For example, if you reboot the system at the end of GUI/TUI installer by mistake, your system will never boot again. -In this case, the overwrite install recycle this "bad" logical volume and let your system boot again. +For example, assume you are installing a distribution by Kaiten-yaki. If you reboot the system at the end of GUI/TUI installer by mistake, your system will never boot again. +In this case, the overwrite-install can recycle this "bad" logical volume and let your system boot again. -To use the overwrite install, you have to set the as following : +To use the overwrite-install, you have to set some parameters as following : - ERASEALL : 0 - OVERWRITEINSTALL : 1 @@ -110,7 +109,7 @@ And set following parameters as same as previous installation. - VGNAME - CRYPTPARTNAME -So, Kaitenyaki will leave the "bad" logical volume and allow you to overwrite it by GUI/TUI installer. +So, Kaiten-yaki will leave the "bad" logical volume and allow you to overwrite it by GUI/TUI installer. ## First stage : Setting up the volumes After you set the configuration parameters correctly, execute the following command from the shell. Again, you have to be promoted as root user, and you have to use Bash. @@ -145,5 +144,9 @@ At the end of the GUI/TUI installing, do not reboot the system. Click "Continue" ![Void done](image/void_done.png) ## Third stage : Finalizing -After GUI/TUI installer quit without rebooting, final part of the install process automatically starts. You can reboot the system, if you see the "Ready to reboot" message on the console. +After GUI/TUI installer quit without rebooting, final part of the install process automatically starts. + +In this section, Kaiten-yaki put the encryption key of the LUKS volume in to the ramfs initial stage to allow the Linux kernel decrypt the LUKS partition which contains root logical volume. So, system will ask you passphrase only once when GRUB start. + +You can reboot the system, if you see the "Ready to reboot" message on the console. From f980cf3d8999fae68d85b769f6d8a639df28ddf0 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Fri, 2 Jul 2021 22:08:34 +0900 Subject: [PATCH 02/35] Change the "Yet another ... " to lower case --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 65966fd..416f28d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Kaiten-yaki : Yet another Full Disk Encryption for GRUB/Linux +# Kaiten-yaki : Yet another full disk encryption for GRUB/Linux Kaiten-yaki is a script set to help you to make a full disk encryption install to your desktop system. Followings are the list of functionality. From c5ccd06c3b9a0dc5a5a7fa5a84462c5ee4ef3c1c Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Fri, 2 Jul 2021 22:28:10 +0900 Subject: [PATCH 03/35] Changed to support system void without GUI Issue #1 Support non-GUI install for Void Linux. --- script/void-kaiten-yaki.sh | 63 ++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 10 deletions(-) diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index bee312a..44ad038 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -7,7 +7,7 @@ function main() { # Load functions source lib/confirmation.sh source lib/preinstall.sh - source lib/parainstall.sh + # source lib/parainstall.sh # we have customized parainstall source lib/parainstall_msg.sh @@ -83,19 +83,38 @@ function main() { # waitfor a console input read dummy_var - # Start void-installer in the separate window - xterm -fa monospace -fs ${XTERMFONTSIZE} -e void-installer & - - # Record the PID of the installer. - export INSTALLER_PID=$! + # Start the background target/etc/default/grub cheker. + # The definition of this function is down below. + grub_check_and_modify & - # 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 ! parainstall ; then + # Record the PID of the background checker. + grub_check_and_modify_id = $! + + # Start void-installer + void-installer + + # Check if background checker still exist + if ps $grub_check_and_modify_id > /dev/null ; then # If exists + # If exist, the grub was not modifyed -> void-installer termianted unexpectedly + cat <<-HEREDOC 1>&2 + ***** ERROR : The GUI/TUI installer terminated unexpectedly. ***** + ...Deleting the new logical volume "${VGNAME}-${LVROOTNAME}". + HEREDOC + lvremove -f /dev/mapper/${VGNAME}-${LVROOTNAME} + echo "...Deactivating all logical volumes in volume group \"${VGNAME}\"." + vgchange -a n ${VGNAME} + echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." + cryptsetup close ${CRYPTPARTNAME} + cat <<-HEREDOC 1>&2 + + ...The new logical volume has been deleted. You can retry Kaiten-yaki again. + ...Installation process terminated. + HEREDOC return 1 # with error status fi + # At here, the installation was successful. + # ******************************************************************************* # Post-install stage # ******************************************************************************* @@ -164,5 +183,29 @@ function main() { return 0 } + +# This function will be executed in the background context, to watch the TUI installer. +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. + while [ ! -e ${TARGETMOUNTPOINT}/etc/default/grub ] + do + sleep 1 # 1sec. + done # while + + # Perhaps, too neuvous. Wait 1 more sectond to avoid the rece condition. + sleep 1 # 1sec. + + # Make target GRUB aware to the crypt partition + # This must do it after start of the file copy by installer, but before the end of the file copy. + echo "...Adding GRUB_ENABLE_CRYPTODISK entry to ${TARGETMOUNTPOINT}/etc/default/grub " + echo "GRUB_ENABLE_CRYPTODISK=y" >> ${TARGETMOUNTPOINT}/etc/default/grub + + # succesfull return + return 0 + +} # para install + # Execute main \ No newline at end of file From 508f2f8130e911509319e0812b8f6a4deea27538 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Fri, 2 Jul 2021 22:35:24 +0900 Subject: [PATCH 04/35] xterm is not needed anymore. --- script/void-kaiten-yaki.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index 44ad038..50f081b 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -48,7 +48,7 @@ function main() { # ******************************************************************************* # Install essential packages. - xbps-install -y -Su xbps gptfdisk xterm + xbps-install -y -Su xbps gptfdisk # Common part of the pre-install stage if ! pre_install ; then From ed8e08b9a777378de0cbf01ed25c5b5a072709af Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Fri, 2 Jul 2021 22:45:15 +0900 Subject: [PATCH 05/35] Fix the void installer unexpected quit detection The unneccesally space was the root caause. --- script/void-kaiten-yaki.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index 50f081b..7e0517d 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -88,7 +88,7 @@ function main() { grub_check_and_modify & # Record the PID of the background checker. - grub_check_and_modify_id = $! + grub_check_and_modify_id=$! # Start void-installer void-installer From a863ae6ad3526190204096702b647a3663fa4534 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Fri, 2 Jul 2021 23:42:35 +0900 Subject: [PATCH 06/35] Add void-linux "base" support Removed limitation description. Added tested iso. --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 416f28d..be9669c 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ These scripts are tested with following environment. - Ubuntu Mate 20.04.2 amd64 desktop - void-live-x86_64-20210218-mate.iso - void-live-x86_64-musl-20210218-mate.iso +- void-live-x86_64-20210218.iso # Installation Start the PC with the LiveCD/LiveUSB of the distribution to install. Download this repository from github, and expand it. @@ -40,8 +41,6 @@ If you install two or more Void Linux in to the EFI system, only the last one ca # Variants considerations Ubuntu has several variants ( flavors ). While I have tested only MATE flavor, other flavor may work correctly as far as it uses Ubiquity installer. -Void Linux has "base" variant which doesn't have GUI. Kaiten-yaki can't run correctly without GUI. - # Acknowledgments These scripts are based on the script shared on the [myn's diary](https://myn.hatenablog.jp/entry/install-ubuntu-focal-with-lvm-on-luks). That page contains rich information, hint and techniques around the encrypted volume and Ubiquity installer. From 9bde5fb9ab2adb6ffa1314d6cd5302ebf1d9d3f5 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 05:43:42 +0900 Subject: [PATCH 07/35] Correct comment Ubuntu -> Void Linux --- script/void-kaiten-yaki.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index 7e0517d..1cbdab9 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -68,7 +68,7 @@ function main() { # Show common message to let the operator focus on the critical part parainstall_msg - # Ubuntu dependent message + # Void-Linux dependent message cat <<- HEREDOC ************************ CAUTION! CAUTION! CAUTION! **************************** From 0e0af792349f420ea941e0d0d85171fb3912f820 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 06:12:01 +0900 Subject: [PATCH 08/35] Refactored structure Post install part is gotten into a function. Ubuntu dependent para-install is moved to main ubuntu-kaiten-yaki.sh --- script/lib/parainstall.sh | 50 ------------------------- script/ubuntu-kaiten-yaki.sh | 71 +++++++++++++++++++++++++++++++++--- script/void-kaiten-yaki.sh | 27 ++++++++++---- 3 files changed, 86 insertions(+), 62 deletions(-) delete mode 100644 script/lib/parainstall.sh diff --git a/script/lib/parainstall.sh b/script/lib/parainstall.sh deleted file mode 100644 index d410566..0000000 --- a/script/lib/parainstall.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -u -# ******************************************************************************* -# Common part of para-install -# ******************************************************************************* - -function parainstall() { - - # While the /etc/default/grub in the install target is NOT existing, keep sleeping. - # If installer terminated without file copy, this script also terminates. - while [ ! -e ${TARGETMOUNTPOINT}/etc/default/grub ] - do - sleep 1 # 1sec. - - # Check if installer still exist - if ! ps $INSTALLER_PID > /dev/null ; then # If not exists - cat <<-HEREDOC 1>&2 - ***** ERROR : The GUI/TUI installer terminated unexpectedly. ***** - ...Deleting the new logical volume "${VGNAME}-${LVROOTNAME}". - HEREDOC - lvremove -f /dev/mapper/${VGNAME}-${LVROOTNAME} - echo "...Deactivating all logical volumes in volume group \"${VGNAME}\"." - vgchange -a n ${VGNAME} - echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." - cryptsetup close ${CRYPTPARTNAME} - cat <<-HEREDOC 1>&2 - - ...The new logical volume has been deleted. You can retry Kaiten-yaki again. - ...Installation process terminated. - HEREDOC - return 1 # with error status - fi - done # while - - # Perhaps, too neuvous. Wait 1 more sectond to avoid the rece condition. - sleep 1 # 1sec. - - # Make target GRUB aware to the crypt partition - # This must do it after start of the file copy by installer, but before the end of the file copy. - echo "...Adding GRUB_ENABLE_CRYPTODISK entry to ${TARGETMOUNTPOINT}/etc/default/grub " - echo "GRUB_ENABLE_CRYPTODISK=y" >> ${TARGETMOUNTPOINT}/etc/default/grub - - # And then, wait for the end of installer process - echo "...Waiting for the end of GUI/TUI installer." - echo "...Again, DO NOT reboot/restart here. Just exit the GUI/TUI installer." - wait $INSTALLER_PID - - # succesfull return - return 0 - -} # para install diff --git a/script/ubuntu-kaiten-yaki.sh b/script/ubuntu-kaiten-yaki.sh index f5ead25..9623f54 100644 --- a/script/ubuntu-kaiten-yaki.sh +++ b/script/ubuntu-kaiten-yaki.sh @@ -7,7 +7,6 @@ function main() { # Load functions source lib/confirmation.sh source lib/preinstall.sh - source lib/parainstall.sh source lib/parainstall_msg.sh @@ -84,7 +83,7 @@ function main() { # 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 ! parainstall ; then + if ! grub_check_and_modify_ubuntu ; then return 1 # with error status fi @@ -92,6 +91,18 @@ function main() { # Post-install stage # ******************************************************************************* + # Finalizing. Embedd encryption key into the ramfs image. + post_install_void() + + # Normal end + return 0 + +} # End of main() + + +# ******************************************************************************* +# Ubuntu dependent post-installation process +function post_install_ubuntu() { ## Mount the target file system # ${TARGETMOUNTPOINT} is created by the GUI/TUI installer echo "...Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${TARGETMOUNTPOINT}." @@ -149,9 +160,59 @@ function main() { ...Ready to reboot. HEREDOC - # Normal end - return 0 -} + retrun 0 +} # End of post_install_ubuntu() + + +# ******************************************************************************* +# This function will be executed in the foreguround context, to watch the GUI installer. +function grub_check_and_modify_ubuntu() { + + # While the /etc/default/grub in the install target is NOT existing, keep sleeping. + # If installer terminated without file copy, this script also terminates. + while [ ! -e ${TARGETMOUNTPOINT}/etc/default/grub ] + do + sleep 1 # 1sec. + + # Check if installer still exist + if ! ps $INSTALLER_PID > /dev/null ; then # If not exists + cat <<-HEREDOC 1>&2 + ***** ERROR : The GUI/TUI installer terminated unexpectedly. ***** + ...Deleting the new logical volume "${VGNAME}-${LVROOTNAME}". + HEREDOC + lvremove -f /dev/mapper/${VGNAME}-${LVROOTNAME} + echo "...Deactivating all logical volumes in volume group \"${VGNAME}\"." + vgchange -a n ${VGNAME} + echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." + cryptsetup close ${CRYPTPARTNAME} + cat <<-HEREDOC 1>&2 + + ...The new logical volume has been deleted. You can retry Kaiten-yaki again. + ...Installation process terminated. + HEREDOC + return 1 # with error status + fi + done # while + + # Perhaps, too neuvous. Wait 1 more sectond to avoid the rece condition. + sleep 1 # 1sec. + + # Make target GRUB aware to the crypt partition + # This must do it after start of the file copy by installer, but before the end of the file copy. + echo "...Adding GRUB_ENABLE_CRYPTODISK entry to ${TARGETMOUNTPOINT}/etc/default/grub " + echo "GRUB_ENABLE_CRYPTODISK=y" >> ${TARGETMOUNTPOINT}/etc/default/grub + + # And then, wait for the end of installer process + echo "...Waiting for the end of GUI/TUI installer." + echo "...Again, DO NOT reboot/restart here. Just exit the GUI/TUI installer." + wait $INSTALLER_PID + + # succesfull return + return 0 + +} # grub_check_and_modify_ubuntu() + +# ******************************************************************************* # Execute main \ No newline at end of file diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index 1cbdab9..ee3d016 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -7,7 +7,6 @@ function main() { # Load functions source lib/confirmation.sh source lib/preinstall.sh - # source lib/parainstall.sh # we have customized parainstall source lib/parainstall_msg.sh @@ -85,7 +84,7 @@ function main() { # Start the background target/etc/default/grub cheker. # The definition of this function is down below. - grub_check_and_modify & + grub_check_and_modify_void & # Record the PID of the background checker. grub_check_and_modify_id=$! @@ -119,6 +118,18 @@ function main() { # Post-install stage # ******************************************************************************* + # Finalizing. Embedd encryption key into the ramfs image. + post_install_ubuntu() + + # Normal end + return 0 + +} # End of ()) + + +# ******************************************************************************* +# Void Linux dependent post-installation process +function post_install_void() { ## Mount the target file system # ${TARGETMOUNTPOINT} is created by the GUI/TUI installer echo "...Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${TARGETMOUNTPOINT}." @@ -179,13 +190,14 @@ function main() { ...Ready to reboot. HEREDOC - # Normal end - return 0 -} + retrun 0 + +} # End of post_install_void() +# ******************************************************************************* # This function will be executed in the background context, to watch the TUI installer. -function grub_check_and_modify() { +function grub_check_and_modify_void() { # While the /etc/default/grub in the install target is NOT existing, keep sleeping. # If installer terminated without file copy, this script also terminates. @@ -205,7 +217,8 @@ function grub_check_and_modify() { # succesfull return return 0 -} # para install +} # gurb_check_and_modify_void() +# ******************************************************************************* # Execute main \ No newline at end of file From ccc7d009f62ca25f138e5d3f2a049c2a99ad3896 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 06:26:33 +0900 Subject: [PATCH 09/35] Fixed bug of function call --- script/ubuntu-kaiten-yaki.sh | 2 +- script/void-kaiten-yaki.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/script/ubuntu-kaiten-yaki.sh b/script/ubuntu-kaiten-yaki.sh index 9623f54..77420c9 100644 --- a/script/ubuntu-kaiten-yaki.sh +++ b/script/ubuntu-kaiten-yaki.sh @@ -92,7 +92,7 @@ function main() { # ******************************************************************************* # Finalizing. Embedd encryption key into the ramfs image. - post_install_void() + post_install_ubuntu # Normal end return 0 diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index ee3d016..b5c4c09 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -119,12 +119,12 @@ function main() { # ******************************************************************************* # Finalizing. Embedd encryption key into the ramfs image. - post_install_ubuntu() + post_install_void # Normal end return 0 -} # End of ()) +} # End of main() # ******************************************************************************* 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 10/35] 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 From fb3720787ca777eed7bd5b04f6d4ca87a95eb5a7 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 07:17:18 +0900 Subject: [PATCH 11/35] Fix file name bug --- .../lib/{parainstall_msg_common.sh => para_install_msg_common.sh} | 0 script/lib/{preinstall_common.sh => pre_install_common.sh} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename script/lib/{parainstall_msg_common.sh => para_install_msg_common.sh} (100%) rename script/lib/{preinstall_common.sh => pre_install_common.sh} (100%) diff --git a/script/lib/parainstall_msg_common.sh b/script/lib/para_install_msg_common.sh similarity index 100% rename from script/lib/parainstall_msg_common.sh rename to script/lib/para_install_msg_common.sh diff --git a/script/lib/preinstall_common.sh b/script/lib/pre_install_common.sh similarity index 100% rename from script/lib/preinstall_common.sh rename to script/lib/pre_install_common.sh From b9e490e5f37ac807fbe7db25b53e3295238f486c Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 07:32:06 +0900 Subject: [PATCH 12/35] Add volume protection logic In cae of the unexpected quit of GUI/TUI installer, The target volume was deleted always. Changed it to delete only when --- script/lib/confirmation_common.sh | 14 +++++++------- script/lib/pre_install_common.sh | 10 +++++----- script/ubuntu-kaiten-yaki.sh | 14 +++++++------- script/void-kaiten-yaki.sh | 17 +++++++++-------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/script/lib/confirmation_common.sh b/script/lib/confirmation_common.sh index ddf6caa..6082dd1 100644 --- a/script/lib/confirmation_common.sh +++ b/script/lib/confirmation_common.sh @@ -7,7 +7,7 @@ function confirmation_common(){ # Consistency check for the OVERWRITEINSTALL and ERASEALL if [ ${ERASEALL} -eq 1 -a ${OVERWRITEINSTALL} -eq 1 ] ; then - cat <<- HEREDOC 1>&2 + cat <<- HEREDOC ***** ERROR : Confliction between ERASEALL and OVERWRITEINSTALL ***** ...ERASEALL = ${ERASEALL} ...OVERWRITEINSTALL = ${OVERWRITEINSTALL} @@ -20,7 +20,7 @@ function confirmation_common(){ # Sanity check for volume group name if echo ${VGNAME} | grep "-" -i > /dev/null ; then # "-" is found in the volume group name. - cat <<- HEREDOC 1>&2 + cat <<- HEREDOC ***** ERROR : VGNAME is "${VGNAME}" ***** ..."-" is not allowed in the volume name. ...Check configuration in your config.sh @@ -32,7 +32,7 @@ function confirmation_common(){ # Sanity check for root volume name if echo ${LVROOTNAME} | grep "-" -i > /dev/null ; then # "-" is found in the volume name. - cat <<- HEREDOC 1>&2 + cat <<- HEREDOC ***** ERROR : LVROOTNAME is "${LVROOTNAME}" ***** ..."-" is not allowed in the volume name. ...Check configuration in your config.sh @@ -44,7 +44,7 @@ function confirmation_common(){ # Sanity check for swap volume name if echo ${LVSWAPNAME} | grep "-" -i > /dev/null ; then # "-" is found in the volume name. - cat <<- HEREDOC 1>&2 + cat <<- HEREDOC ***** ERROR : LVSWAPNAME is "${LVSWAPNAME}" ***** ..."-" is not allowed in the volume name. ...Check configuration in your config.sh @@ -63,7 +63,7 @@ function confirmation_common(){ HEREDOC read YESNO if [ ${YESNO} != "Y" -a ${YESNO} != "y" ] ; then - cat <<- HEREDOC 1>&2 + cat <<- HEREDOC ...Installation process terminated.. HEREDOC @@ -75,7 +75,7 @@ function confirmation_common(){ echo "Are you sure you want to erase entire ${DEV}? [Y/N]" read YESNO if [ ${YESNO} != "Y" -a ${YESNO} != "y" ] ; then - cat <<-HEREDOC 1>&2 + cat <<-HEREDOC ...Check your config.sh. The variable ERASEALL is ${ERASEALL}. ...Installation process terminated.. @@ -96,7 +96,7 @@ function confirmation_common(){ # Validate whether both are indentical or not if [ ${PASSPHRASE} != ${PASSPHRASE_C} ] ; then - cat <<-HEREDOC 1>&2 + cat <<-HEREDOC ***** ERROR : Passphrase doesn't match ***** ...Installation process terminated.. diff --git a/script/lib/pre_install_common.sh b/script/lib/pre_install_common.sh index 82d679c..e2606a8 100644 --- a/script/lib/pre_install_common.sh +++ b/script/lib/pre_install_common.sh @@ -48,7 +48,7 @@ function pre_install_common() { # Check whether successful open. If mapped, it is successful. if [ ! -e /dev/mapper/${CRYPTPARTNAME} ] ; then - cat <<- HEREDOC 1>&2 + cat <<- HEREDOC ***** ERROR : Cannot open LUKS volume "${CRYPTPARTNAME}" on ${DEV}${CRYPTPARTITION}. ***** ...Check passphrase and your config.txt @@ -83,7 +83,7 @@ function pre_install_common() { if [ ${OVERWRITEINSTALL} -eq 1 ] ; then # exist and overwrite install echo "...Logical volume "${VGNAME}-${LVROOTNAME}" already exists. OK." else # exist and not overwriteinstall - cat <<- HEREDOC 1>&2 + cat <<- HEREDOC ***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" already exists. ***** ...Check LVROOTNAME environment variable in your config.txt. HEREDOC @@ -91,7 +91,7 @@ function pre_install_common() { vgchange -a n ${VGNAME} echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." cryptsetup close ${CRYPTPARTNAME} - cat <<- HEREDOC 1>&2 + cat <<- HEREDOC ...Installation process terminated.. HEREDOC @@ -99,7 +99,7 @@ function pre_install_common() { fi else # not exsit if [ ${OVERWRITEINSTALL} -eq 1 ] ; then - cat <<- HEREDOC 1>&2 + cat <<- HEREDOC ***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" doesn't exist while overwrite install. ***** ...Check consistency of your config.txt. HEREDOC @@ -107,7 +107,7 @@ function pre_install_common() { vgchange -a n ${VGNAME} echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." cryptsetup close ${CRYPTPARTNAME} - cat <<- HEREDOC 1>&2 + cat <<- HEREDOC ...Installation process terminated.. HEREDOC diff --git a/script/ubuntu-kaiten-yaki.sh b/script/ubuntu-kaiten-yaki.sh index 11c1c0a..9cf0ff8 100644 --- a/script/ubuntu-kaiten-yaki.sh +++ b/script/ubuntu-kaiten-yaki.sh @@ -24,7 +24,7 @@ function main() { HEREDOC read YESNO if [ ${YESNO} != "Y" -a ${YESNO} != "y" ] ; then - cat <<- HEREDOC 1>&2 + cat <<- HEREDOC ...Installation process terminated.. HEREDOC @@ -177,16 +177,16 @@ function grub_check_and_modify() { # Check if installer still exist if ! ps $INSTALLER_PID > /dev/null ; then # If not exists - cat <<-HEREDOC 1>&2 - ***** ERROR : The GUI/TUI installer terminated unexpectedly. ***** - ...Deleting the new logical volume "${VGNAME}-${LVROOTNAME}". - HEREDOC - lvremove -f /dev/mapper/${VGNAME}-${LVROOTNAME} + echo "***** ERROR : The GUI/TUI installer terminated unexpectedly. *****" + if [ ${OVERWRITEINSTALL} -eq 0 ] ; then # If not over install, volume is new. So delete it + echo "...Deleting the new logical volume \"${VGNAME}-${LVROOTNAME}\"." + lvremove -f /dev/mapper/${VGNAME}-${LVROOTNAME} + fi echo "...Deactivating all logical volumes in volume group \"${VGNAME}\"." vgchange -a n ${VGNAME} echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." cryptsetup close ${CRYPTPARTNAME} - cat <<-HEREDOC 1>&2 + cat <<-HEREDOC ...The new logical volume has been deleted. You can retry Kaiten-yaki again. ...Installation process terminated. diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index ffc1e53..cc5b39a 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -24,7 +24,7 @@ function main() { HEREDOC read YESNO if [ ${YESNO} != "Y" -a ${YESNO} != "y" ] ; then - cat <<- HEREDOC 1>&2 + cat <<- HEREDOC ...Installation process terminated.. HEREDOC @@ -67,7 +67,7 @@ function main() { # Show common message to let the operator focus on the critical part para_install_msg_common - + # Void-Linux dependent message cat <<- HEREDOC @@ -96,16 +96,17 @@ function main() { # Check if background checker still exist if ps $grub_check_and_modify_id > /dev/null ; then # If exists # If exist, the grub was not modifyed -> void-installer termianted unexpectedly - cat <<-HEREDOC 1>&2 - ***** ERROR : The GUI/TUI installer terminated unexpectedly. ***** - ...Deleting the new logical volume "${VGNAME}-${LVROOTNAME}". - HEREDOC - lvremove -f /dev/mapper/${VGNAME}-${LVROOTNAME} + + echo "***** ERROR : The GUI/TUI installer terminated unexpectedly. *****" + if [ ${OVERWRITEINSTALL} -eq 0 ] ; then # If not over install, volume is new. So delete it + echo "...Deleting the new logical volume \"${VGNAME}-${LVROOTNAME}\"." + lvremove -f /dev/mapper/${VGNAME}-${LVROOTNAME} + fi echo "...Deactivating all logical volumes in volume group \"${VGNAME}\"." vgchange -a n ${VGNAME} echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." cryptsetup close ${CRYPTPARTNAME} - cat <<-HEREDOC 1>&2 + cat <<-HEREDOC ...The new logical volume has been deleted. You can retry Kaiten-yaki again. ...Installation process terminated. From dc1e8ff720b0947babd4deaab5556ace2a44c899 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 08:17:36 +0900 Subject: [PATCH 13/35] Applied shellcheck --- script/lib/confirmation_common.sh | 20 ++++----- script/lib/para_install_msg_common.sh | 4 +- script/lib/pre_install_common.sh | 58 +++++++++++++-------------- script/ubuntu-kaiten-yaki.sh | 21 +++++----- script/void-kaiten-yaki.sh | 21 +++++----- 5 files changed, 63 insertions(+), 61 deletions(-) diff --git a/script/lib/confirmation_common.sh b/script/lib/confirmation_common.sh index 6082dd1..a9a8130 100644 --- a/script/lib/confirmation_common.sh +++ b/script/lib/confirmation_common.sh @@ -6,7 +6,7 @@ function confirmation_common(){ # Consistency check for the OVERWRITEINSTALL and ERASEALL - if [ ${ERASEALL} -eq 1 -a ${OVERWRITEINSTALL} -eq 1 ] ; then + if [ "${ERASEALL}" -eq 1 ] && [ "${OVERWRITEINSTALL}" -eq 1 ] ; then cat <<- HEREDOC ***** ERROR : Confliction between ERASEALL and OVERWRITEINSTALL ***** ...ERASEALL = ${ERASEALL} @@ -19,7 +19,7 @@ function confirmation_common(){ fi # Sanity check for volume group name - if echo ${VGNAME} | grep "-" -i > /dev/null ; then # "-" is found in the volume group name. + if echo "${VGNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume group name. cat <<- HEREDOC ***** ERROR : VGNAME is "${VGNAME}" ***** ..."-" is not allowed in the volume name. @@ -31,7 +31,7 @@ function confirmation_common(){ fi # "-" is found in the volume group name. # Sanity check for root volume name - if echo ${LVROOTNAME} | grep "-" -i > /dev/null ; then # "-" is found in the volume name. + if echo "${LVROOTNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume name. cat <<- HEREDOC ***** ERROR : LVROOTNAME is "${LVROOTNAME}" ***** ..."-" is not allowed in the volume name. @@ -43,7 +43,7 @@ function confirmation_common(){ fi # "-" is found in the volume name. # Sanity check for swap volume name - if echo ${LVSWAPNAME} | grep "-" -i > /dev/null ; then # "-" is found in the volume name. + if echo "${LVSWAPNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume name. cat <<- HEREDOC ***** ERROR : LVSWAPNAME is "${LVSWAPNAME}" ***** ..."-" is not allowed in the volume name. @@ -61,8 +61,8 @@ function confirmation_common(){ "${LVROOTNAME}" uses ${LVROOTSIZE} of the LVM volume group. Are you sure to install? [Y/N] HEREDOC - read YESNO - if [ ${YESNO} != "Y" -a ${YESNO} != "y" ] ; then + read -r YESNO + if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then cat <<- HEREDOC ...Installation process terminated.. @@ -71,10 +71,10 @@ function confirmation_common(){ fi # if YES # For sure ask to be sure to erase. - if [ ${ERASEALL} -eq 1 ] ; then + if [ "${ERASEALL}" -eq 1 ] ; then echo "Are you sure you want to erase entire ${DEV}? [Y/N]" - read YESNO - if [ ${YESNO} != "Y" -a ${YESNO} != "y" ] ; then + read -r YESNO + if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then cat <<-HEREDOC ...Check your config.sh. The variable ERASEALL is ${ERASEALL}. @@ -95,7 +95,7 @@ function confirmation_common(){ read -sr PASSPHRASE_C # Validate whether both are indentical or not - if [ ${PASSPHRASE} != ${PASSPHRASE_C} ] ; then + if [ "${PASSPHRASE}" != "${PASSPHRASE_C}" ] ; then cat <<-HEREDOC ***** ERROR : Passphrase doesn't match ***** diff --git a/script/lib/para_install_msg_common.sh b/script/lib/para_install_msg_common.sh index 84abf42..56e7167 100644 --- a/script/lib/para_install_msg_common.sh +++ b/script/lib/para_install_msg_common.sh @@ -14,7 +14,7 @@ function para_install_msg_common() { HEREDOC # In the EFI system, add this mapping - if [ ${ISEFI} -eq 1 ] ; then + if [ "${ISEFI}" -eq 1 ] ; then echo "/boot/efi : ${DEV}${EFIPARTITION}" fi @@ -22,7 +22,7 @@ function para_install_msg_common() { echo "/ : /dev/mapper/${VGNAME}-${LVROOTNAME}" # In case of erased storage, add this mapping - if [ ${ERASEALL} -eq 1 ] ; then + if [ "${ERASEALL}" -eq 1 ] ; then echo "swap : /dev/mapper/${VGNAME}-${LVSWAPNAME}" fi diff --git a/script/lib/pre_install_common.sh b/script/lib/pre_install_common.sh index e2606a8..98efaaa 100644 --- a/script/lib/pre_install_common.sh +++ b/script/lib/pre_install_common.sh @@ -7,49 +7,49 @@ function pre_install_common() { # ----- Erase entire disk, create partitions, format them and encrypt the LUKS partition ----- - if [ ${ERASEALL} -eq 1 ] ; then + if [ "${ERASEALL}" -eq 1 ] ; then # Assign specified space and rest of disk to the EFI and LUKS partition, respectively. - if [ ${ISEFI} -eq 1 ] ; then + if [ "${ISEFI}" -eq 1 ] ; then # Zap existing partition table and create new GPT - echo "...Initializing ${DEV} with GPT." + echo "...Initializing \"${DEV}\" with GPT." sgdisk --zap-all "${DEV}" # Create EFI partition and format it - echo "...Creating an EFI partition on ${DEV}." - sgdisk --new=${EFIPARTITION}:0:+${EFISIZE} --change-name=${EFIPARTITION}:"EFI System" --typecode=${EFIPARTITION}:ef00 "${DEV}" + echo "...Creating an EFI partition on \"${DEV}\"." + sgdisk --new="${EFIPARTITION}":0:+"${EFISIZE}" --change-name="${EFIPARTITION}":"EFI System" --typecode="${EFIPARTITION}":ef00 "${DEV}" echo "...Formatting the EFI parttion." mkfs.vfat -F 32 -n EFI-SP "${DEV}${EFIPARTITION}" # Create Linux partition echo "...Creating a Linux partition on ${DEV}." - sgdisk --new=${CRYPTPARTITION}:0:0 --change-name=${CRYPTPARTITION}:"Linux LUKS" --typecode=${CRYPTPARTITION}:8309 "${DEV}" + sgdisk --new="${CRYPTPARTITION}":0:0 --change-name="${CRYPTPARTITION}":"Linux LUKS" --typecode="${CRYPTPARTITION}":8309 "${DEV}" # Then print them sgdisk --print "${DEV}" else # Zap existing partition table - echo "...Erasing partition table of ${DEV}." - dd if=/dev/zero of=${DEV} bs=512 count=1 + echo "...Erasing partition table of \"${DEV}\"." + dd if=/dev/zero of="${DEV}" bs=512 count=1 # Create MBR and allocate max storage for Linux partition echo "...Creating a Linux partition on ${DEV} with MBR." - sfdisk ${DEV} <<- HEREDOC + sfdisk "${DEV}" <<- HEREDOC 2M,,L HEREDOC fi # if EFI firmware # Encrypt the partition to install Linux - echo "...Initializing ${DEV}${CRYPTPARTITION} as crypt partition" + echo "...Initializing \"${DEV}${CRYPTPARTITION}\" as crypt partition" printf %s "${PASSPHRASE}" | cryptsetup luksFormat --type=luks1 --key-file - --batch-mode "${DEV}${CRYPTPARTITION}" fi # if erase all # ----- Open the LUKS partition ----- # Open the crypt partition. - echo "...Opening a crypt partition ${DEV}${CRYPTPARTITION} as \"${CRYPTPARTNAME}\"" - printf %s "${PASSPHRASE}" | cryptsetup open -d - "${DEV}${CRYPTPARTITION}" ${CRYPTPARTNAME} + echo "...Opening a crypt partition \"${DEV}${CRYPTPARTITION}\" as \"${CRYPTPARTNAME}\"" + printf %s "${PASSPHRASE}" | cryptsetup open -d - "${DEV}${CRYPTPARTITION}" "${CRYPTPARTNAME}" # Check whether successful open. If mapped, it is successful. - if [ ! -e /dev/mapper/${CRYPTPARTNAME} ] ; then + if [ ! -e /dev/mapper/"${CRYPTPARTNAME}" ] ; then cat <<- HEREDOC - ***** ERROR : Cannot open LUKS volume "${CRYPTPARTNAME}" on ${DEV}${CRYPTPARTITION}. ***** + ***** ERROR : Cannot open LUKS volume "${CRYPTPARTNAME}" on "${DEV}${CRYPTPARTITION}". ***** ...Check passphrase and your config.txt ...Installation process terminated.. @@ -59,38 +59,38 @@ function pre_install_common() { # ----- Configure the LVM in LUKS volume ----- # Check volume group ${VGNAME} exist or not - if vgdisplay -s ${VGNAME} &> /dev/null ; then # if exist - echo "...Volume group ${VGNAME} already exist. Skipped to create. No problem." + if vgdisplay -s "${VGNAME}" &> /dev/null ; then # if exist + echo "...Volume group \"${VGNAME}\" already exist. Skipped to create. No problem." echo "...Activating all logical volumes in volume group \"${VGNAME}\"." vgchange -ay else echo "...Initializing a physical volume on \"${CRYPTPARTNAME}\"" - pvcreate /dev/mapper/${CRYPTPARTNAME} + pvcreate /dev/mapper/"${CRYPTPARTNAME}" echo "...And then creating Volume group \"${VGNAME}\"." - vgcreate ${VGNAME} /dev/mapper/${CRYPTPARTNAME} + vgcreate "${VGNAME}" /dev/mapper/"${CRYPTPARTNAME}" fi # if /dev/volume-groupt exist # Create a SWAP Logical Volume on VG, if it doesn't exist - if [ -e /dev/mapper/${VGNAME}-${LVSWAPNAME} ] ; then + if [ -e /dev/mapper/"${VGNAME}"-"${LVSWAPNAME}" ] ; then echo "...Swap volume already exist. Skipped to create. No problem." else echo "...Creating logical volume \"${LVSWAPNAME}\" on \"${VGNAME}\"." - lvcreate -L ${LVSWAPSIZE} -n ${LVSWAPNAME} ${VGNAME} + lvcreate -L "${LVSWAPSIZE}" -n "${LVSWAPNAME}" "${VGNAME}" fi # if /dev/mapper/swap volume already exit. # Create a ROOT Logical Volume on VG. - if [ -e /dev/mapper/${VGNAME}-${LVROOTNAME} ] ; then # exist - if [ ${OVERWRITEINSTALL} -eq 1 ] ; then # exist and overwrite install - echo "...Logical volume "${VGNAME}-${LVROOTNAME}" already exists. OK." + if [ -e /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" ] ; then # exist + if [ "${OVERWRITEINSTALL}" -eq 1 ] ; then # exist and overwrite install + echo "...Logical volume \"${VGNAME}-${LVROOTNAME}\" already exists. OK." else # exist and not overwriteinstall cat <<- HEREDOC ***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" already exists. ***** ...Check LVROOTNAME environment variable in your config.txt. HEREDOC echo "...Deactivating all logical volumes in volume group \"${VGNAME}\"." - vgchange -a n ${VGNAME} + vgchange -a n "${VGNAME}" echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." - cryptsetup close ${CRYPTPARTNAME} + cryptsetup close "${CRYPTPARTNAME}" cat <<- HEREDOC ...Installation process terminated.. @@ -98,15 +98,15 @@ function pre_install_common() { return 1 # with error status fi else # not exsit - if [ ${OVERWRITEINSTALL} -eq 1 ] ; then + if [ "${OVERWRITEINSTALL}" -eq 1 ] ; then cat <<- HEREDOC ***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" doesn't exist while overwrite install. ***** ...Check consistency of your config.txt. HEREDOC echo "...Deactivate all logical volumes in volume group \"${VGNAME}\"." - vgchange -a n ${VGNAME} + vgchange -a n "${VGNAME}" echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." - cryptsetup close ${CRYPTPARTNAME} + cryptsetup close "${CRYPTPARTNAME}" cat <<- HEREDOC ...Installation process terminated.. @@ -114,7 +114,7 @@ function pre_install_common() { return 1 # with error status else # not exist and not overwrite install echo "...Creating logical volume \"${LVROOTNAME}\" on \"${VGNAME}\"." - lvcreate -l ${LVROOTSIZE} -n ${LVROOTNAME} ${VGNAME} + lvcreate -l "${LVROOTSIZE}" -n "${LVROOTNAME}" "${VGNAME}" fi fi diff --git a/script/ubuntu-kaiten-yaki.sh b/script/ubuntu-kaiten-yaki.sh index 9cf0ff8..716af88 100644 --- a/script/ubuntu-kaiten-yaki.sh +++ b/script/ubuntu-kaiten-yaki.sh @@ -1,6 +1,6 @@ #!/bin/bash -u -function main() { + # shellcheck disable=SC1091 # Load configuration parameter source config.sh @@ -9,6 +9,7 @@ function main() { source lib/pre_install_common.sh source lib/para_install_msg_common.sh +function main() { # This is the mount point of the install target. export TARGETMOUNTPOINT="/target" @@ -22,8 +23,8 @@ function main() { This system seems to be not Ubuntu, while this script is dediated to the Ubuntu. Are you sure you want to run this script? [Y/N] HEREDOC - read YESNO - if [ ${YESNO} != "Y" -a ${YESNO} != "y" ] ; then + read -r YESNO + if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then cat <<- HEREDOC ...Installation process terminated.. @@ -72,7 +73,7 @@ function main() { HEREDOC # waitfor a console input - read dummy_var + read -r # Start Ubiquity installer ubiquity & @@ -106,7 +107,7 @@ function post_install() { ## Mount the target file system # ${TARGETMOUNTPOINT} is created by the GUI/TUI installer echo "...Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${TARGETMOUNTPOINT}." - mount /dev/mapper/${VGNAME}-${LVROOTNAME} ${TARGETMOUNTPOINT} + mount /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" ${TARGETMOUNTPOINT} # And mount other directories echo "...Mounting all other dirs." @@ -135,7 +136,7 @@ function post_install() { # Add the LUKS volume information to /etc/crypttab to decrypt by kernel. echo "...Adding LUKS volume info to /etc/crypttab." - echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab + echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value "${DEV}${CRYPTPARTITION}") /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab # Putting key file into the ramfs initial image echo "...Registering key file to the ramfs" @@ -178,14 +179,14 @@ function grub_check_and_modify() { # Check if installer still exist if ! ps $INSTALLER_PID > /dev/null ; then # If not exists echo "***** ERROR : The GUI/TUI installer terminated unexpectedly. *****" - if [ ${OVERWRITEINSTALL} -eq 0 ] ; then # If not over install, volume is new. So delete it + if [ "${OVERWRITEINSTALL}" -eq 0 ] ; then # If not over install, volume is new. So delete it echo "...Deleting the new logical volume \"${VGNAME}-${LVROOTNAME}\"." - lvremove -f /dev/mapper/${VGNAME}-${LVROOTNAME} + lvremove -f /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" fi echo "...Deactivating all logical volumes in volume group \"${VGNAME}\"." - vgchange -a n ${VGNAME} + vgchange -a n "${VGNAME}" echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." - cryptsetup close ${CRYPTPARTNAME} + cryptsetup close "${CRYPTPARTNAME}" cat <<-HEREDOC ...The new logical volume has been deleted. You can retry Kaiten-yaki again. diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index cc5b39a..a22beb5 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -1,6 +1,6 @@ #!/bin/bash -u -function main() { + # shellcheck disable=SC1091 # Load configuration parameter source config.sh @@ -9,6 +9,7 @@ function main() { source lib/pre_install_common.sh source lib/para_install_msg_common.sh +function main() { # This is the mount point of the install target. export TARGETMOUNTPOINT="/mnt/target" @@ -22,8 +23,8 @@ function main() { This system seems to be not Void Linux, while this script is dediated to the Void Linux. Are you sure you want to run this script for installation? [Y/N] HEREDOC - read YESNO - if [ ${YESNO} != "Y" -a ${YESNO} != "y" ] ; then + read -r YESNO + if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then cat <<- HEREDOC ...Installation process terminated.. @@ -81,7 +82,7 @@ function main() { HEREDOC # waitfor a console input - read dummy_var + read -r # Start the background target/etc/default/grub cheker. # The definition of this function is down below. @@ -98,14 +99,14 @@ function main() { # If exist, the grub was not modifyed -> void-installer termianted unexpectedly echo "***** ERROR : The GUI/TUI installer terminated unexpectedly. *****" - if [ ${OVERWRITEINSTALL} -eq 0 ] ; then # If not over install, volume is new. So delete it + if [ "${OVERWRITEINSTALL}" -eq 0 ] ; then # If not over install, volume is new. So delete it echo "...Deleting the new logical volume \"${VGNAME}-${LVROOTNAME}\"." - lvremove -f /dev/mapper/${VGNAME}-${LVROOTNAME} + lvremove -f /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" fi echo "...Deactivating all logical volumes in volume group \"${VGNAME}\"." - vgchange -a n ${VGNAME} + vgchange -a n "${VGNAME}" echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." - cryptsetup close ${CRYPTPARTNAME} + cryptsetup close "${CRYPTPARTNAME}" cat <<-HEREDOC ...The new logical volume has been deleted. You can retry Kaiten-yaki again. @@ -133,7 +134,7 @@ function post_install() { ## Mount the target file system # ${TARGETMOUNTPOINT} is created by the GUI/TUI installer echo "...Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${TARGETMOUNTPOINT}." - mount /dev/mapper/${VGNAME}-${LVROOTNAME} ${TARGETMOUNTPOINT} + mount /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" ${TARGETMOUNTPOINT} # And mount other directories echo "...Mounting all other dirs." @@ -162,7 +163,7 @@ function post_install() { # Add the LUKS volume information to /etc/crypttab to decrypt by kernel. echo "...Adding LUKS volume info to /etc/crypttab." - echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab + echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value "${DEV}""${CRYPTPARTITION}") /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab # Putting key file into the ramfs initial image echo "...Registering key file to the ramfs" From b7738a9fd8cd4ad8dc0a57ecc8eb131e7ef46aab Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 08:19:00 +0900 Subject: [PATCH 14/35] change -eq 1 to -ne 0 To accept non-zero value --- script/config.sh | 2 +- script/lib/confirmation_common.sh | 4 ++-- script/lib/para_install_msg_common.sh | 4 ++-- script/lib/pre_install_common.sh | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/script/config.sh b/script/config.sh index 7af8501..fccb91f 100644 --- a/script/config.sh +++ b/script/config.sh @@ -44,7 +44,7 @@ export ISEFI=0 # No, BIOS fi # is EFI firmaare? # Set partition number based on the firmware type -if [ ${ISEFI} -eq 1 ] ; then +if [ ${ISEFI} -ne 0 ] ; then # EFI firmware export EFIPARTITION=1 export CRYPTPARTITION=2 diff --git a/script/lib/confirmation_common.sh b/script/lib/confirmation_common.sh index a9a8130..b8b25e2 100644 --- a/script/lib/confirmation_common.sh +++ b/script/lib/confirmation_common.sh @@ -6,7 +6,7 @@ function confirmation_common(){ # Consistency check for the OVERWRITEINSTALL and ERASEALL - if [ "${ERASEALL}" -eq 1 ] && [ "${OVERWRITEINSTALL}" -eq 1 ] ; then + if [ "${ERASEALL}" -ne 0 ] && [ "${OVERWRITEINSTALL}" -ne 0 ] ; then cat <<- HEREDOC ***** ERROR : Confliction between ERASEALL and OVERWRITEINSTALL ***** ...ERASEALL = ${ERASEALL} @@ -71,7 +71,7 @@ function confirmation_common(){ fi # if YES # For sure ask to be sure to erase. - if [ "${ERASEALL}" -eq 1 ] ; then + if [ "${ERASEALL}" -ne 0 ] ; then echo "Are you sure you want to erase entire ${DEV}? [Y/N]" read -r YESNO if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then diff --git a/script/lib/para_install_msg_common.sh b/script/lib/para_install_msg_common.sh index 56e7167..fe21165 100644 --- a/script/lib/para_install_msg_common.sh +++ b/script/lib/para_install_msg_common.sh @@ -14,7 +14,7 @@ function para_install_msg_common() { HEREDOC # In the EFI system, add this mapping - if [ "${ISEFI}" -eq 1 ] ; then + if [ "${ISEFI}" -ne 0 ] ; then echo "/boot/efi : ${DEV}${EFIPARTITION}" fi @@ -22,7 +22,7 @@ function para_install_msg_common() { echo "/ : /dev/mapper/${VGNAME}-${LVROOTNAME}" # In case of erased storage, add this mapping - if [ "${ERASEALL}" -eq 1 ] ; then + if [ "${ERASEALL}" -ne 0 ] ; then echo "swap : /dev/mapper/${VGNAME}-${LVSWAPNAME}" fi diff --git a/script/lib/pre_install_common.sh b/script/lib/pre_install_common.sh index 98efaaa..bb61fb9 100644 --- a/script/lib/pre_install_common.sh +++ b/script/lib/pre_install_common.sh @@ -7,10 +7,10 @@ function pre_install_common() { # ----- Erase entire disk, create partitions, format them and encrypt the LUKS partition ----- - if [ "${ERASEALL}" -eq 1 ] ; then + if [ "${ERASEALL}" -ne 0 ] ; then # Assign specified space and rest of disk to the EFI and LUKS partition, respectively. - if [ "${ISEFI}" -eq 1 ] ; then + if [ "${ISEFI}" -ne 0 ] ; then # EFI # Zap existing partition table and create new GPT echo "...Initializing \"${DEV}\" with GPT." sgdisk --zap-all "${DEV}" @@ -24,7 +24,7 @@ function pre_install_common() { sgdisk --new="${CRYPTPARTITION}":0:0 --change-name="${CRYPTPARTITION}":"Linux LUKS" --typecode="${CRYPTPARTITION}":8309 "${DEV}" # Then print them sgdisk --print "${DEV}" - else + else # BIOS # Zap existing partition table echo "...Erasing partition table of \"${DEV}\"." dd if=/dev/zero of="${DEV}" bs=512 count=1 @@ -80,7 +80,7 @@ function pre_install_common() { # Create a ROOT Logical Volume on VG. if [ -e /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" ] ; then # exist - if [ "${OVERWRITEINSTALL}" -eq 1 ] ; then # exist and overwrite install + if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then # exist and overwrite install echo "...Logical volume \"${VGNAME}-${LVROOTNAME}\" already exists. OK." else # exist and not overwriteinstall cat <<- HEREDOC @@ -98,7 +98,7 @@ function pre_install_common() { return 1 # with error status fi else # not exsit - if [ "${OVERWRITEINSTALL}" -eq 1 ] ; then + if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then cat <<- HEREDOC ***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" doesn't exist while overwrite install. ***** ...Check consistency of your config.txt. From c089a8c70178b67dc3c8b939cb21b7994cb041bc Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 08:26:57 +0900 Subject: [PATCH 15/35] Add #! to superss error message --- script/config.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/script/config.sh b/script/config.sh index fccb91f..6f0f32f 100644 --- a/script/config.sh +++ b/script/config.sh @@ -1,3 +1,5 @@ +#!/bin/bash + # Configuration parameters for Kaiten-Yaki # Storage device to install the linux. From 594dfedc24c6d220567c1dc2dd601aaf419a2370 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 08:32:58 +0900 Subject: [PATCH 16/35] Add shellcheck disable to suppress --- script/lib/pre_install_common.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/script/lib/pre_install_common.sh b/script/lib/pre_install_common.sh index bb61fb9..97fd970 100644 --- a/script/lib/pre_install_common.sh +++ b/script/lib/pre_install_common.sh @@ -16,11 +16,13 @@ function pre_install_common() { sgdisk --zap-all "${DEV}" # Create EFI partition and format it echo "...Creating an EFI partition on \"${DEV}\"." + # shellcheck disable=SC2140 sgdisk --new="${EFIPARTITION}":0:+"${EFISIZE}" --change-name="${EFIPARTITION}":"EFI System" --typecode="${EFIPARTITION}":ef00 "${DEV}" echo "...Formatting the EFI parttion." mkfs.vfat -F 32 -n EFI-SP "${DEV}${EFIPARTITION}" # Create Linux partition echo "...Creating a Linux partition on ${DEV}." + # shellcheck disable=SC2140 sgdisk --new="${CRYPTPARTITION}":0:0 --change-name="${CRYPTPARTITION}":"Linux LUKS" --typecode="${CRYPTPARTITION}":8309 "${DEV}" # Then print them sgdisk --print "${DEV}" From 0779994278d2277dafead3f67038bca32116e3a9 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 08:39:01 +0900 Subject: [PATCH 17/35] Add shell check disable To supress unnessary message in the post-install --- script/ubuntu-kaiten-yaki.sh | 3 ++- script/void-kaiten-yaki.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/script/ubuntu-kaiten-yaki.sh b/script/ubuntu-kaiten-yaki.sh index 716af88..2b75657 100644 --- a/script/ubuntu-kaiten-yaki.sh +++ b/script/ubuntu-kaiten-yaki.sh @@ -115,6 +115,7 @@ function post_install() { # Change root and create the keyfile and ramfs image for Linux kernel. echo "...Chroot to ${TARGETMOUNTPOINT}." + # shellcheck disable=SC2086 cat <<- HEREDOC | chroot ${TARGETMOUNTPOINT} /bin/bash # Mount the rest of partitions by target /etc/fstab mount -a @@ -136,7 +137,7 @@ function post_install() { # Add the LUKS volume information to /etc/crypttab to decrypt by kernel. echo "...Adding LUKS volume info to /etc/crypttab." - echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value "${DEV}${CRYPTPARTITION}") /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab + echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab # Putting key file into the ramfs initial image echo "...Registering key file to the ramfs" diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index a22beb5..0d89ec1 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -142,6 +142,7 @@ function post_install() { # Change root and create the keyfile and ramfs image for Linux kernel. echo "...Chroot to ${TARGETMOUNTPOINT}." + # shellcheck disable=SC2086 cat <<- HEREDOC | chroot ${TARGETMOUNTPOINT} /bin/bash # Mount the rest of partitions by target /etc/fstab mount -a @@ -163,7 +164,7 @@ function post_install() { # Add the LUKS volume information to /etc/crypttab to decrypt by kernel. echo "...Adding LUKS volume info to /etc/crypttab." - echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value "${DEV}""${CRYPTPARTITION}") /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab + echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab # Putting key file into the ramfs initial image echo "...Registering key file to the ramfs" From 6bbab99badb074cccbb747b4ce1220f6df72cf76 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 09:03:45 +0900 Subject: [PATCH 18/35] Refactor canceling proces Gather the common canceling process to one function --- script/ubuntu-kaiten-yaki.sh | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/script/ubuntu-kaiten-yaki.sh b/script/ubuntu-kaiten-yaki.sh index 2b75657..e9fb934 100644 --- a/script/ubuntu-kaiten-yaki.sh +++ b/script/ubuntu-kaiten-yaki.sh @@ -2,12 +2,10 @@ # shellcheck disable=SC1091 # Load configuration parameter - source config.sh + source ./config.sh # Load functions - source lib/confirmation_common.sh - source lib/pre_install_common.sh - source lib/para_install_msg_common.sh + source ./lib.sh function main() { @@ -39,7 +37,7 @@ function main() { # ******************************************************************************* # Common part of the parameter confirmation - if ! confirmation_common ; then + if ! confirmation ; then return 1 # with error status fi @@ -48,7 +46,7 @@ function main() { # ******************************************************************************* # Common part of the pre-install stage - if ! pre_install_common ; then + if ! pre_install ; then return 1 # with error status fi @@ -58,7 +56,7 @@ function main() { # ******************************************************************************* # Show common message to let the operator focus on the critical part - para_install_msg_common + para_install_msg # Ubuntu dependent message cat <<- HEREDOC @@ -177,22 +175,10 @@ function grub_check_and_modify() { do sleep 1 # 1sec. - # Check if installer still exist + # Check if installer quit unexpectedly if ! ps $INSTALLER_PID > /dev/null ; then # If not exists - echo "***** ERROR : The GUI/TUI installer terminated unexpectedly. *****" - if [ "${OVERWRITEINSTALL}" -eq 0 ] ; then # If not over install, volume is new. So delete it - echo "...Deleting the new logical volume \"${VGNAME}-${LVROOTNAME}\"." - lvremove -f /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" - fi - echo "...Deactivating all logical volumes in volume group \"${VGNAME}\"." - vgchange -a n "${VGNAME}" - echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." - cryptsetup close "${CRYPTPARTNAME}" - cat <<-HEREDOC - - ...The new logical volume has been deleted. You can retry Kaiten-yaki again. - ...Installation process terminated. - HEREDOC + # Delete the nwe volume if overwrite install, and close all + on_unexpected_installer_quit return 1 # with error status fi done # while From 8ab81438381c2c4d7cc2e35d37e33215aedab8ae Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 09:34:22 +0900 Subject: [PATCH 19/35] Fixed GRUB modification of void installer. Previously, it was adding inifinitly, if install executed repeatedly. And refactored common functions. --- script/lib.sh | 289 ++++++++++++++++++++++++++ script/lib/confirmation_common.sh | 109 ---------- script/lib/para_install_msg_common.sh | 30 --- script/lib/pre_install_common.sh | 126 ----------- script/ubuntu-kaiten-yaki.sh | 16 +- script/void-kaiten-yaki.sh | 76 ++++--- 6 files changed, 332 insertions(+), 314 deletions(-) create mode 100644 script/lib.sh delete mode 100644 script/lib/confirmation_common.sh delete mode 100644 script/lib/para_install_msg_common.sh delete mode 100644 script/lib/pre_install_common.sh diff --git a/script/lib.sh b/script/lib.sh new file mode 100644 index 0000000..032adae --- /dev/null +++ b/script/lib.sh @@ -0,0 +1,289 @@ +#!/bin/bash -u +# ******************************************************************************* +# Confirmation and Passphrase setting +# ******************************************************************************* + +function confirmation(){ + + # Consistency check for the OVERWRITEINSTALL and ERASEALL + if [ "${ERASEALL}" -ne 0 ] && [ "${OVERWRITEINSTALL}" -ne 0 ] ; then + cat <<- HEREDOC + ***** ERROR : Confliction between ERASEALL and OVERWRITEINSTALL ***** + ...ERASEALL = ${ERASEALL} + ...OVERWRITEINSTALL = ${OVERWRITEINSTALL} + ...Check configuration in your config.sh + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi + + # Sanity check for volume group name + if echo "${VGNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume group name. + cat <<- HEREDOC + ***** ERROR : VGNAME is "${VGNAME}" ***** + ..."-" is not allowed in the volume name. + ...Check configuration in your config.sh + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # "-" is found in the volume group name. + + # Sanity check for root volume name + if echo "${LVROOTNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume name. + cat <<- HEREDOC + ***** ERROR : LVROOTNAME is "${LVROOTNAME}" ***** + ..."-" is not allowed in the volume name. + ...Check configuration in your config.sh + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # "-" is found in the volume name. + + # Sanity check for swap volume name + if echo "${LVSWAPNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume name. + cat <<- HEREDOC + ***** ERROR : LVSWAPNAME is "${LVSWAPNAME}" ***** + ..."-" is not allowed in the volume name. + ...Check configuration in your config.sh + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # "-" is found in the volume name. + + # For surre ask the your config.sh is edited + cat <<- HEREDOC + + The destination logical volume label is "${LVROOTNAME}" + "${LVROOTNAME}" uses ${LVROOTSIZE} of the LVM volume group. + Are you sure to install? [Y/N] + HEREDOC + read -r YESNO + if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then + cat <<- HEREDOC + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # if YES + + # For sure ask to be sure to erase. + if [ "${ERASEALL}" -ne 0 ] ; then + echo "Are you sure you want to erase entire ${DEV}? [Y/N]" + read -r YESNO + if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then + cat <<-HEREDOC + ...Check your config.sh. The variable ERASEALL is ${ERASEALL}. + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # if YES + fi # if erase all + + # ----- Set Passphrase ----- + # Input passphrase + echo "" + echo "Type passphrase for the disk encryption." + read -sr PASSPHRASE + export PASSPHRASE + + echo "Type passphrase again, to confirm." + read -sr PASSPHRASE_C + + # Validate whether both are indentical or not + if [ "${PASSPHRASE}" != "${PASSPHRASE_C}" ] ; then + cat <<-HEREDOC + ***** ERROR : Passphrase doesn't match ***** + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # passphrase validation + + # succesfull return + return 0 +} + + +# ******************************************************************************* +# Pre-install stage +# ******************************************************************************* + +function pre_install() { + + + # ----- Erase entire disk, create partitions, format them and encrypt the LUKS partition ----- + if [ "${ERASEALL}" -ne 0 ] ; then + + # Assign specified space and rest of disk to the EFI and LUKS partition, respectively. + if [ "${ISEFI}" -ne 0 ] ; then # EFI + # Zap existing partition table and create new GPT + echo "...Initializing \"${DEV}\" with GPT." + sgdisk --zap-all "${DEV}" + # Create EFI partition and format it + echo "...Creating an EFI partition on \"${DEV}\"." + # shellcheck disable=SC2140 + sgdisk --new="${EFIPARTITION}":0:+"${EFISIZE}" --change-name="${EFIPARTITION}":"EFI System" --typecode="${EFIPARTITION}":ef00 "${DEV}" + echo "...Formatting the EFI parttion." + mkfs.vfat -F 32 -n EFI-SP "${DEV}${EFIPARTITION}" + # Create Linux partition + echo "...Creating a Linux partition on ${DEV}." + # shellcheck disable=SC2140 + sgdisk --new="${CRYPTPARTITION}":0:0 --change-name="${CRYPTPARTITION}":"Linux LUKS" --typecode="${CRYPTPARTITION}":8309 "${DEV}" + # Then print them + sgdisk --print "${DEV}" + else # BIOS + # Zap existing partition table + echo "...Erasing partition table of \"${DEV}\"." + dd if=/dev/zero of="${DEV}" bs=512 count=1 + # Create MBR and allocate max storage for Linux partition + echo "...Creating a Linux partition on ${DEV} with MBR." + sfdisk "${DEV}" <<- HEREDOC + 2M,,L + HEREDOC + fi # if EFI firmware + + # Encrypt the partition to install Linux + echo "...Initializing \"${DEV}${CRYPTPARTITION}\" as crypt partition" + printf %s "${PASSPHRASE}" | cryptsetup luksFormat --type=luks1 --key-file - --batch-mode "${DEV}${CRYPTPARTITION}" + + fi # if erase all + + # ----- Open the LUKS partition ----- + # Open the crypt partition. + echo "...Opening a crypt partition \"${DEV}${CRYPTPARTITION}\" as \"${CRYPTPARTNAME}\"" + printf %s "${PASSPHRASE}" | cryptsetup open -d - "${DEV}${CRYPTPARTITION}" "${CRYPTPARTNAME}" + + # Check whether successful open. If mapped, it is successful. + if [ ! -e /dev/mapper/"${CRYPTPARTNAME}" ] ; then + cat <<- HEREDOC + ***** ERROR : Cannot open LUKS volume "${CRYPTPARTNAME}" on "${DEV}${CRYPTPARTITION}". ***** + ...Check passphrase and your config.txt + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # if crypt volume is unable to open + + # ----- Configure the LVM in LUKS volume ----- + # Check volume group ${VGNAME} exist or not + if vgdisplay -s "${VGNAME}" &> /dev/null ; then # if exist + echo "...Volume group \"${VGNAME}\" already exist. Skipped to create. No problem." + echo "...Activating all logical volumes in volume group \"${VGNAME}\"." + vgchange -ay + else + echo "...Initializing a physical volume on \"${CRYPTPARTNAME}\"" + pvcreate /dev/mapper/"${CRYPTPARTNAME}" + echo "...And then creating Volume group \"${VGNAME}\"." + vgcreate "${VGNAME}" /dev/mapper/"${CRYPTPARTNAME}" + fi # if /dev/volume-groupt exist + + # Create a SWAP Logical Volume on VG, if it doesn't exist + if [ -e /dev/mapper/"${VGNAME}"-"${LVSWAPNAME}" ] ; then + echo "...Swap volume already exist. Skipped to create. No problem." + else + echo "...Creating logical volume \"${LVSWAPNAME}\" on \"${VGNAME}\"." + lvcreate -L "${LVSWAPSIZE}" -n "${LVSWAPNAME}" "${VGNAME}" + fi # if /dev/mapper/swap volume already exit. + + # Create a ROOT Logical Volume on VG. + if [ -e /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" ] ; then # exist + if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then # exist and overwrite install + echo "...Logical volume \"${VGNAME}-${LVROOTNAME}\" already exists. OK." + else # exist and not overwriteinstall + cat <<- HEREDOC + ***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" already exists. ***** + ...Check LVROOTNAME environment variable in your config.txt. + HEREDOC + # Deactivate all lg and close the LUKS volume + deactivate_and_close + return 1 # with error status + fi + else # not exsit + if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then + cat <<- HEREDOC + ***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" doesn't exist while overwrite install. ***** + ...Check consistency of your config.txt. + HEREDOC + # Deactivate all lg and close the LUKS volume + deactivate_and_close + return 1 # with error status + else # not exist and not overwrite install + echo "...Creating logical volume \"${LVROOTNAME}\" on \"${VGNAME}\"." + lvcreate -l "${LVROOTSIZE}" -n "${LVROOTNAME}" "${VGNAME}" + fi + fi + + + # successful return + return 0 +} + + +# ******************************************************************************* +# Common message in para-install stage +# ******************************************************************************* + +function para_install_msg() { + + cat <<- HEREDOC + ****************************************************************************** + The pre-install process is done. We are ready to install the Linux to the + target storage device. By pressing return key, GUI/TUI installer starts. + + Please pay attention to the partition/logical volume mapping configuration. + In this installation, you have to map the previously created partitions/logical + volumes to the appropriate directories of the target system as followings : + + HEREDOC + + # In the EFI system, add this mapping + if [ "${ISEFI}" -ne 0 ] ; then + echo "/boot/efi : ${DEV}${EFIPARTITION}" + fi + + # Root volume mapping + echo "/ : /dev/mapper/${VGNAME}-${LVROOTNAME}" + + # In case of erased storage, add this mapping + if [ "${ERASEALL}" -ne 0 ] ; then + echo "swap : /dev/mapper/${VGNAME}-${LVSWAPNAME}" + fi + + return 0 +} + +# ******************************************************************************* +# Deactivate all LV in the VG and close LUKS volume +# ******************************************************************************* + +function deactivate_and_close(){ + echo "...Deactivate all logical volumes in volume group \"${VGNAME}\"." + vgchange -a n "${VGNAME}" + echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." + cryptsetup close "${CRYPTPARTNAME}" + cat <<- HEREDOC + + ...Installation process terminated.. + HEREDOC + +} + +# ******************************************************************************* +# Delete the nwe volume if overwrite install, and close all +# ******************************************************************************* + +function on_unexpected_installer_quit(){ + echo "***** ERROR : The GUI/TUI installer terminated unexpectedly. *****" + if [ "${OVERWRITEINSTALL}" -eq 0 ] ; then # If not over install, volume is new. So delete it + echo "...Deleting the new logical volume \"${VGNAME}-${LVROOTNAME}\"." + lvremove -f /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" + fi + # Deactivate all lg and close the LUKS volume + deactivate_and_close + echo "...The new logical volume has been deleted. You can retry Kaiten-yaki again." +} diff --git a/script/lib/confirmation_common.sh b/script/lib/confirmation_common.sh deleted file mode 100644 index b8b25e2..0000000 --- a/script/lib/confirmation_common.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/bash -u -# ******************************************************************************* -# Confirmation and Passphrase setting -# ******************************************************************************* - -function confirmation_common(){ - - # Consistency check for the OVERWRITEINSTALL and ERASEALL - if [ "${ERASEALL}" -ne 0 ] && [ "${OVERWRITEINSTALL}" -ne 0 ] ; then - cat <<- HEREDOC - ***** ERROR : Confliction between ERASEALL and OVERWRITEINSTALL ***** - ...ERASEALL = ${ERASEALL} - ...OVERWRITEINSTALL = ${OVERWRITEINSTALL} - ...Check configuration in your config.sh - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi - - # Sanity check for volume group name - if echo "${VGNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume group name. - cat <<- HEREDOC - ***** ERROR : VGNAME is "${VGNAME}" ***** - ..."-" is not allowed in the volume name. - ...Check configuration in your config.sh - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # "-" is found in the volume group name. - - # Sanity check for root volume name - if echo "${LVROOTNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume name. - cat <<- HEREDOC - ***** ERROR : LVROOTNAME is "${LVROOTNAME}" ***** - ..."-" is not allowed in the volume name. - ...Check configuration in your config.sh - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # "-" is found in the volume name. - - # Sanity check for swap volume name - if echo "${LVSWAPNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume name. - cat <<- HEREDOC - ***** ERROR : LVSWAPNAME is "${LVSWAPNAME}" ***** - ..."-" is not allowed in the volume name. - ...Check configuration in your config.sh - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # "-" is found in the volume name. - - # For surre ask the your config.sh is edited - cat <<- HEREDOC - - The destination logical volume label is "${LVROOTNAME}" - "${LVROOTNAME}" uses ${LVROOTSIZE} of the LVM volume group. - Are you sure to install? [Y/N] - HEREDOC - read -r YESNO - if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then - cat <<- HEREDOC - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # if YES - - # For sure ask to be sure to erase. - if [ "${ERASEALL}" -ne 0 ] ; then - echo "Are you sure you want to erase entire ${DEV}? [Y/N]" - read -r YESNO - if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then - cat <<-HEREDOC - ...Check your config.sh. The variable ERASEALL is ${ERASEALL}. - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # if YES - fi # if erase all - - # ----- Set Passphrase ----- - # Input passphrase - echo "" - echo "Type passphrase for the disk encryption." - read -sr PASSPHRASE - export PASSPHRASE - - echo "Type passphrase again, to confirm." - read -sr PASSPHRASE_C - - # Validate whether both are indentical or not - if [ "${PASSPHRASE}" != "${PASSPHRASE_C}" ] ; then - cat <<-HEREDOC - ***** ERROR : Passphrase doesn't match ***** - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # passphrase validation - - # succesfull return - return 0 -} diff --git a/script/lib/para_install_msg_common.sh b/script/lib/para_install_msg_common.sh deleted file mode 100644 index fe21165..0000000 --- a/script/lib/para_install_msg_common.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -u - -function para_install_msg_common() { - - cat <<- HEREDOC - ****************************************************************************** - The pre-install process is done. We are ready to install the Linux to the - target storage device. By pressing return key, GUI/TUI installer starts. - - Please pay attention to the partition/logical volume mapping configuration. - In this installation, you have to map the previously created partitions/logical - volumes to the appropriate directories of the target system as followings : - - HEREDOC - - # In the EFI system, add this mapping - if [ "${ISEFI}" -ne 0 ] ; then - echo "/boot/efi : ${DEV}${EFIPARTITION}" - fi - - # Root volume mapping - echo "/ : /dev/mapper/${VGNAME}-${LVROOTNAME}" - - # In case of erased storage, add this mapping - if [ "${ERASEALL}" -ne 0 ] ; then - echo "swap : /dev/mapper/${VGNAME}-${LVSWAPNAME}" - fi - - return 0 -} \ No newline at end of file diff --git a/script/lib/pre_install_common.sh b/script/lib/pre_install_common.sh deleted file mode 100644 index 97fd970..0000000 --- a/script/lib/pre_install_common.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/bash -u -# ******************************************************************************* -# Pre-install stage -# ******************************************************************************* - -function pre_install_common() { - - - # ----- Erase entire disk, create partitions, format them and encrypt the LUKS partition ----- - if [ "${ERASEALL}" -ne 0 ] ; then - - # Assign specified space and rest of disk to the EFI and LUKS partition, respectively. - if [ "${ISEFI}" -ne 0 ] ; then # EFI - # Zap existing partition table and create new GPT - echo "...Initializing \"${DEV}\" with GPT." - sgdisk --zap-all "${DEV}" - # Create EFI partition and format it - echo "...Creating an EFI partition on \"${DEV}\"." - # shellcheck disable=SC2140 - sgdisk --new="${EFIPARTITION}":0:+"${EFISIZE}" --change-name="${EFIPARTITION}":"EFI System" --typecode="${EFIPARTITION}":ef00 "${DEV}" - echo "...Formatting the EFI parttion." - mkfs.vfat -F 32 -n EFI-SP "${DEV}${EFIPARTITION}" - # Create Linux partition - echo "...Creating a Linux partition on ${DEV}." - # shellcheck disable=SC2140 - sgdisk --new="${CRYPTPARTITION}":0:0 --change-name="${CRYPTPARTITION}":"Linux LUKS" --typecode="${CRYPTPARTITION}":8309 "${DEV}" - # Then print them - sgdisk --print "${DEV}" - else # BIOS - # Zap existing partition table - echo "...Erasing partition table of \"${DEV}\"." - dd if=/dev/zero of="${DEV}" bs=512 count=1 - # Create MBR and allocate max storage for Linux partition - echo "...Creating a Linux partition on ${DEV} with MBR." - sfdisk "${DEV}" <<- HEREDOC - 2M,,L - HEREDOC - fi # if EFI firmware - - # Encrypt the partition to install Linux - echo "...Initializing \"${DEV}${CRYPTPARTITION}\" as crypt partition" - printf %s "${PASSPHRASE}" | cryptsetup luksFormat --type=luks1 --key-file - --batch-mode "${DEV}${CRYPTPARTITION}" - - fi # if erase all - - # ----- Open the LUKS partition ----- - # Open the crypt partition. - echo "...Opening a crypt partition \"${DEV}${CRYPTPARTITION}\" as \"${CRYPTPARTNAME}\"" - printf %s "${PASSPHRASE}" | cryptsetup open -d - "${DEV}${CRYPTPARTITION}" "${CRYPTPARTNAME}" - - # Check whether successful open. If mapped, it is successful. - if [ ! -e /dev/mapper/"${CRYPTPARTNAME}" ] ; then - cat <<- HEREDOC - ***** ERROR : Cannot open LUKS volume "${CRYPTPARTNAME}" on "${DEV}${CRYPTPARTITION}". ***** - ...Check passphrase and your config.txt - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # if crypt volume is unable to open - - # ----- Configure the LVM in LUKS volume ----- - # Check volume group ${VGNAME} exist or not - if vgdisplay -s "${VGNAME}" &> /dev/null ; then # if exist - echo "...Volume group \"${VGNAME}\" already exist. Skipped to create. No problem." - echo "...Activating all logical volumes in volume group \"${VGNAME}\"." - vgchange -ay - else - echo "...Initializing a physical volume on \"${CRYPTPARTNAME}\"" - pvcreate /dev/mapper/"${CRYPTPARTNAME}" - echo "...And then creating Volume group \"${VGNAME}\"." - vgcreate "${VGNAME}" /dev/mapper/"${CRYPTPARTNAME}" - fi # if /dev/volume-groupt exist - - # Create a SWAP Logical Volume on VG, if it doesn't exist - if [ -e /dev/mapper/"${VGNAME}"-"${LVSWAPNAME}" ] ; then - echo "...Swap volume already exist. Skipped to create. No problem." - else - echo "...Creating logical volume \"${LVSWAPNAME}\" on \"${VGNAME}\"." - lvcreate -L "${LVSWAPSIZE}" -n "${LVSWAPNAME}" "${VGNAME}" - fi # if /dev/mapper/swap volume already exit. - - # Create a ROOT Logical Volume on VG. - if [ -e /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" ] ; then # exist - if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then # exist and overwrite install - echo "...Logical volume \"${VGNAME}-${LVROOTNAME}\" already exists. OK." - else # exist and not overwriteinstall - cat <<- HEREDOC - ***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" already exists. ***** - ...Check LVROOTNAME environment variable in your config.txt. - HEREDOC - echo "...Deactivating all logical volumes in volume group \"${VGNAME}\"." - vgchange -a n "${VGNAME}" - echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." - cryptsetup close "${CRYPTPARTNAME}" - cat <<- HEREDOC - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi - else # not exsit - if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then - cat <<- HEREDOC - ***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" doesn't exist while overwrite install. ***** - ...Check consistency of your config.txt. - HEREDOC - echo "...Deactivate all logical volumes in volume group \"${VGNAME}\"." - vgchange -a n "${VGNAME}" - echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." - cryptsetup close "${CRYPTPARTNAME}" - cat <<- HEREDOC - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - else # not exist and not overwrite install - echo "...Creating logical volume \"${LVROOTNAME}\" on \"${VGNAME}\"." - lvcreate -l "${LVROOTSIZE}" -n "${LVROOTNAME}" "${VGNAME}" - fi - fi - - - # successful return - return 0 -} diff --git a/script/ubuntu-kaiten-yaki.sh b/script/ubuntu-kaiten-yaki.sh index e9fb934..2207d67 100644 --- a/script/ubuntu-kaiten-yaki.sh +++ b/script/ubuntu-kaiten-yaki.sh @@ -30,7 +30,7 @@ function main() { return 1 # with error status fi # if YES - fi # "Ubuntu" is not found in the OS name. + fi # Distribution check # ******************************************************************************* # Confirmation before installation @@ -58,7 +58,7 @@ function main() { # Show common message to let the operator focus on the critical part para_install_msg - # Ubuntu dependent message + # Distrobution dependent message cat <<- HEREDOC ************************ CAUTION! CAUTION! CAUTION! **************************** @@ -82,7 +82,7 @@ function main() { # Record the install PID, modify the /etc/default/grub of the target, # and then, wait for the end of the intaller. - if ! grub_check_and_modify ; then + if ! grub_check_and_modify_local ; then return 1 # with error status fi @@ -91,7 +91,7 @@ function main() { # ******************************************************************************* # Finalizing. Embedd encryption key into the ramfs image. - post_install + post_install_local # Normal end return 0 @@ -101,7 +101,7 @@ function main() { # ******************************************************************************* # Ubuntu dependent post-installation process -function post_install() { +function post_install_local() { ## 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() { retrun 0 -} # End of post_install() +} # End of post_install_local() # ******************************************************************************* # This function will be executed in the foreguround context, to watch the GUI installer. -function grub_check_and_modify() { +function grub_check_and_modify_local() { # While the /etc/default/grub in the install target is NOT existing, keep sleeping. # If installer terminated without file copy, this script also terminates. @@ -199,7 +199,7 @@ function grub_check_and_modify() { # succesfull return return 0 -} # grub_check_and_modify() +} # grub_check_and_modify_local() # ******************************************************************************* # Execute diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index 0d89ec1..a089463 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -2,12 +2,10 @@ # shellcheck disable=SC1091 # Load configuration parameter - source config.sh + source ./config.sh # Load functions - source lib/confirmation_common.sh - source lib/pre_install_common.sh - source lib/para_install_msg_common.sh + source ./lib.sh function main() { @@ -16,12 +14,12 @@ function main() { # Distribution check if ! uname -a | grep void -i > /dev/null ; then # "Void" is not found in the OS name. - echo "*********************************************************************************" + echo "*******************************************************************************" uname -a cat <<- HEREDOC - ********************************************************************************* + ******************************************************************************* This system seems to be not Void Linux, while this script is dediated to the Void Linux. - Are you sure you want to run this script for installation? [Y/N] + Are you sure you want to run this script? [Y/N] HEREDOC read -r YESNO if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then @@ -29,17 +27,17 @@ function main() { ...Installation process terminated.. HEREDOC - return + return 1 # with error status fi # if YES - fi # "Void" is not found in the OS name. + fi # Distribution check # ******************************************************************************* # Confirmation before installation # ******************************************************************************* # Common part of the parameter confirmation - if ! confirmation_common ; then + if ! confirmation ; then return 1 # with error status fi @@ -50,26 +48,35 @@ function main() { # Install essential packages. xbps-install -y -Su xbps gptfdisk - # Common part of the pre-install stage - if ! pre_install_common ; then - return 1 # with error status - fi - # ADD "rd.auto=1 cryptdevice=/dev/sda2:${CRYPTPARTNAME} root=/dev/mapper/${VGNAME}-${ROOTNAME}" to GRUB. # This is magical part. I have not understood why this is required. # Anyway, without this modification, Void Linux doesn't boot. # Refer https://wiki.voidlinux.org/Install_LVM_LUKS#Installation_using_void-installer - echo "...Modify /etc/default/grub." - sed -i "s#loglevel=4#loglevel=4 rd.auto=1 cryptdevice=${DEV}${CRYPTPARTITION}:${CRYPTPARTNAME} root=/dev/mapper/${VGNAME}-${LVROOTNAME}#" /etc/default/grub + # This modification is guaratnteed once only. To allow re-trying the installation after unexpected GUI/TUI installer quit. + grub_additional_parameters="rd.auto=1 cryptdevice=${DEV}${CRYPTPARTITION}:${CRYPTPARTNAME} root=/dev/mapper/${VGNAME}-${LVROOTNAME}" + if grep "$grub_additional_parameters" /etc/default/grub ; then # Is additonal parameter already added? + # Yes ".../etc/default/grub already modified. OK, skipping to modiy." + echo + else + # Not yet. Let's add. + echo "...Modify /etc/default/grub." + sed -i "s#loglevel=4#loglevel=4 ${grub_additional_parameters}#" /etc/default/grub + + fi + + # Common part of the pre-install stage + if ! pre_install ; then + return 1 # with error status + fi # ******************************************************************************* # Para-install stage # ******************************************************************************* # Show common message to let the operator focus on the critical part - para_install_msg_common + para_install_msg - # Void-Linux dependent message + # Distrobution dependent message cat <<- HEREDOC ************************ CAUTION! CAUTION! CAUTION! **************************** @@ -86,7 +93,7 @@ function main() { # Start the background target/etc/default/grub cheker. # The definition of this function is down below. - grub_check_and_modify_void & + grub_check_and_modify_local & # Record the PID of the background checker. grub_check_and_modify_id=$! @@ -96,22 +103,9 @@ function main() { # Check if background checker still exist if ps $grub_check_and_modify_id > /dev/null ; then # If exists - # If exist, the grub was not modifyed -> void-installer termianted unexpectedly - - echo "***** ERROR : The GUI/TUI installer terminated unexpectedly. *****" - if [ "${OVERWRITEINSTALL}" -eq 0 ] ; then # If not over install, volume is new. So delete it - echo "...Deleting the new logical volume \"${VGNAME}-${LVROOTNAME}\"." - lvremove -f /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" - fi - echo "...Deactivating all logical volumes in volume group \"${VGNAME}\"." - vgchange -a n "${VGNAME}" - echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." - cryptsetup close "${CRYPTPARTNAME}" - cat <<-HEREDOC - - ...The new logical volume has been deleted. You can retry Kaiten-yaki again. - ...Installation process terminated. - HEREDOC + # If exist, the grub was not modifyed -> void-installer termianted unexpectedly + # Delete the nwe volume if overwrite install, and close all + on_unexpected_installer_quit return 1 # with error status fi @@ -120,7 +114,7 @@ function main() { # ******************************************************************************* # Finalizing. Embedd encryption key into the ramfs image. - post_install + post_install_local # Normal end return 0 @@ -130,7 +124,7 @@ function main() { # ******************************************************************************* # Void Linux dependent post-installation process -function post_install() { +function post_install_local() { ## Mount the target file system # ${TARGETMOUNTPOINT} is created by the GUI/TUI installer echo "...Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${TARGETMOUNTPOINT}." @@ -194,12 +188,12 @@ function post_install() { retrun 0 -} # End of post_install() +} # End of post_install_local() # ******************************************************************************* # This function will be executed in the background context, to watch the TUI installer. -function grub_check_and_modify_void() { +function grub_check_and_modify_local() { # While the /etc/default/grub in the install target is NOT existing, keep sleeping. # If installer terminated without file copy, this script also terminates. @@ -219,7 +213,7 @@ function grub_check_and_modify_void() { # succesfull return return 0 -} # grub_check_and_modify() +} # grub_check_and_modify_local() # ******************************************************************************* # Execute From 2d2d200fefe9ec7489da3d5c7e789309ebea8188 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 09:47:42 +0900 Subject: [PATCH 20/35] Refactored Distribution check is now common function --- script/lib.sh | 29 ++++++++++++++++++++++++++++- script/ubuntu-kaiten-yaki.sh | 30 ++++++++++-------------------- script/void-kaiten-yaki.sh | 32 +++++++++++--------------------- 3 files changed, 49 insertions(+), 42 deletions(-) diff --git a/script/lib.sh b/script/lib.sh index 032adae..5149dea 100644 --- a/script/lib.sh +++ b/script/lib.sh @@ -276,7 +276,6 @@ function deactivate_and_close(){ # ******************************************************************************* # Delete the nwe volume if overwrite install, and close all # ******************************************************************************* - function on_unexpected_installer_quit(){ echo "***** ERROR : The GUI/TUI installer terminated unexpectedly. *****" if [ "${OVERWRITEINSTALL}" -eq 0 ] ; then # If not over install, volume is new. So delete it @@ -287,3 +286,31 @@ function on_unexpected_installer_quit(){ deactivate_and_close echo "...The new logical volume has been deleted. You can retry Kaiten-yaki again." } + + +# ******************************************************************************* +# Check whether given signaure is in the system information +# ******************************************************************************* +function distribution_check(){ + if ! uname -a | grep "${DISTRIBUTIONSIGNATURE}" -i > /dev/null ; then # Signature is not found in the OS name. + echo "*******************************************************************************" + uname -a + cat <<- HEREDOC + ******************************************************************************* + This system seems to be not $DISTRIBUTIONNAME, while this script is dediated to the $DISTRIBUTIONNAME. + Are you sure you want to run this script? [Y/N] + HEREDOC + read -r YESNO + if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then + cat <<- HEREDOC + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # if YES + + fi # Distribution check + + # no error + return 0 +} \ No newline at end of file diff --git a/script/ubuntu-kaiten-yaki.sh b/script/ubuntu-kaiten-yaki.sh index 2207d67..27ef8a6 100644 --- a/script/ubuntu-kaiten-yaki.sh +++ b/script/ubuntu-kaiten-yaki.sh @@ -4,7 +4,7 @@ # Load configuration parameter source ./config.sh - # Load functions + # Load common functions source ./lib.sh function main() { @@ -12,30 +12,20 @@ function main() { # This is the mount point of the install target. export TARGETMOUNTPOINT="/target" - # Distribution check - if ! uname -a | grep ubuntu -i > /dev/null ; then # "Ubuntu" is not found in the OS name. - echo "*******************************************************************************" - uname -a - cat <<- HEREDOC - ******************************************************************************* - This system seems to be not Ubuntu, while this script is dediated to the Ubuntu. - Are you sure you want to run this script? [Y/N] - HEREDOC - read -r YESNO - if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then - cat <<- HEREDOC - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # if YES - - fi # Distribution check # ******************************************************************************* # Confirmation before installation # ******************************************************************************* + # parameters for distribution check + export DISTRIBUTIONSIGNATURE="ubuntu" + export DISTRIBUTIONNAME="Ubuntu" + + # Check whetehr given signature exist or not + if ! distribution_check ; then + return 1 # with error status + fi + # Common part of the parameter confirmation if ! confirmation ; then return 1 # with error status diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index a089463..4af9fea 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -4,38 +4,28 @@ # Load configuration parameter source ./config.sh - # Load functions + # Load common functions source ./lib.sh function main() { # This is the mount point of the install target. export TARGETMOUNTPOINT="/mnt/target" - - # Distribution check - if ! uname -a | grep void -i > /dev/null ; then # "Void" is not found in the OS name. - echo "*******************************************************************************" - uname -a - cat <<- HEREDOC - ******************************************************************************* - This system seems to be not Void Linux, while this script is dediated to the Void Linux. - Are you sure you want to run this script? [Y/N] - HEREDOC - read -r YESNO - if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then - cat <<- HEREDOC - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # if YES - - fi # Distribution check + # ******************************************************************************* # Confirmation before installation # ******************************************************************************* + # parameters for distribution check + export DISTRIBUTIONSIGNATURE="void" + export DISTRIBUTIONNAME="Void Linux" + + # Check whetehr given signature exist or not + if ! distribution_check ; then + return 1 # with error status + fi + # Common part of the parameter confirmation if ! confirmation ; then return 1 # with error status From de0e689e278ea1a45f94ce7c4dff2793fc091bf1 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 10:02:38 +0900 Subject: [PATCH 21/35] Refactored The para-install part is now local function --- script/ubuntu-kaiten-yaki.sh | 33 ++++++++++++++++++++++----------- script/void-kaiten-yaki.sh | 35 +++++++++++++++++++++++------------ 2 files changed, 45 insertions(+), 23 deletions(-) diff --git a/script/ubuntu-kaiten-yaki.sh b/script/ubuntu-kaiten-yaki.sh index 27ef8a6..bd3c42e 100644 --- a/script/ubuntu-kaiten-yaki.sh +++ b/script/ubuntu-kaiten-yaki.sh @@ -45,6 +45,27 @@ function main() { # Para-install stage # ******************************************************************************* + # Start the GUI installer and modify the target /etc/default/grub in parallel + if ! para_install_local ; then + return 1 # with error status + fi + + # ******************************************************************************* + # Post-install stage + # ******************************************************************************* + + # Distribution dependent finalizing. Embedd encryption key into the ramfs image. + post_install_local + + # Normal end + return 0 + +} # End of main() + + +# ******************************************************************************* +# Ubuntu dependent para-installation process +function para_install_local() { # Show common message to let the operator focus on the critical part para_install_msg @@ -76,18 +97,8 @@ function main() { return 1 # with error status fi - # ******************************************************************************* - # Post-install stage - # ******************************************************************************* - - # Finalizing. Embedd encryption key into the ramfs image. - post_install_local - - # Normal end return 0 - -} # End of main() - +} # ******************************************************************************* # Ubuntu dependent post-installation process diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index 4af9fea..98ddc4e 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -11,7 +11,7 @@ function main() { # This is the mount point of the install target. export TARGETMOUNTPOINT="/mnt/target" - + # ******************************************************************************* # Confirmation before installation @@ -63,6 +63,27 @@ function main() { # Para-install stage # ******************************************************************************* + # Start the TUI installer and modify the target /etc/default/grub in background + if ! para_install_local ; then + return 1 # with error status + fi + + # ******************************************************************************* + # Post-install stage + # ******************************************************************************* + + # Distribution dependent finalizing. Embedd encryption key into the ramfs image. + post_install_local + + # Normal end + return 0 + +} # End of main() + + +# ******************************************************************************* +# Void Linux dependent post-installation process +function para_install_local() { # Show common message to let the operator focus on the critical part para_install_msg @@ -99,18 +120,8 @@ function main() { return 1 # with error status fi - # ******************************************************************************* - # Post-install stage - # ******************************************************************************* - - # Finalizing. Embedd encryption key into the ramfs image. - post_install_local - - # Normal end return 0 - -} # End of main() - +} # ******************************************************************************* # Void Linux dependent post-installation process From 7e68b3ea665310788ab8d73ca0ef56f4a434d4c2 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 10:04:17 +0900 Subject: [PATCH 22/35] fixed problem of echo --- script/void-kaiten-yaki.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index 98ddc4e..06a2c8f 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -45,8 +45,8 @@ function main() { # This modification is guaratnteed once only. To allow re-trying the installation after unexpected GUI/TUI installer quit. grub_additional_parameters="rd.auto=1 cryptdevice=${DEV}${CRYPTPARTITION}:${CRYPTPARTNAME} root=/dev/mapper/${VGNAME}-${LVROOTNAME}" if grep "$grub_additional_parameters" /etc/default/grub ; then # Is additonal parameter already added? - # Yes ".../etc/default/grub already modified. OK, skipping to modiy." - echo + # Yes + echo ".../etc/default/grub already modified. OK, skipping to modiy." else # Not yet. Let's add. echo "...Modify /etc/default/grub." From 7da5ec364770f97c661f5c614dffcb3ba824bd4d Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 10:07:20 +0900 Subject: [PATCH 23/35] Correct comment anf line --- script/ubuntu-kaiten-yaki.sh | 2 +- script/void-kaiten-yaki.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/script/ubuntu-kaiten-yaki.sh b/script/ubuntu-kaiten-yaki.sh index bd3c42e..31edb18 100644 --- a/script/ubuntu-kaiten-yaki.sh +++ b/script/ubuntu-kaiten-yaki.sh @@ -81,7 +81,7 @@ function para_install_local() { Type return key to start Ubiquity. HEREDOC - # waitfor a console input + # waiting for a console input read -r # Start Ubiquity installer diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index 06a2c8f..af6fd85 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -59,6 +59,7 @@ function main() { return 1 # with error status fi + # ******************************************************************************* # Para-install stage # ******************************************************************************* @@ -99,7 +100,7 @@ function para_install_local() { Type return key to start void-installer. HEREDOC - # waitfor a console input + # waiting for a console input read -r # Start the background target/etc/default/grub cheker. From fd199999ace45e9968d6754efa42d8e369a597c2 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 12:04:14 +0900 Subject: [PATCH 24/35] Correct missspelled command retrun -> return --- script/ubuntu-kaiten-yaki.sh | 2 +- script/void-kaiten-yaki.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script/ubuntu-kaiten-yaki.sh b/script/ubuntu-kaiten-yaki.sh index 31edb18..34b4b8f 100644 --- a/script/ubuntu-kaiten-yaki.sh +++ b/script/ubuntu-kaiten-yaki.sh @@ -161,7 +161,7 @@ function post_install_local() { ...Ready to reboot. HEREDOC - retrun 0 + return 0 } # End of post_install_local() diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index af6fd85..423ffc4 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -188,7 +188,7 @@ function post_install_local() { ...Ready to reboot. HEREDOC - retrun 0 + return 0 } # End of post_install_local() From 73f346f2751710173172b6ea9ec7f1e74aaec82b Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 12:14:33 +0900 Subject: [PATCH 25/35] changed example sudo to smarter format --- INSTALL.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index d6ac499..1aeb00f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -23,12 +23,11 @@ First of all, promote the shell to root. Almost of the procedure requires root p In case of Ubuntu : ```bash # Promote to the root user -sudo -i +sudo -i /bin/bash ``` In case of Void-Linux : ```bash -sudo -i -bash +sudo -i /bin/bash xbps-install -Su xbps nano ``` The nano is editor package to configure the config.txt. The editor choice is up to you. Kaiten-yaki script doesn't have dependency to nano editor. From 1c707ff903c2e6ce8f849526432fa1434b1a5100 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 12:16:02 +0900 Subject: [PATCH 26/35] Add appropriate indent to the heredocument of chroot --- script/ubuntu-kaiten-yaki.sh | 50 ++++++++++++++++---------------- script/void-kaiten-yaki.sh | 56 ++++++++++++++++++------------------ 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/script/ubuntu-kaiten-yaki.sh b/script/ubuntu-kaiten-yaki.sh index 34b4b8f..a18aa8f 100644 --- a/script/ubuntu-kaiten-yaki.sh +++ b/script/ubuntu-kaiten-yaki.sh @@ -116,38 +116,38 @@ function post_install_local() { echo "...Chroot to ${TARGETMOUNTPOINT}." # shellcheck disable=SC2086 cat <<- HEREDOC | chroot ${TARGETMOUNTPOINT} /bin/bash - # Mount the rest of partitions by target /etc/fstab - mount -a + # Mount the rest of partitions by target /etc/fstab + mount -a - # Set up the kernel hook of encryption - echo "...Installing cryptsetup-initramfs package." - apt -qq install -y cryptsetup-initramfs + # Set up the kernel hook of encryption + echo "...Installing cryptsetup-initramfs package." + apt -qq install -y cryptsetup-initramfs - # Prepare a key file to embed in to the ramfs. - echo "...Prepairing key file." - mkdir /etc/luks - dd if=/dev/urandom of=/etc/luks/boot_os.keyfile bs=4096 count=1 status=none - chmod u=rx,go-rwx /etc/luks - chmod u=r,go-rwx /etc/luks/boot_os.keyfile + # Prepare a key file to embed in to the ramfs. + echo "...Prepairing key file." + mkdir /etc/luks + dd if=/dev/urandom of=/etc/luks/boot_os.keyfile bs=4096 count=1 status=none + chmod u=rx,go-rwx /etc/luks + chmod u=r,go-rwx /etc/luks/boot_os.keyfile - # Add a key to the key file. Use the passphrase in the environment variable. - echo "...Adding a key to the key file." - printf %s "${PASSPHRASE}" | cryptsetup luksAddKey -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile + # Add a key to the key file. Use the passphrase in the environment variable. + echo "...Adding a key to the key file." + printf %s "${PASSPHRASE}" | cryptsetup luksAddKey -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile - # Add the LUKS volume information to /etc/crypttab to decrypt by kernel. - echo "...Adding LUKS volume info to /etc/crypttab." - echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab + # Add the LUKS volume information to /etc/crypttab to decrypt by kernel. + echo "...Adding LUKS volume info to /etc/crypttab." + echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab - # Putting key file into the ramfs initial image - echo "...Registering key file to the ramfs" - echo "KEYFILE_PATTERN=/etc/luks/*.keyfile" >> /etc/cryptsetup-initramfs/conf-hook - echo "UMASK=0077" >> /etc/initramfs-tools/initramfs.conf + # Putting key file into the ramfs initial image + echo "...Registering key file to the ramfs" + echo "KEYFILE_PATTERN=/etc/luks/*.keyfile" >> /etc/cryptsetup-initramfs/conf-hook + echo "UMASK=0077" >> /etc/initramfs-tools/initramfs.conf - # Finally, update the ramfs initial image with the key file. - echo "...Upadting initramfs." - update-initramfs -uk all + # Finally, update the ramfs initial image with the key file. + echo "...Upadting initramfs." + update-initramfs -uk all - # Leave chroot + # Leave chroot HEREDOC # Unmount all diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index 423ffc4..e076fd7 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -140,41 +140,41 @@ function post_install_local() { echo "...Chroot to ${TARGETMOUNTPOINT}." # shellcheck disable=SC2086 cat <<- HEREDOC | chroot ${TARGETMOUNTPOINT} /bin/bash - # Mount the rest of partitions by target /etc/fstab - mount -a + # Mount the rest of partitions by target /etc/fstab + mount -a - # Set up the kernel hook of encryption - echo "...Installing cryptsetup-initramfs package." - xbps-install -y lvm2 cryptsetup + # Set up the kernel hook of encryption + echo "...Installing cryptsetup-initramfs package." + xbps-install -y lvm2 cryptsetup - # Prepare a key file to embed in to the ramfs. - echo "...Prepairing key file." - mkdir /etc/luks - dd if=/dev/urandom of=/etc/luks/boot_os.keyfile bs=4096 count=1 status=none - chmod u=rx,go-rwx /etc/luks - chmod u=r,go-rwx /etc/luks/boot_os.keyfile + # Prepare a key file to embed in to the ramfs. + echo "...Prepairing key file." + mkdir /etc/luks + dd if=/dev/urandom of=/etc/luks/boot_os.keyfile bs=4096 count=1 status=none + chmod u=rx,go-rwx /etc/luks + chmod u=r,go-rwx /etc/luks/boot_os.keyfile - # Add a key to the key file. Use the passphrase in the environment variable. - echo "...Adding a key to the key file." - printf %s "${PASSPHRASE}" | cryptsetup luksAddKey -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile + # Add a key to the key file. Use the passphrase in the environment variable. + echo "...Adding a key to the key file." + printf %s "${PASSPHRASE}" | cryptsetup luksAddKey -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile - # Add the LUKS volume information to /etc/crypttab to decrypt by kernel. - echo "...Adding LUKS volume info to /etc/crypttab." - echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab + # Add the LUKS volume information to /etc/crypttab to decrypt by kernel. + echo "...Adding LUKS volume info to /etc/crypttab." + echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab - # Putting key file into the ramfs initial image - echo "...Registering key file to the ramfs" - echo 'install_items+=" /etc/luks/boot_os.keyfile /etc/crypttab " ' > /etc/dracut.conf.d/10-crypt.conf + # Putting key file into the ramfs initial image + echo "...Registering key file to the ramfs" + echo 'install_items+=" /etc/luks/boot_os.keyfile /etc/crypttab " ' > /etc/dracut.conf.d/10-crypt.conf - # Finally, update the ramfs initial image with the key file. - echo "...Upadting initramfs." - xbps-reconfigure -fa - echo "...grub-mkconfig." - grub-mkconfig -o /boot/grub/grub.cfg - echo "...update-grub." - update-grub + # Finally, update the ramfs initial image with the key file. + echo "...Upadting initramfs." + xbps-reconfigure -fa + echo "...grub-mkconfig." + grub-mkconfig -o /boot/grub/grub.cfg + echo "...update-grub." + update-grub - # Leave chroot + # Leave chroot HEREDOC # Unmount all From 062253981d122c7a35fe6a0f902dc834570c86f0 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 12:35:56 +0900 Subject: [PATCH 27/35] Add vgscan after opening existing LUKS vokume For the confirmation for the operator. --- script/lib.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/script/lib.sh b/script/lib.sh index 5149dea..9aff42b 100644 --- a/script/lib.sh +++ b/script/lib.sh @@ -175,6 +175,8 @@ function pre_install() { echo "...Volume group \"${VGNAME}\" already exist. Skipped to create. No problem." echo "...Activating all logical volumes in volume group \"${VGNAME}\"." vgchange -ay + echo "...Scanning all logical volumes." + vgcscan else echo "...Initializing a physical volume on \"${CRYPTPARTNAME}\"" pvcreate /dev/mapper/"${CRYPTPARTNAME}" @@ -262,7 +264,7 @@ function para_install_msg() { # ******************************************************************************* function deactivate_and_close(){ - echo "...Deactivate all logical volumes in volume group \"${VGNAME}\"." + echo "...Deactivating all logical volumes in volume group \"${VGNAME}\"." vgchange -a n "${VGNAME}" echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." cryptsetup close "${CRYPTPARTNAME}" From 9d3e1d137cf72d9277f181e48144deacd3114071 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 12:46:42 +0900 Subject: [PATCH 28/35] Add restroration of /etac/default/tab --- script/void-kaiten-yaki.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index e076fd7..c5a4cdc 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -43,19 +43,21 @@ function main() { # Anyway, without this modification, Void Linux doesn't boot. # Refer https://wiki.voidlinux.org/Install_LVM_LUKS#Installation_using_void-installer # This modification is guaratnteed once only. To allow re-trying the installation after unexpected GUI/TUI installer quit. - grub_additional_parameters="rd.auto=1 cryptdevice=${DEV}${CRYPTPARTITION}:${CRYPTPARTNAME} root=/dev/mapper/${VGNAME}-${LVROOTNAME}" - if grep "$grub_additional_parameters" /etc/default/grub ; then # Is additonal parameter already added? + export GRUB_ADDITIONAL_PARAMETERS="rd.auto=1 cryptdevice=${DEV}${CRYPTPARTITION}:${CRYPTPARTNAME} root=/dev/mapper/${VGNAME}-${LVROOTNAME}" + if grep "$GRUB_ADDITIONAL_PARAMETERS" /etc/default/grub ; then # Is additonal parameter already added? # Yes echo ".../etc/default/grub already modified. OK, skipping to modiy." else # Not yet. Let's add. echo "...Modify /etc/default/grub." - sed -i "s#loglevel=4#loglevel=4 ${grub_additional_parameters}#" /etc/default/grub + sed -i "s#loglevel=4#loglevel=4 ${GRUB_ADDITIONAL_PARAMETERS}#" /etc/default/grub fi # Common part of the pre-install stage if ! pre_install ; then + echo "...restoring modified /etc/default/grub." + sed -i "s#loglevel=4 ${GRUB_ADDITIONAL_PARAMETERS}#loglevel=4#" /etc/default/grub return 1 # with error status fi @@ -118,6 +120,8 @@ function para_install_local() { # If exist, the grub was not modifyed -> void-installer termianted unexpectedly # Delete the nwe volume if overwrite install, and close all on_unexpected_installer_quit + echo "...restoring modified /etc/default/grub." + sed -i "s#loglevel=4 ${GRUB_ADDITIONAL_PARAMETERS}#loglevel=4#" /etc/default/grub return 1 # with error status fi From 6feba5dafc3280baeea68d3e10ef05123a592bf2 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 13:03:44 +0900 Subject: [PATCH 29/35] Fix command name vgcscan->lvscan --- script/lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/lib.sh b/script/lib.sh index 9aff42b..7c874a6 100644 --- a/script/lib.sh +++ b/script/lib.sh @@ -176,7 +176,7 @@ function pre_install() { echo "...Activating all logical volumes in volume group \"${VGNAME}\"." vgchange -ay echo "...Scanning all logical volumes." - vgcscan + lvscan else echo "...Initializing a physical volume on \"${CRYPTPARTNAME}\"" pvcreate /dev/mapper/"${CRYPTPARTNAME}" From c291e77fd60c0f65d1f102aad937d8fe9c98a72e Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 13:15:08 +0900 Subject: [PATCH 30/35] Removed unneccesarry update-grub --- script/void-kaiten-yaki.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index c5a4cdc..d2c1332 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -175,8 +175,6 @@ function post_install_local() { xbps-reconfigure -fa echo "...grub-mkconfig." grub-mkconfig -o /boot/grub/grub.cfg - echo "...update-grub." - update-grub # Leave chroot HEREDOC From 3858839105a9df55defb7fd11abe060d7a405f0e Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 14:01:27 +0900 Subject: [PATCH 31/35] Brush up the README and INSTALL --- INSTALL.md | 76 +++++++++++++++++++++++++++--------------------------- README.md | 35 +++++++++++++------------ 2 files changed, 56 insertions(+), 55 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 1aeb00f..5954a89 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -5,43 +5,43 @@ Installation requires mainly 2 steps. - Configure the parameters in config.sh. - Run the kaiten-yaki script -You can execute the install script without command line parameter. For example : +You can execute the install script without the command line parameter. For example : ```shell source ubuntu-kaiten-yaki.sh ``` -The first stage of the script is preparation like : erasing disk, format partition, and encryption. This is most critical stage of the entire installation process. This part is controlled by the configuration parameter. Thus, you have to edit the config.txt carefully. +The first stage of the script is preparation like: erasing a disk, format partition, and encryption. This is the most critical stage of the entire installation process. This part is controlled by the configuration parameter. Thus, you have to edit the config.txt carefully. -In the second stage, the distribution dependent GUI/TUI installer is invoked from the running script. That is the Ubiquity/void-installer of Ubuntu/Void linux, respectively. +In the second stage, the distribution-dependent GUI/TUI installer is invoked from the running script. That is the Ubiquity/void-installer of Ubuntu/Void Linux, respectively. -The third stage is easy. There is nothing user can do. Everything is automatic. +The third stage is easy. There is nothing the user can do. Everything is automatic. # Installation Follow the steps below. ## Shell preparation -First of all, promote the shell to root. Almost of the procedure requires root privilege. Note that the scripts requires Bash. +First of all, promote the shell to root. Almost of the procedure requires root privilege. Note that the scripts require Bash. -In case of Ubuntu : +In the case of Ubuntu : ```bash # Promote to the root user sudo -i /bin/bash ``` -In case of Void-Linux : +In the case of Void-Linux : ```bash sudo -i /bin/bash xbps-install -Su xbps nano ``` -The nano is editor package to configure the config.txt. The editor choice is up to you. Kaiten-yaki script doesn't have dependency to nano editor. +The nano is an editor package to configure the config.txt. The choice of editor is up to you. Kaiten-yaki script doesn't have a dependency on nano editor. Then, edit the config.txt. ## Configuration parameters -This is very critical part of the installation. The configuration parameters are in the the config.sh. Edit these parameters before the installation. +This is a very critical part of the installation. The configuration parameters are in the config.sh. Edit these parameters before the installation. Followings are the set of the default settings of the parameters : - Install to **/dev/sda** (DEV). -- Erase entire disk (ERASEALL). +- Erase the entire disk (ERASEALL). - Overwrite install is disabled. -- In case of EFI firmware, 200MB is allocated to the EFI partition (EFISIZE). +- In the case of EFI firmware, 200MB is allocated to the EFI partition (EFISIZE). - Create a logical volume group named "vg1" in the encrypted volume (VGNAME) - Create a swap logical volume named "swap" in the "vg1". The size is 8GB (LVSWAPNAME,LVSWAPSIZE) - Create a logical volume named **"anko"** for / in the "vg1". The size of the **50%** of the entire free space (LVROOTNAME, LVROOTSIZE). @@ -53,30 +53,30 @@ Followings are the set of the default settings of the parameters : export DEV="/dev/sda" # Whether you want to erase all contents of the storage device or not. -# 1 : Yes, I want to erase all. -# 0 : No, I don't. I want to add to the existing LUKS volume. +# 1: Yes, I want to erase all. +# 0: No, I don't. I want to add to the existing LUKS volume. export ERASEALL=1 -# Logical Volume name for your Linux installation. Keep it unique from other distribution. +# Logical Volume name for your Linux installation. Keep it unique from other distributions. export LVROOTNAME="anko" # Logical volume size of the Linux installation. -# 30% mean, new logical volume will use 30% of the free space in the LVM volume group. -# For example, assume the free space is 100GB, and LVROOTSIZE is 30%FREE. Script will create 30GB logical volume. +# 30% means the new logical volume will use 30% of the free space in the LVM volume group. +# For example, assume the free space is 100GB, and LVROOTSIZE is 30%FREE. The script will create a 30GB logical volume. export LVROOTSIZE="50%FREE" -# Set the size of EFI partition and swap partition. The unit is Byte. you can use M,G... notation. +# Set the size of the EFI partition and swap partition. The unit is Byte. you can use M, G... notation. export EFISIZE="200M" export LVSWAPSIZE="8G" # Usually, these names can be left untouched. -# If you change, keep them consistent through all instllation in your system. +# If you change, keep them consistent through all installations in your system. export CRYPTPARTNAME="luks_volume" export VGNAME="vg1" export LVSWAPNAME="swap" -# Do not touch this parameter, unless you understand precisely what you are doing. -# 1 : Overwrite the existing logical volume as root vlume. 0 : Create new logical volume as root volume. +# Do not touch this parameter unless you understand precisely what you are doing. +# 1: Overwrite the existing logical volume as root volume. 0: Create new logical volume as root volume. export OVERWRITEINSTALL=0 # Void Linux only. Ignored in Ubuntu. @@ -85,53 +85,53 @@ export XTERMFONTSIZE=11 ``` There are several restrictions : -- For the first distribution installation, you must set ERASEALL to 1, to erase entire screen and create a LUKS partition. Kaiten-yaki script creates a maximum LUKS partition as possible. -- The LVROOMNAME must be unique among all installations in a computer. Otherwise, Kaiten-yaki terminate at a middle. -- The LVSWAPNAME must be unique among all installations in a computer. Otherwise, Kaiten-yaki creates an unnecessary logical volume. This is waste of storage resource. +- For the first distribution installation, you must set ERASEALL to 1, to erase the entire screen and create a LUKS partition. Kaiten-yaki script creates a maximum LUKS partition as possible. +- The LVROOMNAME must be unique among all installations in a computer. Otherwise, Kaiten-yaki terminates in a middle. +- The LVSWAPNAME must be unique among all installations in a computer. Otherwise, Kaiten-yaki creates an unnecessary logical volume. This is a waste of storage resources. - The EFISIZE and the LVSWAPSIZE are refereed during the first distribution installation only. - The LVROOTSIZE is the size of a logical volume to create. This is a relative value to the existing free space in the volume group. If you want to install 3 distributions in a computer, you may want to set 33%FREE, 50%FREE, and 100%FREE for the first, second, and third distribution installation, respectively. - The name with "-" is not allowed for the VGNAME, LVROOTNAME, and LVSWAPNAME. I saw some installer doesn't work if "-" in in the name. ## About the overwrite-install -The OVERWRITEINSTALL parameter allows you to use an existing logical volume as root volume of the new installation. -This is very danger because of the several aspect like destroying wrong volume and risk of security. But sometimes it is +The OVERWRITEINSTALL parameter allows you to use an existing logical volume as the root volume of the new installation. +This is very dangerous because of several aspects like destroying the wrong volume and the risk of security. But sometimes it is very useful. For example, assume you are installing a distribution by Kaiten-yaki. If you reboot the system at the end of GUI/TUI installer by mistake, your system will never boot again. In this case, the overwrite-install can recycle this "bad" logical volume and let your system boot again. -To use the overwrite-install, you have to set some parameters as following : +To use the overwrite-install, you have to set some parameters as follows: - ERASEALL : 0 - OVERWRITEINSTALL : 1 -And set following parameters as same as previous installation. +And set the following parameters as same as the previous installation. - LVROOTNAME - VGNAME - CRYPTPARTNAME So, Kaiten-yaki will leave the "bad" logical volume and allow you to overwrite it by GUI/TUI installer. -## First stage : Setting up the volumes -After you set the configuration parameters correctly, execute the following command from the shell. Again, you have to be promoted as root user, and you have to use Bash. +## First stage: Setting up the volumes +After you set the configuration parameters correctly, execute the following command from the shell. Again, you have to be promoted as the root user, and you have to use Bash. -In case of Ubuntu : +In the case of Ubuntu : ```bash source ubuntu-kaiten-yaki.sh ``` -In case of Void Linux +In the case of Void Linux ```bash source void-kaiten-yaki.sh ``` -After the several interactive confirmations, Kaiten-yaki will ask you to input a passphrase. This passphrase will be applied to the encryption of the LUKS volume. Make sure you use identical passphrase between all installation of the distributions in a computer. Otherwise, install process terminates with error. +After several interactive confirmations, Kaiten-yaki will ask you to input a passphrase. This passphrase will be applied to the encryption of the LUKS volume. Make sure you use identical passphrases between all installations of the distributions in a computer. Otherwise, the install process terminates with an error. ## Second stage : GUI/TUI installer -After the first script finishes, the GUI/TUI installer starts automatically. Configure it as usual and run it. Ensure you map the followings correctly. +After the first script finishes, the GUI/TUI installer starts automatically. Configure it as usual and run it. Ensure you map the following correctly. Target Directory | Host Volume | Comment -----------------|------------------------|--------------------------------------------------------------- /boot/efi | /dev/sda1 | BIOS system doesn't need this mapping / | /dev/mapper/vg1-ubuntu | Host volume name is up to your configuration parameter. swap | /dev/mapper/swap | Only the first distribution installation requires this mapping. -During the GUI/TUI installer copying files, Kaiten-yaki modifies the /etc/default/grub of target system. This is pretty dirty way. But if we don't modify this file, GUI/TUI installer fails at last. +During the GUI/TUI installer copying files, Kaiten-yaki modifies the /etc/default/grub of the target system. This is the pretty dirty way. But if we don't modify this file, GUI/TUI installer fails at last. ![Ubuntu Partitioning](image/ubuntu_partitioning.png) ![Void Partitioning](image/void_partitioning.png) @@ -142,10 +142,10 @@ At the end of the GUI/TUI installing, do not reboot the system. Click "Continue" ![Ubuntu done](image/ubuntu_done.png) ![Void done](image/void_done.png) -## Third stage : Finalizing -After GUI/TUI installer quit without rebooting, final part of the install process automatically starts. +## Third stage: Finalizing +After GUI/TUI installer quits without rebooting, the final part of the install process automatically starts. -In this section, Kaiten-yaki put the encryption key of the LUKS volume in to the ramfs initial stage to allow the Linux kernel decrypt the LUKS partition which contains root logical volume. So, system will ask you passphrase only once when GRUB start. +In this section, Kaiten-yaki put the encryption key of the LUKS volume into the ramfs initial stage to allow the Linux kernel to decrypt the LUKS partition which contains root logical volume. So, the system will ask you passphrase only once when GRUB starts. -You can reboot the system, if you see the "Ready to reboot" message on the console. +You can reboot the system if you see the "Ready to reboot" message on the console. diff --git a/README.md b/README.md index be9669c..19c8d20 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,20 @@ -# Kaiten-yaki : Yet another full disk encryption for GRUB/Linux -Kaiten-yaki is a script set to help you to make a full disk encryption install to your desktop system. +# Kaiten-yaki: Full disk encryption install script for Linux +Kaiten-yaki is a script set helping to install Linux as full disk encryption to your desktop system. With these scripts, you can install Ubuntu/Void Linux to an encrypted partition easily. -Followings are the list of functionality. -- Support Ubuntu and Void Linux. +The followings are the list of functionalities: +- Ubuntu and Void Linux. - Install from LiveCD/USB. -- Invoke GUI/TUI installer at the middle of script execution, for the ease of installation. +- Invoke GUI/TUI installer automatically at the middle of script execution, for the ease of installation. - Automatic detection of BIOS/EFI firmware and create MBR/GPT, respectively. -- Support to install multiple distributions in a LUKS partition. -- The "/boot" is located in the same logical volume with the "/". -- The swap logical volume is located inside encrypted volume. +- Create an EFI partition, if needed. +- Support multiple boot in a LUKS partition. +- The "/boot" is located in the same logical volume as the "/". +- The swap logical volume is located inside the encrypted volume. - You need to type a passphrase only once in the boot sequence. -With the configuration parameters, you can customize each installation. For example, you can configure the system to have 2, 3 or 4,... distributions in a HDD/SSD, as you want. +With the configuration parameters, you can customize each installation. For example, you can configure the system to have 2, 3, or 4,... distributions in an HDD/SSD, as you want. -Following is the HDD/SSD partitioning plan of these scripts ( In case of BIOS, the disk has MBR and doesn't have EFI partition, while it is depicted here). +Following is the HDD/SSD partitioning plan of these scripts ( In the case of BIOS, the disk has MBR and doesn't have an EFI partition, while it is depicted here). ![Partition Diagram](image/partition_diagram_0.png) @@ -22,7 +23,7 @@ The logical volume size of each Linux distribution (LVROOTSIZE) can be customize As depicted above, the LVM volume group has only one physical volume. # Tested environment -These scripts are tested with following environment. +These scripts are tested with the following environment. - VMWare Workstation 15.5.7 ( EFI/BIOS ) - Ubuntu 20.04.2 amd64 desktop - Ubuntu Mate 20.04.2 amd64 desktop @@ -31,20 +32,20 @@ These scripts are tested with following environment. - void-live-x86_64-20210218.iso # Installation -Start the PC with the LiveCD/LiveUSB of the distribution to install. Download this repository from github, and expand it. +Start the PC with the LiveCD/LiveUSB of the distribution to install. Download this repository from GitHub, and expand it. -Then, go to script directory and follow the procedure in the [INSTALL.md](INSTALL.md) +Then, go to the script directory and follow the procedure in the [INSTALL.md](INSTALL.md) # Known issues -If you install two or more Void Linux in to the EFI system, only the last one can boot without trouble. This is not the problem of Kaiten-yaki. +If you install two or more Void Linux into the EFI system, only the last one can boot without trouble. This is not the problem of Kaiten-yaki. # Variants considerations -Ubuntu has several variants ( flavors ). While I have tested only MATE flavor, other flavor may work correctly as far as it uses Ubiquity installer. +Ubuntu has several variants ( flavors ). While I have tested only MATE flavor, other flavors may work correctly as far as it uses Ubiquity installer. # Acknowledgments -These scripts are based on the script shared on the [myn's diary](https://myn.hatenablog.jp/entry/install-ubuntu-focal-with-lvm-on-luks). That page contains rich information, hint and techniques around the encrypted volume and Ubiquity installer. +These scripts are based on the script shared on [myn's diary](https://myn.hatenablog.jp/entry/install-ubuntu-focal-with-lvm-on-luks). That page contains rich information, hint, and techniques around the encrypted volume and Ubiquity installer. -Also, following documents were very important to study how Void Linux installation works. +Also, the following documents were very important to study how Void Linux installation works. - [Full Disk Encryption](https://docs.voidlinux.org/installation/guides/fde.html) in the Void Handbook. - [Install LVM LUKS](https://wiki.voidlinux.org/Install_LVM_LUKS) (deprecated) # Kaiten-yaki From 10033ca66b81eae0b4c8194aa8b7253a256380b3 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 14:43:30 +0900 Subject: [PATCH 32/35] Simplify the overview. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 19c8d20..c6c0c05 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Kaiten-yaki: Full disk encryption install script for Linux -Kaiten-yaki is a script set helping to install Linux as full disk encryption to your desktop system. With these scripts, you can install Ubuntu/Void Linux to an encrypted partition easily. +Kaiten-yaki is a script set to install to your desktop system. With these scripts, you can install Ubuntu/Void Linux to an encrypted partition easily. The followings are the list of functionalities: - Ubuntu and Void Linux. From b0a2eef99ed1931bf665c353368776de15da2e6c Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 15:01:00 +0900 Subject: [PATCH 33/35] Added change log. --- CHANGELOG.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..7bf44ca --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,17 @@ +# Change log +Record of the modification in project development. + +## [Unreleased] - yyyy-mm-dd + +### Added +- [Issue 1 : Support non-GUI install for Void Linux.](https://github.com/suikan4github/kaiten-yaki/issues/1) + +### Changed +### Deprecated +### Removed +### Fixed +### Security +### Known Issue + + +[Unreleased]: https://github.com/suikan4github/kaiten-yaki/compare/v0.0.0...develop From 659c752d59f732b7835218897d519a2c7c7f44b8 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 21:23:58 +0900 Subject: [PATCH 34/35] Add Thinkpad as test environment --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c6c0c05..3f68709 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ As depicted above, the LVM volume group has only one physical volume. # Tested environment These scripts are tested with the following environment. - VMWare Workstation 15.5.7 ( EFI/BIOS ) +- ThinkPad X200 (BIOS) - Ubuntu 20.04.2 amd64 desktop - Ubuntu Mate 20.04.2 amd64 desktop - void-live-x86_64-20210218-mate.iso From bec49ee8627350d6f6390bc7ee481291b4468804 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 3 Jul 2021 21:26:01 +0900 Subject: [PATCH 35/35] Change the notation a bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f68709..b94af7c 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ If you install two or more Void Linux into the EFI system, only the last one can Ubuntu has several variants ( flavors ). While I have tested only MATE flavor, other flavors may work correctly as far as it uses Ubiquity installer. # Acknowledgments -These scripts are based on the script shared on [myn's diary](https://myn.hatenablog.jp/entry/install-ubuntu-focal-with-lvm-on-luks). That page contains rich information, hint, and techniques around the encrypted volume and Ubiquity installer. +These scripts are based on the script by [myn's diary](https://myn.hatenablog.jp/entry/install-ubuntu-focal-with-lvm-on-luks). That page contains rich information, hint, and techniques around the encrypted volume and Ubiquity installer. Also, the following documents were very important to study how Void Linux installation works. - [Full Disk Encryption](https://docs.voidlinux.org/installation/guides/fde.html) in the Void Handbook.