diff --git a/frzr-initramfs b/frzr-initramfs index cc82c7d..1d815db 100755 --- a/frzr-initramfs +++ b/frzr-initramfs @@ -12,20 +12,23 @@ if grep -q "microcode" "/etc/mkinitcpio.conf"; then microcode_flag="# " fi -# Check if script is being ran frmo the install media -if [ -d /tmp/frzr_root ]; then +function initramfs_subvol() { + local subvol=$1 + if [ -z "$subvol" ]; then + echo "No subvol found" >&2 + exit 1 + fi - if [ -d "${SUBVOL}" ]; then + cd $subvol + # Mount necessary file systems + mount -t proc /proc proc/ + mount -t sysfs /sys sys/ + mount --rbind /dev dev/ - cd ${SUBVOL} - # Mount necessary file systems - mount -t proc /proc proc/ - mount -t sysfs /sys sys/ - mount --rbind /dev dev/ + # Set R/W permissions + btrfs property set -fts ${SUBVOL} ro false - # Set R/W permissions - btrfs property set -fts ${SUBVOL} ro false - chroot ${SUBVOL} /bin/bash <&2 + exit 1 + fi + if [ -z "$BUILD" ]; then + echo "No BUILD found" >&2 + exit 1 + fi + if [ -z path ]; then + echo "No path found" >&2 + exit 1 + fi + + cat > "/etc/mkinitcpio.d/${ID}.preset" < /etc/mkinitcpio.d/\${NAME%%-*}.preset - -### Rebuild Initramfs with custom preset -mkinitcpio -p \${NAME%%-*} -EOF - umount -l ${SUBVOL}/proc - umount -l ${SUBVOL}/sys - mount --make-rslave ${SUBVOL}/dev - umount -l ${SUBVOL}/dev - elif [[ -d "/efi/${BUILD}" ]] || grep -q "HOOKS=.*systemd" /etc/mkinitcpio.conf; then - echo ' -ALL_config="/etc/mkinitcpio.conf" -ALL_kver="/efi/'$BUILD'/vmlinuz-linux" -'${microcode_flag}'ALL_microcode=(/efi/'$BUILD'/*-ucode.img) - -PRESETS="default" - -default_image="/efi/initramfs-linux.img" -' >/etc/mkinitcpio.d/$ID.preset - # If we are not doing a deployment then this will be used for local installs to rebuild initramfs - mkinitcpio -p $ID + initramfs_subvol "${SUBVOL}" + elif [[ -d "/efi/${BUILD}" ]] && grep -q "HOOKS=.*systemd" /etc/mkinitcpio.conf; then + initramfs_boot "/efi" else - echo ' -ALL_config="/etc/mkinitcpio.conf" -ALL_kver="/boot/'$BUILD'/vmlinuz-linux" -'${microcode_flag}'ALL_microcode=(/boot/'$BUILD'/*-ucode.img) - -PRESETS="default" - -default_image="/boot/'$BUILD'/initramfs-linux.img" -' >/etc/mkinitcpio.d/$ID.preset - # If we are not doing a deployment then this will be used for local installs to rebuild initramfs - mkinitcpio -p $ID + initramfs_boot "/frzr_root/boot" fi if [[ $RELOCK == 1 ]]; then @@ -165,5 +159,10 @@ default_image="/boot/'$BUILD'/initramfs-linux.img" cp /efi/$BUILD/* /efi cp /efi/$BUILD/* /boot fi + + if [[ -d /frzr_root/boot/$BUILD ]]; then + cp /frzr_root/boot/$BUILD/* /frzr_root/boot + cp /frzr_root/boot/$BUILD/* /boot + fi fi fi