init-storage: Create intermediate dirs in /etc

When creating writable paths in the `/etc` subvolume, the `setup_etc`
function needs to create intermediate directories before copying
existing files from the root filesystem.  Without this step, `cp` will
fail with a "no such file or directory" error, referring to the
destination path.
master
Dustin 2023-03-29 18:39:55 -05:00
parent 670c1f7561
commit 77f7e6d8cc
1 changed files with 5 additions and 0 deletions

View File

@ -136,6 +136,11 @@ setup_etc() {
while read type path; do while read type path; do
if [ ! -e "${tmpdir}/${path}" ]; then if [ ! -e "${tmpdir}/${path}" ]; then
if [ -e /etc/"${path}" ]; then if [ -e /etc/"${path}" ]; then
case "${path}" in
*/*)
mkdir -p "${tmpdir}/${path%/*}"
;;
esac
cp -ca /etc/"${path}" "${tmpdir}/${path}" cp -ca /etc/"${path}" "${tmpdir}/${path}"
elif [ "${type}" = d ]; then elif [ "${type}" = d ]; then
mkdir -p "${tmpdir}/${path}" mkdir -p "${tmpdir}/${path}"