mirror of
https://github.com/suikan4github/kaiten-yaki.git
synced 2025-12-20 10:31: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
|
# Sanity check for volume group name
|
||||||
if echo ${VGNAME} | grep "-" -i > /dev/null ; then # "-" is found in the 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}" *****
|
***** ERROR : VGNAME is "${VGNAME}" *****
|
||||||
THe "-" is not allowed in the volume name.
|
THe "-" is not allowed in the volume name.
|
||||||
Check passphrase and config.txt
|
Check passphrase and config.txt
|
||||||
|
|
@ -19,7 +19,7 @@ fi # "-" is found in the volume group name.
|
||||||
|
|
||||||
# Sanity check for root volume name
|
# Sanity check for root volume name
|
||||||
if echo ${LVROOTNAME} | grep "-" -i > /dev/null ; then # "-" is found in the 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}" *****
|
***** ERROR : LVROOTNAME is "${LVROOTNAME}" *****
|
||||||
THe "-" is not allowed in the volume name.
|
THe "-" is not allowed in the volume name.
|
||||||
Check passphrase and config.txt
|
Check passphrase and config.txt
|
||||||
|
|
@ -31,7 +31,7 @@ fi # "-" is found in the volume name.
|
||||||
|
|
||||||
# Sanity check for swap volume name
|
# Sanity check for swap volume name
|
||||||
if echo ${LVSWAPNAME} | grep "-" -i > /dev/null ; then # "-" is found in the 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}" *****
|
***** ERROR : LVSWAPNAME is "${LVSWAPNAME}" *****
|
||||||
THe "-" is not allowed in the volume name.
|
THe "-" is not allowed in the volume name.
|
||||||
Check passphrase and config.txt
|
Check passphrase and config.txt
|
||||||
|
|
@ -42,7 +42,7 @@ HEREDOC
|
||||||
fi # "-" is found in the volume name.
|
fi # "-" is found in the volume name.
|
||||||
|
|
||||||
# For surre ask the config.sh is edited
|
# For surre ask the config.sh is edited
|
||||||
cat <<HEREDOC
|
cat <<- HEREDOC
|
||||||
|
|
||||||
The destination logical volume label is "${LVROOTNAME}"
|
The destination logical volume label is "${LVROOTNAME}"
|
||||||
"${LVROOTNAME}" uses ${LVROOTSIZE} of the LVM volume group.
|
"${LVROOTNAME}" uses ${LVROOTSIZE} of the LVM volume group.
|
||||||
|
|
@ -50,7 +50,7 @@ Are you ready to install? [Y/N]
|
||||||
HEREDOC
|
HEREDOC
|
||||||
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
|
||||||
|
|
||||||
Installation terminated.
|
Installation terminated.
|
||||||
HEREDOC
|
HEREDOC
|
||||||
|
|
@ -62,7 +62,7 @@ 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 variable ERASEALL is ${ERASEALL}.
|
Check config.sh. The variable ERASEALL is ${ERASEALL}.
|
||||||
|
|
||||||
Installation terminated.
|
Installation terminated.
|
||||||
|
|
@ -82,7 +82,7 @@ read -sr PASSPHRASE_C
|
||||||
|
|
||||||
# Validate whether both are indentical or not
|
# Validate whether both are indentical or not
|
||||||
if [ ${PASSPHRASE} != ${PASSPHRASE_C} ] ; then
|
if [ ${PASSPHRASE} != ${PASSPHRASE_C} ] ; then
|
||||||
cat <<HEREDOC 1>&2
|
cat <<-HEREDOC 1>&2
|
||||||
***** ERROR : Passphrase doesn't match *****
|
***** ERROR : Passphrase doesn't match *****
|
||||||
|
|
||||||
Installation terminated.
|
Installation terminated.
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,12 @@ do
|
||||||
|
|
||||||
# Check if installer still exist
|
# Check if installer still exist
|
||||||
if ! ps $installer_pid > /dev/null ; then # If not exists
|
if ! ps $installer_pid > /dev/null ; then # If not exists
|
||||||
cat <<HEREDOC 1>&2
|
cat <<-HEREDOC 1>&2
|
||||||
The installer terminated unexpectedly.
|
The installer terminated unexpectedly.
|
||||||
|
|
||||||
Installation process terminated.
|
Installation process terminated.
|
||||||
HEREDOC
|
HEREDOC
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
fi
|
fi
|
||||||
done # while
|
done # while
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
function parainstall_msg() {
|
function parainstall_msg() {
|
||||||
|
|
||||||
cat <<HEREDOC
|
cat <<- HEREDOC
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
The pre-install process is done. We are ready to install the Linux to the
|
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.
|
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
|
dd if=/dev/zero of=${DEV} bs=512 count=1
|
||||||
# Create MBR and allocate max storage for Linux partition
|
# Create MBR and allocate max storage for Linux partition
|
||||||
echo "...Create a Linux partition on ${DEV} with MBR."
|
echo "...Create a Linux partition on ${DEV} with MBR."
|
||||||
sfdisk ${DEV} <<HEREDOC
|
sfdisk ${DEV} <<- HEREDOC
|
||||||
2M,,L
|
2M,,L
|
||||||
HEREDOC
|
HEREDOC
|
||||||
fi # if EFI firmware
|
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.
|
# 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 passphrase and config.txt
|
Check passphrase and config.txt
|
||||||
|
|
||||||
|
|
@ -78,7 +78,7 @@ fi # if /dev/mapper/swap volume already exit.
|
||||||
|
|
||||||
# Create a ROOT Logical Volume on VG.
|
# Create a ROOT Logical Volume on VG.
|
||||||
if [ -e /dev/mapper/${VGNAME}-${LVROOTNAME} ] ; then
|
if [ -e /dev/mapper/${VGNAME}-${LVROOTNAME} ] ; then
|
||||||
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 in config.txt.
|
Check LVROOTNAME environment variable in config.txt.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/bash -u
|
#!/bin/bash -u
|
||||||
|
|
||||||
|
function main() {
|
||||||
# Load configuration parameter
|
# Load configuration parameter
|
||||||
source config.sh
|
source config.sh
|
||||||
|
|
||||||
|
|
@ -12,7 +13,7 @@ source common/parainstall_msg.sh
|
||||||
# Varidate whether script is executed as sourced or not
|
# Varidate whether script is executed as sourced or not
|
||||||
(return 0 2>/dev/null) && sourced=1 || sourced=0
|
(return 0 2>/dev/null) && sourced=1 || sourced=0
|
||||||
if [ $sourced -eq 0 ] ; then
|
if [ $sourced -eq 0 ] ; then
|
||||||
cat <<HEREDOC 1>&2
|
cat <<- HEREDOC 1>&2
|
||||||
***** ERROR : Must execute as "sourced" *****
|
***** ERROR : Must execute as "sourced" *****
|
||||||
Execute as following :
|
Execute as following :
|
||||||
source ubuntu-kaiten-yaki.sh
|
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.
|
if ! uname -a | grep ubuntu -i > /dev/null ; then # "Ubuntu" is not found in the OS name.
|
||||||
echo "*******************************************************************************"
|
echo "*******************************************************************************"
|
||||||
uname -a
|
uname -a
|
||||||
cat <<HEREDOC
|
cat <<- HEREDOC
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
This system seems to be not Ubuntu, while this script is dediated to the Ubuntu.
|
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]
|
Are you sure you want to run this script? [Y/N]
|
||||||
HEREDOC
|
HEREDOC
|
||||||
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
|
||||||
|
|
||||||
Installation terminated.
|
Installation terminated.
|
||||||
HEREDOC
|
HEREDOC
|
||||||
return
|
return 1
|
||||||
fi # if YES
|
fi # if YES
|
||||||
|
|
||||||
fi # "Ubuntu" is not found in the OS name.
|
fi # "Ubuntu" is not found in the OS name.
|
||||||
|
|
@ -74,7 +75,7 @@ fi
|
||||||
parainstall_msg
|
parainstall_msg
|
||||||
|
|
||||||
# Ubuntu dependent message
|
# Ubuntu dependent message
|
||||||
cat <<HEREDOC
|
cat <<- HEREDOC
|
||||||
|
|
||||||
************************ CAUTION! CAUTION! CAUTION! ****************************
|
************************ 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.
|
# Change root and create the keyfile and ramfs image for Linux kernel.
|
||||||
echo "...Chroot to ${TARGETMOUNTPOINT}."
|
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 the rest of partitions by target /etc/fstab
|
||||||
mount -a
|
mount -a
|
||||||
|
|
||||||
|
|
@ -155,8 +156,15 @@ echo "...Unmount all."
|
||||||
umount -R ${TARGETMOUNTPOINT}
|
umount -R ${TARGETMOUNTPOINT}
|
||||||
|
|
||||||
# Finishing message
|
# Finishing message
|
||||||
cat <<HEREDOC
|
cat <<- HEREDOC
|
||||||
****************** Post-install process finished ******************
|
****************** Post-install process finished ******************
|
||||||
|
|
||||||
...Ready to reboot.
|
...Ready to reboot.
|
||||||
HEREDOC
|
HEREDOC
|
||||||
|
|
||||||
|
# Normal end
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute
|
||||||
|
main
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/bash -u
|
#!/bin/bash -u
|
||||||
|
|
||||||
|
function main() {
|
||||||
# Load configuration parameter
|
# Load configuration parameter
|
||||||
source config.sh
|
source config.sh
|
||||||
|
|
||||||
|
|
@ -12,7 +13,7 @@ source common/parainstall_msg.sh
|
||||||
# Varidate whether script is executed as sourced or not
|
# Varidate whether script is executed as sourced or not
|
||||||
(return 0 2>/dev/null) && sourced=1 || sourced=0
|
(return 0 2>/dev/null) && sourced=1 || sourced=0
|
||||||
if [ $sourced -eq 0 ] ; then
|
if [ $sourced -eq 0 ] ; then
|
||||||
cat <<HEREDOC 1>&2
|
cat <<- HEREDOC 1>&2
|
||||||
***** ERROR : Must execute as "sourced" *****
|
***** ERROR : Must execute as "sourced" *****
|
||||||
Execute as following :
|
Execute as following :
|
||||||
source void-kaiten-yaki.sh
|
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.
|
if ! uname -a | grep void -i > /dev/null ; then # "Void" is not found in the OS name.
|
||||||
echo "*********************************************************************************"
|
echo "*********************************************************************************"
|
||||||
uname -a
|
uname -a
|
||||||
cat <<HEREDOC
|
cat <<- HEREDOC
|
||||||
*********************************************************************************
|
*********************************************************************************
|
||||||
This system seems to be not Void Linux, while this script is dediated to the Void Linux.
|
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]
|
Are you sure you want to run this script for installation? [Y/N]
|
||||||
HEREDOC
|
HEREDOC
|
||||||
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
|
||||||
|
|
||||||
Installation terminated.
|
Installation terminated.
|
||||||
HEREDOC
|
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
|
# Show common message to let the operator focus on the critical part
|
||||||
parainstall_msg
|
parainstall_msg
|
||||||
# Ubuntu dependent message
|
# Ubuntu dependent message
|
||||||
cat <<HEREDOC
|
cat <<- HEREDOC
|
||||||
|
|
||||||
************************ CAUTION! CAUTION! CAUTION! ****************************
|
************************ 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.
|
# Change root and create the keyfile and ramfs image for Linux kernel.
|
||||||
echo "...Chroot to ${TARGETMOUNTPOINT}."
|
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 the rest of partitions by target /etc/fstab
|
||||||
mount -a
|
mount -a
|
||||||
|
|
||||||
|
|
@ -168,8 +169,15 @@ echo "...Unmount all."
|
||||||
umount -R ${TARGETMOUNTPOINT}
|
umount -R ${TARGETMOUNTPOINT}
|
||||||
|
|
||||||
# Finishing message
|
# Finishing message
|
||||||
cat <<HEREDOC
|
cat <<- HEREDOC
|
||||||
****************** Post-install process finished ******************
|
****************** Post-install process finished ******************
|
||||||
|
|
||||||
...Ready to reboot.
|
...Ready to reboot.
|
||||||
HEREDOC
|
HEREDOC
|
||||||
|
|
||||||
|
# Normal end
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute
|
||||||
|
main
|
||||||
Loading…
Add table
Add a link
Reference in a new issue