Fix the xbps-install bug

This commit is contained in:
Suikan 2021-06-30 23:23:27 +09:00
parent 4d0f926ee4
commit 228f6824bf
2 changed files with 25 additions and 15 deletions

View file

@ -27,7 +27,7 @@ if [ $? -eq 1 ] ; then # "Ubuntu" is not found in the OS name.
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 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
@ -43,8 +43,8 @@ fi # "Ubuntu" is not found in the OS 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.
Are you ready to install? [Y/N] Are you ready to install? [Y/N]
HEREDOC HEREDOC
read YESNO read YESNO

View file

@ -43,8 +43,8 @@ fi # "Void" is not found in the OS 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.
Are you ready to install? [Y/N] Are you ready to install? [Y/N]
HEREDOC HEREDOC
read YESNO read YESNO
@ -88,6 +88,9 @@ HEREDOC
return return
fi # passphrase validation fi # passphrase validation
# Install essential packages.
xbps-install -y gptfdisk xterm
# ******************************************************************************* # *******************************************************************************
# Pre-install stage # Pre-install stage
@ -253,25 +256,22 @@ wait $ubiquity_pid
## Mount the target file system ## Mount the target file system
# /target is created by the Ubiquity installer # /target is created by the Ubiquity installer
echo "...Mount /dev/mapper/${VGNAME}-${LVROOTNAME} on /target." echo "...Mount /dev/mapper/${VGNAME}-${LVROOTNAME} on /mnt/target."
mount /dev/mapper/${VGNAME}-${LVROOTNAME} /target mount /dev/mapper/${VGNAME}-${LVROOTNAME} /mnt/target
# And mount other directories # And mount other directories
echo "...Mount all other dirs." echo "...Mount all other dirs."
for n in proc sys dev etc/resolv.conf; do mount --rbind "/$n" "/target/$n"; done for n in proc sys dev etc/resolv.conf; do mount --rbind "/$n" "/mnt/target/$n"; done
# 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 /target." echo "...Chroot to /target."
cat <<HEREDOC | chroot /target /bin/bash cat <<HEREDOC | chroot /mnt/target /bin/bash
# Mount the rest of partitions by target /etc/fstab # Mount the rest of partitions by target /etc/fstab
mount -a 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 xbps-install -y lvm2 cryptsetup
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."
@ -288,14 +288,24 @@ 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
echo "...Register key file to the ramfs"
echo 'install_items+=" /etc/luks/boot_os.keyfile /etc/crypttab " ' > /etc/dracut.conf.d/10-crypt.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 xbps-reconfigure -fa
echo "...grub-mkconfig."
grub-mkconfig -o /boot/grub/grub.cfg
echo "...update-grub."
update-grub
# Leave chroot # Leave chroot
exit
HEREDOC HEREDOC
# Unmount all
echo "...Unmount all."
umount -R /mnt/target
# Finishing message # Finishing message
cat <<HEREDOC cat <<HEREDOC
****************** Post-install process finished ****************** ****************** Post-install process finished ******************