mirror of
https://github.com/suikan4github/kaiten-yaki.git
synced 2025-12-20 10:31:17 -03:00
Refactored
This commit is contained in:
parent
3a5446c6ad
commit
d51c88949b
6 changed files with 71 additions and 18 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -3,6 +3,12 @@
|
|||
# Load configuration parameter
|
||||
source config.sh
|
||||
|
||||
# Load functions
|
||||
source common/confirmation.sh
|
||||
source common/preinstall.sh
|
||||
source common/parainstall.sh
|
||||
source common/parainstall_msg.sh
|
||||
|
||||
# Varidate whether script is executed as sourced or not
|
||||
(return 0 2>/dev/null) && sourced=1 || sourced=0
|
||||
if [ $sourced -eq 0 ] ; then
|
||||
|
|
@ -46,21 +52,28 @@ fi # "Ubuntu" is not found in the OS name.
|
|||
# *******************************************************************************
|
||||
|
||||
# Common part of the parameter confirmation
|
||||
source common/_confirmation.sh
|
||||
if ! confirmation ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# *******************************************************************************
|
||||
# Pre-install stage
|
||||
# *******************************************************************************
|
||||
|
||||
# Common part of the pre-install stage
|
||||
source common/_preinstall.sh
|
||||
if ! pre_install ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
# *******************************************************************************
|
||||
# Para-install stage
|
||||
# *******************************************************************************
|
||||
|
||||
# Show common message to let the operator focus on the critical part
|
||||
source common/_parainstall_msg.sh
|
||||
if ! parainstall ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Ubuntu dependent message
|
||||
cat <<HEREDOC
|
||||
|
|
@ -85,7 +98,7 @@ 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.
|
||||
source common/_parainstall.sh
|
||||
parainstall_msg
|
||||
|
||||
# *******************************************************************************
|
||||
# Post-install stage
|
||||
|
|
|
|||
|
|
@ -3,6 +3,12 @@
|
|||
# Load configuration parameter
|
||||
source config.sh
|
||||
|
||||
# Load functions
|
||||
source common/confirmation.sh
|
||||
source common/preinstall.sh
|
||||
source common/parainstall.sh
|
||||
source common/parainstall_msg.sh
|
||||
|
||||
# Varidate whether script is executed as sourced or not
|
||||
(return 0 2>/dev/null) && sourced=1 || sourced=0
|
||||
if [ $sourced -eq 0 ] ; then
|
||||
|
|
@ -46,7 +52,9 @@ fi # "Void" is not found in the OS name.
|
|||
# *******************************************************************************
|
||||
|
||||
# Common part of the parameter confirmation
|
||||
source common/_confirmation.sh
|
||||
if ! confirmation ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# *******************************************************************************
|
||||
# Pre-install stage
|
||||
|
|
@ -61,7 +69,9 @@ else
|
|||
fi
|
||||
|
||||
# Common part of the pre-install stage
|
||||
source common/_preinstall.sh
|
||||
if ! pre_install ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# ADD "rd.auto=1 cryptdevice=/dev/sda2:${LUKS_NAME} root=/dev/mapper/${VGNAME}-${ROOTNAME}" to GRUB.
|
||||
# This is magical part. I have not understood why this is required.
|
||||
|
|
@ -75,7 +85,9 @@ sed -i "s#loglevel=4#loglevel=4 rd.auto=1 cryptdevice=/dev/sda2:${LUKS_NAME} roo
|
|||
# *******************************************************************************
|
||||
|
||||
# Show common message to let the operator focus on the critical part
|
||||
source common/_parainstall_msg.sh
|
||||
if ! parainstall ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Ubuntu dependent message
|
||||
cat <<HEREDOC
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue