Skip to content

Commit

Permalink
Add support for /etc as a submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
NeroReflex committed Mar 21, 2024
1 parent e38d815 commit ded3127
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions __frzr-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,32 @@ main() {
tar xfO ${IMG_FILE} | btrfs receive --quiet ${DEPLOY_PATH}
fi

if [ -d "${SUBVOL}/etc" ]; then
echo "System image ${NAME} will use the /etc overlay"
else
echo "System image ${NAME} will use an /etc subvolume"

btrfs subvolume create "${SUBVOL}/etc"

btrfs subvolume create "${SUBVOL}/snapshots"

btrfs subvolume create "${SUBVOL}/snapshots/etc"

# copy every stock /etc (that has been moved to /usr/etc) file to the actual /etc
cp -a ${SUBVOL}/usr/etc/** ${SUBVOL}/etc/

# copy the machine-id file: this was created by systemd the very first boot and identify the machine:
# changing this will also make ssh warn about machine not matching.
if [ -f "/etc/machine-id" ]; then
cp -a /etc/machine-id ${SUBVOL}/etc/
else
echo "WARNING: no /etc/machine-id -- new machine-id will be regenerated at next boot"
fi

# Make a snapshot of /etc so that this state can be restored
btrfs subvolume snapshot ${SUBVOL}/etc ${SUBVOL}/snapshots/etc/0
fi

mkdir -p ${MOUNT_PATH}/boot/${NAME}
cp ${SUBVOL}/boot/vmlinuz-linux ${MOUNT_PATH}/boot/${NAME}
cp ${SUBVOL}/boot/initramfs-linux.img ${MOUNT_PATH}/boot/${NAME}
Expand Down

0 comments on commit ded3127

Please sign in to comment.