Merge branch 'feature/7' into develop

This commit is contained in:
Suikan 2021-07-04 22:09:50 +09:00
commit 60a519f9ba
3 changed files with 30 additions and 2 deletions

View file

@ -7,6 +7,7 @@ Record of the modification in project development.
### Changed
- [Issue 5 : OVERWRITEINSTALL confirmation is missing](https://github.com/suikan4github/kaiten-yaki/issues/5)
- [Issue 6 : Remove loglevel dependency from the void-kaiten-yaki.sh ](https://github.com/suikan4github/kaiten-yaki/6)
- [Issue 7 : Add the return status validation ](https://github.com/suikan4github/kaiten-yaki/7)
### Deprecated
### Removed

View file

@ -138,27 +138,33 @@ function pre_install() {
# Zap existing partition table and create new GPT
echo "...Initializing \"${DEV}\" with GPT."
sgdisk --zap-all "${DEV}"
if is_error ; then return 1 ; fi; # If error, terminate
# 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}"
if is_error ; then return 1 ; fi; # If error, terminate
echo "...Formatting the EFI parttion."
mkfs.vfat -F 32 -n EFI-SP "${DEV}${EFIPARTITION}"
if is_error ; then return 1 ; fi; # If error, terminate
# 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}"
if is_error ; then return 1 ; fi; # If error, terminate
# 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
if is_error ; then return 1 ; fi; # If error, terminate
# Create MBR and allocate max storage for Linux partition
echo "...Creating a Linux partition on ${DEV} with MBR."
sfdisk "${DEV}" <<- HEREDOC
2M,,L
HEREDOC
if is_error ; then return 1 ; fi; # If error, terminate
fi # if EFI firmware
# Encrypt the partition to install Linux
@ -194,8 +200,10 @@ function pre_install() {
else
echo "...Initializing a physical volume on \"${CRYPTPARTNAME}\""
pvcreate /dev/mapper/"${CRYPTPARTNAME}"
if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi;
echo "...And then creating Volume group \"${VGNAME}\"."
vgcreate "${VGNAME}" /dev/mapper/"${CRYPTPARTNAME}"
if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi;
fi # if /dev/volume-groupt exist
# Create a SWAP Logical Volume on VG, if it doesn't exist
@ -204,6 +212,7 @@ function pre_install() {
else
echo "...Creating logical volume \"${LVSWAPNAME}\" on \"${VGNAME}\"."
lvcreate -L "${LVSWAPSIZE}" -n "${LVSWAPNAME}" "${VGNAME}"
if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi;
fi # if /dev/mapper/swap volume already exit.
# Create a ROOT Logical Volume on VG.
@ -231,6 +240,7 @@ function pre_install() {
else # not exist and not overwrite install
echo "...Creating logical volume \"${LVROOTNAME}\" on \"${VGNAME}\"."
lvcreate -l "${LVROOTSIZE}" -n "${LVROOTNAME}" "${VGNAME}"
if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi;
fi
fi
@ -332,3 +342,20 @@ function distribution_check(){
# no error
return 0
}
# *******************************************************************************
# Error report and return revsers status.
# *******************************************************************************
function is_error() {
if [ $? -eq 0 ] ; then # Is previous job OK?
return 1 # If OK, return error ( because it was not error )
else
cat <<- HEREDOC
**** ERROR ! ****
Installation process terminated.
HEREDOC
return 0 # If error, return OK ( because it was error )
fi;
}

View file

@ -56,8 +56,8 @@ function main() {
# Common part of the pre-install stage
if ! pre_install ; then
# If error, restore the modification.
echo "...restoring modified /etc/default/grub."
sed -i -e "s#loglevel=4 ${GRUB_ADDITIONAL_PARAMETERS}#loglevel=4#" /etc/default/grub
echo "...restoring /etc/default/grub, if needed"
sed -i -e "s#${GRUB_ADDITIONAL_PARAMETERS}##" /etc/default/grub
return 1 # with error status
fi