Refactored

This commit is contained in:
Suikan 2021-07-01 20:57:24 +09:00
parent 3a5446c6ad
commit d51c88949b
6 changed files with 71 additions and 18 deletions

View file

@ -1,7 +1,10 @@
#!/bin/bash
# *******************************************************************************
# Confirmation and Passphrase setting
# *******************************************************************************
function confirmation(){
# 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
@ -11,7 +14,7 @@ Check passphrase and config.txt
Installation terminated.
HEREDOC
return
return 1
fi # "-" is found in the volume group name.
# Sanity check for root volume name
@ -23,7 +26,7 @@ Check passphrase and config.txt
Installation terminated.
HEREDOC
return
return 1
fi # "-" is found in the volume name.
# Sanity check for swap volume name
@ -35,7 +38,7 @@ Check passphrase and config.txt
Installation terminated.
HEREDOC
return
return 1
fi # "-" is found in the volume name.
# For surre ask the config.sh is edited
@ -51,7 +54,7 @@ if [ ${YESNO} != "Y" -a ${YESNO} != "y" ] ; then
Installation terminated.
HEREDOC
return
return 1
fi # if YES
# For sure ask ready to erase.
@ -64,7 +67,7 @@ Check config.sh. The variable ERASEALL is ${ERASEALL}.
Installation terminated.
HEREDOC
return
return 1
fi # if YES
fi # if erase all
@ -81,7 +84,12 @@ read -sr PASSPHRASE_C
if [ ${PASSPHRASE} != ${PASSPHRASE_C} ] ; then
cat <<HEREDOC 1>&2
***** ERROR : Passphrase doesn't match *****
Installation terminated.
HEREDOC
return
return 1
fi # passphrase validation
# succesfull return
return 0
}

View file

@ -1,7 +1,10 @@
#!/bin/bash
# *******************************************************************************
# 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 ]
@ -15,7 +18,7 @@ The installer terminated unexpectedly.
Installation process terminated.
HEREDOC
return
return 1
fi
done # while
@ -26,7 +29,7 @@ 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.
# If the environment is not GUI, keep quiet not to bother the TUI installer.
if [ $PARINSTMSG -eq 1 ]; then
if [ ${PARAINSTMSG} -eq 1 ]; then
echo "...Add GRUB_ENABLE_CRYPTODISK entry to ${TARGETMOUNTPOINT}/etc/default/grub "
fi
echo "GRUB_ENABLE_CRYPTODISK=y" >> ${TARGETMOUNTPOINT}/etc/default/grub
@ -34,7 +37,12 @@ echo "GRUB_ENABLE_CRYPTODISK=y" >> ${TARGETMOUNTPOINT}/etc/default/grub
# And then, wait for the end of installer process
# If the environment is not GUI, keep quiet not to bother the TUI installer.
if [ $PARAINSTMSG -eq 1 ]; then
if [ ${PARAINSTMSG} -eq 1 ]; then
echo "...Waiting for the end of GUI/TUI installer."
fi
wait $installer_pid
# succesfull return
return 0
} # para install

View file

@ -1,3 +1,7 @@
#!/bin/bash
function parainstall_msg() {
cat <<HEREDOC
******************************************************************************
The pre-install process is done. We are ready to install the Linux to the
@ -22,3 +26,5 @@ if [ ${ERASEALL} -eq 1 ] ; then
echo "swap : /dev/mapper/${VGNAME}-${LVSWAPNAME}"
fi
return 0
}

View file

@ -2,6 +2,8 @@
# Pre-install stage
# *******************************************************************************
function pre_install() {
# ----- Erase entire disk, create partitions, format them and encrypt the LUKS partition -----
if [ ${ERASEALL} -eq 1 ] ; then
@ -51,7 +53,7 @@ Check passphrase and config.txt
Installation terminated.
HEREDOC
return
return 1
fi # if crypt volume is unable to open
# ----- Configure the LVM in LUKS volume -----
@ -81,8 +83,12 @@ Check LVROOTNAME environment variable in config.txt.
Installation terminated.
HEREDOC
return
return 1
else
echo "...Create logical volume \"${LVROOTNAME}\" on \"${VGNAME}\"."
lvcreate -l ${LVROOTSIZE} -n ${LVROOTNAME} ${VGNAME}
fi # if the root volun already exist
# successful return
return 0
}