mirror of
https://github.com/suikan4github/kaiten-yaki.git
synced 2025-12-20 02:21:17 -03:00
Refactored structure
Post install part is gotten into a function. Ubuntu dependent para-install is moved to main ubuntu-kaiten-yaki.sh
This commit is contained in:
parent
9bde5fb9ab
commit
0e0af79234
3 changed files with 86 additions and 62 deletions
|
|
@ -1,50 +0,0 @@
|
||||||
#!/bin/bash -u
|
|
||||||
# *******************************************************************************
|
|
||||||
# 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 ]
|
|
||||||
do
|
|
||||||
sleep 1 # 1sec.
|
|
||||||
|
|
||||||
# Check if installer still exist
|
|
||||||
if ! ps $INSTALLER_PID > /dev/null ; then # If not exists
|
|
||||||
cat <<-HEREDOC 1>&2
|
|
||||||
***** ERROR : The GUI/TUI installer terminated unexpectedly. *****
|
|
||||||
...Deleting the new logical volume "${VGNAME}-${LVROOTNAME}".
|
|
||||||
HEREDOC
|
|
||||||
lvremove -f /dev/mapper/${VGNAME}-${LVROOTNAME}
|
|
||||||
echo "...Deactivating all logical volumes in volume group \"${VGNAME}\"."
|
|
||||||
vgchange -a n ${VGNAME}
|
|
||||||
echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"."
|
|
||||||
cryptsetup close ${CRYPTPARTNAME}
|
|
||||||
cat <<-HEREDOC 1>&2
|
|
||||||
|
|
||||||
...The new logical volume has been deleted. You can retry Kaiten-yaki again.
|
|
||||||
...Installation process terminated.
|
|
||||||
HEREDOC
|
|
||||||
return 1 # with error status
|
|
||||||
fi
|
|
||||||
done # while
|
|
||||||
|
|
||||||
# Perhaps, too neuvous. Wait 1 more sectond to avoid the rece condition.
|
|
||||||
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.
|
|
||||||
echo "...Adding GRUB_ENABLE_CRYPTODISK entry to ${TARGETMOUNTPOINT}/etc/default/grub "
|
|
||||||
echo "GRUB_ENABLE_CRYPTODISK=y" >> ${TARGETMOUNTPOINT}/etc/default/grub
|
|
||||||
|
|
||||||
# And then, wait for the end of installer process
|
|
||||||
echo "...Waiting for the end of GUI/TUI installer."
|
|
||||||
echo "...Again, DO NOT reboot/restart here. Just exit the GUI/TUI installer."
|
|
||||||
wait $INSTALLER_PID
|
|
||||||
|
|
||||||
# succesfull return
|
|
||||||
return 0
|
|
||||||
|
|
||||||
} # para install
|
|
||||||
|
|
@ -7,7 +7,6 @@ function main() {
|
||||||
# Load functions
|
# Load functions
|
||||||
source lib/confirmation.sh
|
source lib/confirmation.sh
|
||||||
source lib/preinstall.sh
|
source lib/preinstall.sh
|
||||||
source lib/parainstall.sh
|
|
||||||
source lib/parainstall_msg.sh
|
source lib/parainstall_msg.sh
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -84,7 +83,7 @@ function main() {
|
||||||
# Common part of the para-install.
|
# Common part of the para-install.
|
||||||
# Record the install PID, modify the /etc/default/grub of the target,
|
# Record the install PID, modify the /etc/default/grub of the target,
|
||||||
# and then, wait for the end of sintaller.
|
# and then, wait for the end of sintaller.
|
||||||
if ! parainstall ; then
|
if ! grub_check_and_modify_ubuntu ; then
|
||||||
return 1 # with error status
|
return 1 # with error status
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -92,6 +91,18 @@ function main() {
|
||||||
# Post-install stage
|
# Post-install stage
|
||||||
# *******************************************************************************
|
# *******************************************************************************
|
||||||
|
|
||||||
|
# Finalizing. Embedd encryption key into the ramfs image.
|
||||||
|
post_install_void()
|
||||||
|
|
||||||
|
# Normal end
|
||||||
|
return 0
|
||||||
|
|
||||||
|
} # End of main()
|
||||||
|
|
||||||
|
|
||||||
|
# *******************************************************************************
|
||||||
|
# Ubuntu dependent post-installation process
|
||||||
|
function post_install_ubuntu() {
|
||||||
## Mount the target file system
|
## Mount the target file system
|
||||||
# ${TARGETMOUNTPOINT} is created by the GUI/TUI installer
|
# ${TARGETMOUNTPOINT} is created by the GUI/TUI installer
|
||||||
echo "...Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${TARGETMOUNTPOINT}."
|
echo "...Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${TARGETMOUNTPOINT}."
|
||||||
|
|
@ -149,9 +160,59 @@ function main() {
|
||||||
...Ready to reboot.
|
...Ready to reboot.
|
||||||
HEREDOC
|
HEREDOC
|
||||||
|
|
||||||
# Normal end
|
retrun 0
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
|
} # End of post_install_ubuntu()
|
||||||
|
|
||||||
|
|
||||||
|
# *******************************************************************************
|
||||||
|
# This function will be executed in the foreguround context, to watch the GUI installer.
|
||||||
|
function grub_check_and_modify_ubuntu() {
|
||||||
|
|
||||||
|
# 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 ]
|
||||||
|
do
|
||||||
|
sleep 1 # 1sec.
|
||||||
|
|
||||||
|
# Check if installer still exist
|
||||||
|
if ! ps $INSTALLER_PID > /dev/null ; then # If not exists
|
||||||
|
cat <<-HEREDOC 1>&2
|
||||||
|
***** ERROR : The GUI/TUI installer terminated unexpectedly. *****
|
||||||
|
...Deleting the new logical volume "${VGNAME}-${LVROOTNAME}".
|
||||||
|
HEREDOC
|
||||||
|
lvremove -f /dev/mapper/${VGNAME}-${LVROOTNAME}
|
||||||
|
echo "...Deactivating all logical volumes in volume group \"${VGNAME}\"."
|
||||||
|
vgchange -a n ${VGNAME}
|
||||||
|
echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"."
|
||||||
|
cryptsetup close ${CRYPTPARTNAME}
|
||||||
|
cat <<-HEREDOC 1>&2
|
||||||
|
|
||||||
|
...The new logical volume has been deleted. You can retry Kaiten-yaki again.
|
||||||
|
...Installation process terminated.
|
||||||
|
HEREDOC
|
||||||
|
return 1 # with error status
|
||||||
|
fi
|
||||||
|
done # while
|
||||||
|
|
||||||
|
# Perhaps, too neuvous. Wait 1 more sectond to avoid the rece condition.
|
||||||
|
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.
|
||||||
|
echo "...Adding GRUB_ENABLE_CRYPTODISK entry to ${TARGETMOUNTPOINT}/etc/default/grub "
|
||||||
|
echo "GRUB_ENABLE_CRYPTODISK=y" >> ${TARGETMOUNTPOINT}/etc/default/grub
|
||||||
|
|
||||||
|
# And then, wait for the end of installer process
|
||||||
|
echo "...Waiting for the end of GUI/TUI installer."
|
||||||
|
echo "...Again, DO NOT reboot/restart here. Just exit the GUI/TUI installer."
|
||||||
|
wait $INSTALLER_PID
|
||||||
|
|
||||||
|
# succesfull return
|
||||||
|
return 0
|
||||||
|
|
||||||
|
} # grub_check_and_modify_ubuntu()
|
||||||
|
|
||||||
|
# *******************************************************************************
|
||||||
# Execute
|
# Execute
|
||||||
main
|
main
|
||||||
|
|
@ -7,7 +7,6 @@ function main() {
|
||||||
# Load functions
|
# Load functions
|
||||||
source lib/confirmation.sh
|
source lib/confirmation.sh
|
||||||
source lib/preinstall.sh
|
source lib/preinstall.sh
|
||||||
# source lib/parainstall.sh # we have customized parainstall
|
|
||||||
source lib/parainstall_msg.sh
|
source lib/parainstall_msg.sh
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -85,7 +84,7 @@ function main() {
|
||||||
|
|
||||||
# Start the background target/etc/default/grub cheker.
|
# Start the background target/etc/default/grub cheker.
|
||||||
# The definition of this function is down below.
|
# The definition of this function is down below.
|
||||||
grub_check_and_modify &
|
grub_check_and_modify_void &
|
||||||
|
|
||||||
# Record the PID of the background checker.
|
# Record the PID of the background checker.
|
||||||
grub_check_and_modify_id=$!
|
grub_check_and_modify_id=$!
|
||||||
|
|
@ -119,6 +118,18 @@ function main() {
|
||||||
# Post-install stage
|
# Post-install stage
|
||||||
# *******************************************************************************
|
# *******************************************************************************
|
||||||
|
|
||||||
|
# Finalizing. Embedd encryption key into the ramfs image.
|
||||||
|
post_install_ubuntu()
|
||||||
|
|
||||||
|
# Normal end
|
||||||
|
return 0
|
||||||
|
|
||||||
|
} # End of ())
|
||||||
|
|
||||||
|
|
||||||
|
# *******************************************************************************
|
||||||
|
# Void Linux dependent post-installation process
|
||||||
|
function post_install_void() {
|
||||||
## Mount the target file system
|
## Mount the target file system
|
||||||
# ${TARGETMOUNTPOINT} is created by the GUI/TUI installer
|
# ${TARGETMOUNTPOINT} is created by the GUI/TUI installer
|
||||||
echo "...Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${TARGETMOUNTPOINT}."
|
echo "...Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${TARGETMOUNTPOINT}."
|
||||||
|
|
@ -179,13 +190,14 @@ function main() {
|
||||||
...Ready to reboot.
|
...Ready to reboot.
|
||||||
HEREDOC
|
HEREDOC
|
||||||
|
|
||||||
# Normal end
|
retrun 0
|
||||||
return 0
|
|
||||||
}
|
} # End of post_install_void()
|
||||||
|
|
||||||
|
|
||||||
|
# *******************************************************************************
|
||||||
# This function will be executed in the background context, to watch the TUI installer.
|
# This function will be executed in the background context, to watch the TUI installer.
|
||||||
function grub_check_and_modify() {
|
function grub_check_and_modify_void() {
|
||||||
|
|
||||||
# While the /etc/default/grub in the install target is NOT existing, keep sleeping.
|
# While the /etc/default/grub in the install target is NOT existing, keep sleeping.
|
||||||
# If installer terminated without file copy, this script also terminates.
|
# If installer terminated without file copy, this script also terminates.
|
||||||
|
|
@ -205,7 +217,8 @@ function grub_check_and_modify() {
|
||||||
# succesfull return
|
# succesfull return
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
} # para install
|
} # gurb_check_and_modify_void()
|
||||||
|
|
||||||
|
# *******************************************************************************
|
||||||
# Execute
|
# Execute
|
||||||
main
|
main
|
||||||
Loading…
Add table
Add a link
Reference in a new issue