mirror of
https://github.com/suikan4github/kaiten-yaki.git
synced 2025-12-20 02:21:17 -03:00
Refactored script
Add config.txt confirmation Erase all check is moved to before passphrase Add more comment
This commit is contained in:
parent
28203ce0f4
commit
1ee412ee12
3 changed files with 67 additions and 53 deletions
|
|
@ -8,48 +8,61 @@ if [ $sourced -eq 0 ] ; then
|
||||||
Execute as following :
|
Execute as following :
|
||||||
source 1-pre-install.sh
|
source 1-pre-install.sh
|
||||||
|
|
||||||
Installation terminates.
|
Installation terminated.
|
||||||
HEREDOC
|
HEREDOC
|
||||||
exit
|
exit # use "exit" instead of "return", if not "sourced" execusion
|
||||||
fi
|
fi # "sourced" validation
|
||||||
|
|
||||||
|
|
||||||
# ----- Set Passphrase -----
|
|
||||||
# Input passphrase
|
|
||||||
echo "Type passphrase for the disk encryption."
|
|
||||||
read -sr PASSPHRASE
|
|
||||||
|
|
||||||
echo "Type passphrase again, to confirm."
|
|
||||||
read -sr PASSPHRASE_C
|
|
||||||
|
|
||||||
# Validate whether both are indentical or not
|
|
||||||
if [ ${PASSPHRASE} = ${PASSPHRASE_C} ] ; then
|
|
||||||
export PASSPHRASE
|
|
||||||
else
|
|
||||||
cat <<HEREDOC 1>&2
|
|
||||||
***** ERROR : Passphrase doesn't match *****
|
|
||||||
Installation terminates.
|
|
||||||
HEREDOC
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ----- Configuration Parameter -----
|
# ----- Configuration Parameter -----
|
||||||
# Load the configuration parameter
|
# Load the configuration parameter
|
||||||
source config.sh
|
source config.sh
|
||||||
|
|
||||||
# ----- Format the disk and encrypt the LUKS partition -----
|
# For surre ask the config.sh is edited
|
||||||
if [ ${ERASEALL} -eq 1 ] ; then
|
echo "Did you edit config.sys? Are you ready to install? [Y/N]"
|
||||||
|
read YESNO
|
||||||
|
if [ YESNO != "Y" -a YESNO != "y" ] ; then
|
||||||
|
cat <<HEREDOC 1>&2
|
||||||
|
|
||||||
|
Installation terminated.
|
||||||
|
HEREDOC
|
||||||
|
return
|
||||||
|
fi # if YES
|
||||||
|
|
||||||
|
|
||||||
# For sure ask ready to erase.
|
# For sure ask ready to erase.
|
||||||
|
if [ ${ERASEALL} -eq 1 ] ; then
|
||||||
echo "Are you sure you want to erase entire ${DEV}? [Y/N]"
|
echo "Are you sure you want to erase entire ${DEV}? [Y/N]"
|
||||||
read YESNO
|
read YESNO
|
||||||
if [ YESNO != "Y" -a YESNO != "y" ] ; then
|
if [ YESNO != "Y" -a YESNO != "y" ] ; then
|
||||||
cat <<HEREDOC 1>&2
|
cat <<HEREDOC 1>&2
|
||||||
Check config.sh. The ERASEALL is ${ERASEALL}.
|
Check config.sh. The ERASEALL is ${ERASEALL}.
|
||||||
|
|
||||||
Installation terminates.
|
Installation terminated.
|
||||||
HEREDOC
|
HEREDOC
|
||||||
return
|
return
|
||||||
fi
|
fi # if YES
|
||||||
|
fi # if erase all
|
||||||
|
|
||||||
|
# ----- Set Passphrase -----
|
||||||
|
# Input passphrase
|
||||||
|
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 1>&2
|
||||||
|
***** ERROR : Passphrase doesn't match *****
|
||||||
|
Installation terminated.
|
||||||
|
HEREDOC
|
||||||
|
return
|
||||||
|
fi # passphrase validation
|
||||||
|
|
||||||
|
# ----- Erase entire disk, create partitions, format them and encrypt the LUKS partition -----
|
||||||
|
if [ ${ERASEALL} -eq 1 ] ; then
|
||||||
|
|
||||||
# Assign specified space and rest of disk to the EFI and LUKS partition, respectively.
|
# Assign specified space and rest of disk to the EFI and LUKS partition, respectively.
|
||||||
if [ ${ISEFI} -eq 1 ] ; then
|
if [ ${ISEFI} -eq 1 ] ; then
|
||||||
|
|
@ -69,29 +82,27 @@ HEREDOC
|
||||||
sfdisk ${DEV} <<HEREDOC
|
sfdisk ${DEV} <<HEREDOC
|
||||||
2M,,L
|
2M,,L
|
||||||
HEREDOC
|
HEREDOC
|
||||||
fi
|
fi # if EFI firmware
|
||||||
# if EFI firmware
|
|
||||||
|
|
||||||
# Encrypt the partition to install Linux
|
# Encrypt the partition to install Linux
|
||||||
printf %s "${PASSPHRASE}" | cryptsetup luksFormat --type=luks1 --key-file - --batch-mode "${DEV}${CRYPTPARTITION}"
|
printf %s "${PASSPHRASE}" | cryptsetup luksFormat --type=luks1 --key-file - --batch-mode "${DEV}${CRYPTPARTITION}"
|
||||||
|
|
||||||
fi
|
fi # if erase all
|
||||||
# if erase all
|
|
||||||
|
|
||||||
# ----- Open the LUKS partition -----
|
# ----- Open the LUKS partition -----
|
||||||
# Open the created crypt partition.
|
# Open the crypt partition.
|
||||||
printf %s "${PASSPHRASE}" | cryptsetup open -d - "${DEV}${CRYPTPARTITION}" ${CRYPTPARTNAME}
|
printf %s "${PASSPHRASE}" | cryptsetup open -d - "${DEV}${CRYPTPARTITION}" ${CRYPTPARTNAME}
|
||||||
|
|
||||||
# Check whether successful open. If mapped, it is successful.
|
# Check whether successful open. If mapped, it is successful.
|
||||||
if [ ! -e /dev/mapper/${CRYPTPARTNAME} ] ; then
|
if [ ! -e /dev/mapper/${CRYPTPARTNAME} ] ; then
|
||||||
cat <<HEREDOC 1>&2
|
cat <<HEREDOC 1>&2
|
||||||
***** ERROR : Cannot open LUKS volume ${CRYPTPARTNAME} on ${DEV}${CRYPTPARTITION}. *****
|
***** ERROR : Cannot open LUKS volume ${CRYPTPARTNAME} on ${DEV}${CRYPTPARTITION}. *****
|
||||||
Check the passphrase
|
Check passphrase and config.txt
|
||||||
|
|
||||||
Installation terminates.
|
Installation terminated.
|
||||||
HEREDOC
|
HEREDOC
|
||||||
return
|
return
|
||||||
fi
|
fi # if crypt volume is unable to open
|
||||||
|
|
||||||
# ----- Configure the LVM in LUKS volume -----
|
# ----- Configure the LVM in LUKS volume -----
|
||||||
# The swap volume and / volume is created here, based on the given parameters.
|
# The swap volume and / volume is created here, based on the given parameters.
|
||||||
|
|
@ -100,25 +111,26 @@ pvcreate /dev/mapper/${CRYPTPARTNAME}
|
||||||
vgcreate ${VGNAME} /dev/mapper/${CRYPTPARTNAME}
|
vgcreate ${VGNAME} /dev/mapper/${CRYPTPARTNAME}
|
||||||
|
|
||||||
# Create a SWAP Logical Volume on VG, if it doesn't exist
|
# Create a SWAP Logical Volume on VG, if it doesn't exist
|
||||||
if [ ! -d /dev/mapper/${VGNAME}-${LVSWAPNAME} ] ; then
|
if [ -d /dev/mapper/${VGNAME}-${LVSWAPNAME} ] ; then
|
||||||
lvcreate -L ${LVSWAPSIZE} -n ${LVSWAPNAME} ${VGNAME}
|
|
||||||
else
|
|
||||||
echo "Swap volume already exist. Skipped to create" 1>&2
|
echo "Swap volume already exist. Skipped to create" 1>&2
|
||||||
fi
|
else
|
||||||
|
lvcreate -L ${LVSWAPSIZE} -n ${LVSWAPNAME} ${VGNAME}
|
||||||
|
fi # if /dev/mapper/swap volume already exit.
|
||||||
|
|
||||||
# Create a ROOT Logical Volume on VG.
|
# Create a ROOT Logical Volume on VG.
|
||||||
if [ ! -d /dev/mapper/${VGNAME}-${LVROOTNAME} ] ; then
|
if [ -d /dev/mapper/${VGNAME}-${LVROOTNAME} ] ; then
|
||||||
lvcreate -l ${LVROOTSIZE} -n ${LVROOTNAME} ${VGNAME}
|
|
||||||
else
|
|
||||||
cat <<HEREDOC 1>&2
|
cat <<HEREDOC 1>&2
|
||||||
***** ERROR : Logical volume ${VGNAME}-${LVROOTNAME} already exists. *****
|
***** ERROR : Logical volume ${VGNAME}-${LVROOTNAME} already exists. *****
|
||||||
Check LVROOTNAME environment variable.
|
Check LVROOTNAME environment variable in config.txt.
|
||||||
|
|
||||||
Installation terminates.
|
Installation terminated.
|
||||||
HEREDOC
|
HEREDOC
|
||||||
return
|
return
|
||||||
fi
|
else
|
||||||
|
lvcreate -l ${LVROOTSIZE} -n ${LVROOTNAME} ${VGNAME}
|
||||||
|
fi # if the root volun already exist
|
||||||
|
|
||||||
|
# Finishing message
|
||||||
cat <<HEREDOC
|
cat <<HEREDOC
|
||||||
|
|
||||||
1-pre-install.sh : Done. Next, run the Ubiquity installer.
|
1-pre-install.sh : Done. Next, run the Ubiquity installer.
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ if [ $sourced -eq 0 ] ; then
|
||||||
Execute as following :
|
Execute as following :
|
||||||
source 2-para-install.sh
|
source 2-para-install.sh
|
||||||
|
|
||||||
Installation terminates.
|
Installation terminated.
|
||||||
HEREDOC
|
HEREDOC
|
||||||
exit
|
exit # use "exit" instead of "return", if not "sourced" execusion
|
||||||
fi
|
fi # "sourced" validation
|
||||||
|
|
||||||
|
|
||||||
# Check whether grub configuration file is ready to write
|
# Check whether grub configuration file is ready to write
|
||||||
|
|
@ -20,14 +20,15 @@ if [ ! -e /target/etc/default/grub ] ; then
|
||||||
***** ERROR : The /target/etc/default/grub is not ready. *****
|
***** ERROR : The /target/etc/default/grub is not ready. *****
|
||||||
Perhaps, to early to execute this script.
|
Perhaps, to early to execute this script.
|
||||||
|
|
||||||
Installation terminates.
|
Installation terminated.
|
||||||
HEREDOC
|
HEREDOC
|
||||||
return
|
return
|
||||||
fi
|
fi # if grub file exists
|
||||||
|
|
||||||
# Make target GRUB aware to the crypt partition
|
# Make target GRUB aware to the crypt partition
|
||||||
echo "GRUB_ENABLE_CRYPTODISK=y" >> /target/etc/default/grub
|
echo "GRUB_ENABLE_CRYPTODISK=y" >> /target/etc/default/grub
|
||||||
|
|
||||||
|
# Finishing message
|
||||||
cat <<HEREDOC
|
cat <<HEREDOC
|
||||||
|
|
||||||
2-para-install.sh : Done.
|
2-para-install.sh : Done.
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ if [ $sourced -eq 0 ] ; then
|
||||||
Execute as following :
|
Execute as following :
|
||||||
source 3-post-install.sh
|
source 3-post-install.sh
|
||||||
|
|
||||||
Installation terminates.
|
Installation terminated.
|
||||||
HEREDOC
|
HEREDOC
|
||||||
exit
|
exit # use "exit" instead of "return", if not "sourced" execusion
|
||||||
fi
|
fi # "sourced" validation
|
||||||
|
|
||||||
## Mount the target file system
|
## Mount the target file system
|
||||||
# /target is created by the Ubiquity installer
|
# /target is created by the Ubiquity installer
|
||||||
|
|
@ -49,6 +49,7 @@ update-initramfs -uk all
|
||||||
exit
|
exit
|
||||||
HEREDOC
|
HEREDOC
|
||||||
|
|
||||||
|
# Finishing message
|
||||||
cat <<HEREDOC
|
cat <<HEREDOC
|
||||||
|
|
||||||
3-pro-install.sh : Done. Ready to reboot.
|
3-pro-install.sh : Done. Ready to reboot.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue