Refactor the structure of the source

Common part is moved to common dir
This commit is contained in:
Suikan 2021-07-01 15:10:12 +09:00
parent ea49d6d082
commit 0b392629c9
6 changed files with 14 additions and 11 deletions

View file

@ -45,21 +45,21 @@ fi # "Ubuntu" is not found in the OS name.
# ******************************************************************************* # *******************************************************************************
# Common part of the parameter confirmation # Common part of the parameter confirmation
source _confirmation.sh source common/_confirmation.sh
# ******************************************************************************* # *******************************************************************************
# Pre-install stage # Pre-install stage
# ******************************************************************************* # *******************************************************************************
# Common part of the pre-install stage # Common part of the pre-install stage
source _preinstall.sh source common/_preinstall.sh
# ******************************************************************************* # *******************************************************************************
# Para-install stage # Para-install stage
# ******************************************************************************* # *******************************************************************************
# Show common message to let the operator focus on the critical part # Show common message to let the operator focus on the critical part
source _parainstall_msg.sh source common/_parainstall_msg.sh
# Ubuntu dependent message # Ubuntu dependent message
cat <<HEREDOC cat <<HEREDOC
@ -84,7 +84,7 @@ installer_pid=$!
# 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.
source _parainstall.sh source common/_parainstall.sh
# ******************************************************************************* # *******************************************************************************
# Post-install stage # Post-install stage
@ -108,9 +108,6 @@ mount -a
# Set up the kernel hook of encryption # Set up the kernel hook of encryption
echo "...Install cryptsetup-initramfs package." echo "...Install cryptsetup-initramfs package."
apt -qq install -y cryptsetup-initramfs apt -qq install -y cryptsetup-initramfs
echo "...Register key file to the ramfs"
echo "KEYFILE_PATTERN=/etc/luks/*.keyfile" >> /etc/cryptsetup-initramfs/conf-hook
echo "UMASK=0077" >> /etc/initramfs-tools/initramfs.conf
# Prepare a key file to embed in to the ramfs. # Prepare a key file to embed in to the ramfs.
echo "...Prepair key file." echo "...Prepair key file."
@ -127,6 +124,11 @@ printf %s "${PASSPHRASE}" | cryptsetup luksAddKey -d - "${DEV}${CRYPTPARTITION}"
echo "...Add LUKS volume info to /etc/crypttab." echo "...Add LUKS volume info to /etc/crypttab."
echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab
# Putting key file into the ramfs initial image
echo "...Register key file to the ramfs"
echo "KEYFILE_PATTERN=/etc/luks/*.keyfile" >> /etc/cryptsetup-initramfs/conf-hook
echo "UMASK=0077" >> /etc/initramfs-tools/initramfs.conf
# Finally, update the ramfs initial image with the key file. # Finally, update the ramfs initial image with the key file.
echo "...Upadte initramfs." echo "...Upadte initramfs."
update-initramfs -uk all update-initramfs -uk all

View file

@ -45,7 +45,7 @@ fi # "Void" is not found in the OS name.
# ******************************************************************************* # *******************************************************************************
# Common part of the parameter confirmation # Common part of the parameter confirmation
source _confirmation.sh source common/_confirmation.sh
# ******************************************************************************* # *******************************************************************************
# Pre-install stage # Pre-install stage
@ -60,7 +60,7 @@ else
fi fi
# Common part of the pre-install stage # Common part of the pre-install stage
source _preinstall.sh source common/_preinstall.sh
# ADD "rd.auto=1 cryptdevice=/dev/sda2:${LUKS_NAME} root=/dev/mapper/${VGNAME}-${ROOTNAME}" to GRUB. # ADD "rd.auto=1 cryptdevice=/dev/sda2:${LUKS_NAME} root=/dev/mapper/${VGNAME}-${ROOTNAME}" to GRUB.
# This is magical part. I have not understood why this is required. # This is magical part. I have not understood why this is required.
@ -74,7 +74,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
source _parainstall_msg.sh source common/_parainstall_msg.sh
# Ubuntu dependent message # Ubuntu dependent message
cat <<HEREDOC cat <<HEREDOC
@ -103,7 +103,7 @@ installer_pid=$!
# 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.
source _parainstall.sh source common/_parainstall.sh
# ******************************************************************************* # *******************************************************************************
# Post-install stage # Post-install stage
@ -143,6 +143,7 @@ printf %s "${PASSPHRASE}" | cryptsetup luksAddKey -d - "${DEV}${CRYPTPARTITION}"
echo "...Add LUKS volume info to /etc/crypttab." echo "...Add LUKS volume info to /etc/crypttab."
echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab
# Putting key file into the ramfs initial image
echo "...Register key file to the ramfs" echo "...Register key file to the ramfs"
echo 'install_items+=" /etc/luks/boot_os.keyfile /etc/crypttab " ' > /etc/dracut.conf.d/10-crypt.conf echo 'install_items+=" /etc/luks/boot_os.keyfile /etc/crypttab " ' > /etc/dracut.conf.d/10-crypt.conf