mirror of
https://github.com/suikan4github/kaiten-yaki.git
synced 2025-12-20 02:21:17 -03:00
Refactored.
All function body is indented. kaiten-yaki-* has main function. "sourced" style is not enforced.
This commit is contained in:
parent
a5ecca9860
commit
f1a43e9c54
6 changed files with 475 additions and 460 deletions
|
|
@ -7,7 +7,7 @@ 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
|
||||
cat <<- HEREDOC 1>&2
|
||||
***** ERROR : VGNAME is "${VGNAME}" *****
|
||||
THe "-" is not allowed in the volume name.
|
||||
Check passphrase and config.txt
|
||||
|
|
@ -19,7 +19,7 @@ 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 1>&2
|
||||
cat <<- HEREDOC 1>&2
|
||||
***** ERROR : LVROOTNAME is "${LVROOTNAME}" *****
|
||||
THe "-" is not allowed in the volume name.
|
||||
Check passphrase and config.txt
|
||||
|
|
@ -31,7 +31,7 @@ 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 1>&2
|
||||
cat <<- HEREDOC 1>&2
|
||||
***** ERROR : LVSWAPNAME is "${LVSWAPNAME}" *****
|
||||
THe "-" is not allowed in the volume name.
|
||||
Check passphrase and config.txt
|
||||
|
|
@ -42,7 +42,7 @@ HEREDOC
|
|||
fi # "-" is found in the volume name.
|
||||
|
||||
# For surre ask the config.sh is edited
|
||||
cat <<HEREDOC
|
||||
cat <<- HEREDOC
|
||||
|
||||
The destination logical volume label is "${LVROOTNAME}"
|
||||
"${LVROOTNAME}" uses ${LVROOTSIZE} of the LVM volume group.
|
||||
|
|
@ -50,7 +50,7 @@ Are you ready to install? [Y/N]
|
|||
HEREDOC
|
||||
read YESNO
|
||||
if [ ${YESNO} != "Y" -a ${YESNO} != "y" ] ; then
|
||||
cat <<HEREDOC 1>&2
|
||||
cat <<- HEREDOC 1>&2
|
||||
|
||||
Installation terminated.
|
||||
HEREDOC
|
||||
|
|
@ -62,7 +62,7 @@ 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
|
||||
cat <<HEREDOC 1>&2
|
||||
cat <<-HEREDOC 1>&2
|
||||
Check config.sh. The variable ERASEALL is ${ERASEALL}.
|
||||
|
||||
Installation terminated.
|
||||
|
|
@ -82,7 +82,7 @@ read -sr PASSPHRASE_C
|
|||
|
||||
# Validate whether both are indentical or not
|
||||
if [ ${PASSPHRASE} != ${PASSPHRASE_C} ] ; then
|
||||
cat <<HEREDOC 1>&2
|
||||
cat <<-HEREDOC 1>&2
|
||||
***** ERROR : Passphrase doesn't match *****
|
||||
|
||||
Installation terminated.
|
||||
|
|
|
|||
|
|
@ -13,13 +13,12 @@ do
|
|||
|
||||
# Check if installer still exist
|
||||
if ! ps $installer_pid > /dev/null ; then # If not exists
|
||||
cat <<HEREDOC 1>&2
|
||||
cat <<-HEREDOC 1>&2
|
||||
The installer terminated unexpectedly.
|
||||
|
||||
Installation process terminated.
|
||||
HEREDOC
|
||||
return 1
|
||||
|
||||
fi
|
||||
done # while
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
function parainstall_msg() {
|
||||
|
||||
cat <<HEREDOC
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ if [ ${ERASEALL} -eq 1 ] ; then
|
|||
dd if=/dev/zero of=${DEV} bs=512 count=1
|
||||
# Create MBR and allocate max storage for Linux partition
|
||||
echo "...Create a Linux partition on ${DEV} with MBR."
|
||||
sfdisk ${DEV} <<HEREDOC
|
||||
sfdisk ${DEV} <<- HEREDOC
|
||||
2M,,L
|
||||
HEREDOC
|
||||
fi # if EFI firmware
|
||||
|
|
@ -48,7 +48,7 @@ printf %s "${PASSPHRASE}" | cryptsetup open -d - "${DEV}${CRYPTPARTITION}" ${CRY
|
|||
|
||||
# Check whether successful open. If mapped, it is successful.
|
||||
if [ ! -e /dev/mapper/${CRYPTPARTNAME} ] ; then
|
||||
cat <<HEREDOC 1>&2
|
||||
cat <<- HEREDOC 1>&2
|
||||
***** ERROR : Cannot open LUKS volume "${CRYPTPARTNAME}" on ${DEV}${CRYPTPARTITION}. *****
|
||||
Check passphrase and config.txt
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ fi # if /dev/mapper/swap volume already exit.
|
|||
|
||||
# Create a ROOT Logical Volume on VG.
|
||||
if [ -e /dev/mapper/${VGNAME}-${LVROOTNAME} ] ; then
|
||||
cat <<HEREDOC 1>&2
|
||||
cat <<- HEREDOC 1>&2
|
||||
***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" already exists. *****
|
||||
Check LVROOTNAME environment variable in config.txt.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash -u
|
||||
|
||||
function main() {
|
||||
# Load configuration parameter
|
||||
source config.sh
|
||||
|
||||
|
|
@ -12,7 +13,7 @@ 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
|
||||
cat <<HEREDOC 1>&2
|
||||
cat <<- HEREDOC 1>&2
|
||||
***** ERROR : Must execute as "sourced" *****
|
||||
Execute as following :
|
||||
source ubuntu-kaiten-yaki.sh
|
||||
|
|
@ -31,18 +32,18 @@ export PARAINSTMSG=1
|
|||
if ! uname -a | grep ubuntu -i > /dev/null ; then # "Ubuntu" is not found in the OS name.
|
||||
echo "*******************************************************************************"
|
||||
uname -a
|
||||
cat <<HEREDOC
|
||||
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 YESNO
|
||||
if [ ${YESNO} != "Y" -a ${YESNO} != "y" ] ; then
|
||||
cat <<HEREDOC 1>&2
|
||||
cat <<- HEREDOC 1>&2
|
||||
|
||||
Installation terminated.
|
||||
HEREDOC
|
||||
return
|
||||
return 1
|
||||
fi # if YES
|
||||
|
||||
fi # "Ubuntu" is not found in the OS name.
|
||||
|
|
@ -74,7 +75,7 @@ fi
|
|||
parainstall_msg
|
||||
|
||||
# Ubuntu dependent message
|
||||
cat <<HEREDOC
|
||||
cat <<- HEREDOC
|
||||
|
||||
************************ CAUTION! CAUTION! CAUTION! ****************************
|
||||
|
||||
|
|
@ -115,7 +116,7 @@ for n in proc sys dev etc/resolv.conf; do mount --rbind "/$n" "${TARGETMOUNTPOIN
|
|||
|
||||
# Change root and create the keyfile and ramfs image for Linux kernel.
|
||||
echo "...Chroot to ${TARGETMOUNTPOINT}."
|
||||
cat <<HEREDOC | chroot ${TARGETMOUNTPOINT} /bin/bash
|
||||
cat <<- HEREDOC | chroot ${TARGETMOUNTPOINT} /bin/bash
|
||||
# Mount the rest of partitions by target /etc/fstab
|
||||
mount -a
|
||||
|
||||
|
|
@ -155,8 +156,15 @@ echo "...Unmount all."
|
|||
umount -R ${TARGETMOUNTPOINT}
|
||||
|
||||
# Finishing message
|
||||
cat <<HEREDOC
|
||||
cat <<- HEREDOC
|
||||
****************** Post-install process finished ******************
|
||||
|
||||
...Ready to reboot.
|
||||
HEREDOC
|
||||
|
||||
# Normal end
|
||||
return 0
|
||||
}
|
||||
|
||||
# Execute
|
||||
main
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash -u
|
||||
|
||||
function main() {
|
||||
# Load configuration parameter
|
||||
source config.sh
|
||||
|
||||
|
|
@ -12,7 +13,7 @@ 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
|
||||
cat <<HEREDOC 1>&2
|
||||
cat <<- HEREDOC 1>&2
|
||||
***** ERROR : Must execute as "sourced" *****
|
||||
Execute as following :
|
||||
source void-kaiten-yaki.sh
|
||||
|
|
@ -31,14 +32,14 @@ export PARAINSTMSG=0
|
|||
if ! uname -a | grep void -i > /dev/null ; then # "Void" is not found in the OS name.
|
||||
echo "*********************************************************************************"
|
||||
uname -a
|
||||
cat <<HEREDOC
|
||||
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]
|
||||
HEREDOC
|
||||
read YESNO
|
||||
if [ ${YESNO} != "Y" -a ${YESNO} != "y" ] ; then
|
||||
cat <<HEREDOC 1>&2
|
||||
cat <<- HEREDOC 1>&2
|
||||
|
||||
Installation terminated.
|
||||
HEREDOC
|
||||
|
|
@ -83,7 +84,7 @@ 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
|
||||
parainstall_msg
|
||||
# Ubuntu dependent message
|
||||
cat <<HEREDOC
|
||||
cat <<- HEREDOC
|
||||
|
||||
************************ CAUTION! CAUTION! CAUTION! ****************************
|
||||
|
||||
|
|
@ -125,7 +126,7 @@ for n in proc sys dev etc/resolv.conf; do mount --rbind "/$n" "${TARGETMOUNTPOIN
|
|||
|
||||
# Change root and create the keyfile and ramfs image for Linux kernel.
|
||||
echo "...Chroot to ${TARGETMOUNTPOINT}."
|
||||
cat <<HEREDOC | chroot ${TARGETMOUNTPOINT} /bin/bash
|
||||
cat <<- HEREDOC | chroot ${TARGETMOUNTPOINT} /bin/bash
|
||||
# Mount the rest of partitions by target /etc/fstab
|
||||
mount -a
|
||||
|
||||
|
|
@ -168,8 +169,15 @@ echo "...Unmount all."
|
|||
umount -R ${TARGETMOUNTPOINT}
|
||||
|
||||
# Finishing message
|
||||
cat <<HEREDOC
|
||||
cat <<- HEREDOC
|
||||
****************** Post-install process finished ******************
|
||||
|
||||
...Ready to reboot.
|
||||
HEREDOC
|
||||
|
||||
# Normal end
|
||||
return 0
|
||||
}
|
||||
|
||||
# Execute
|
||||
main
|
||||
Loading…
Add table
Add a link
Reference in a new issue