feat: replace /etc on update

This commit is contained in:
Rudra Saraswat 2023-06-10 23:17:45 +10:00
parent 9bf1cf1aa7
commit a77f631c43

View file

@ -35,23 +35,19 @@ run_latehook() {
# Detect if /etc stage is active. # Detect if /etc stage is active.
if [[ -f /new_root/mnt/iso-update/.etc-stage ]]; then if [[ -f /new_root/mnt/iso-update/.etc-stage ]]; then
# Create new /etc.
cp -a /new_root/mnt/iso-update/squashfs-root/etc /new_root/.new.etc
# Replace editable /etc files.
for i in sudoers crypttab fstab group gshadow hosts passwd resolv.conf shadow shells subgid subuid; do
cp "/new_root/etc/${i}" /new_root/.new.etc
done
# Rename existing /etc. # Rename existing /etc.
mv /new_root/etc /new_root/.old.etc &>/dev/null || : mv /new_root/etc /new_root/.old.etc &>/dev/null || :
# Create new /etc. # Rename new /etc.
cp -a /new_root/.old.etc /new_root/etc mv /new_root/.new.etc /new_root/etc &>/dev/null || :
# Only copy non-existent files.
cp -a -n /new_root/mnt/iso-update/squashfs-root/etc/* /new_root/etc
# Update pacman config, and other system files that aren't
# supposed to be edited.
cp /new_root/mnt/iso-update/squashfs-root/etc/pacman.conf /new_root/etc
rm -rf /new_root/etc/pacman.d
cp -r /new_root/mnt/iso-update/squashfs-root/etc/pacman.d /new_root/etc
cp /new_root/mnt/iso-update/squashfs-root/etc/blend_release /new_root/etc
cp /new_root/mnt/iso-update/squashfs-root/etc/os-release /new_root/etc
cp /new_root/mnt/iso-update/squashfs-root/etc/lsb-release /new_root/etc
# Replace kernel and microcode images. # Replace kernel and microcode images.
mv /new_root/mnt/iso-update/iso/boot/initramfs-linux-zen.img /new_root/boot/initramfs-linux-zen.img mv /new_root/mnt/iso-update/iso/boot/initramfs-linux-zen.img /new_root/boot/initramfs-linux-zen.img