Recursively change file permissions for folders listed in profiledef.sh
- if a folder listed in the associative array ends with a "/", recursively apply chmod and chown.
This commit is contained in:
parent
e43017c955
commit
6bb12552e4
@ -55,7 +55,7 @@ The image file is constructed from some of the variables in **profiledef.sh**: `
|
|||||||
`('-comp' 'xz')` for squashfs).
|
`('-comp' 'xz')` for squashfs).
|
||||||
* `file_permissions`: An associative array that lists files and/or directories who need specific ownership or
|
* `file_permissions`: An associative array that lists files and/or directories who need specific ownership or
|
||||||
permissions. The array's keys contain the path and the value is a colon separated list of owner UID, owner GID and
|
permissions. The array's keys contain the path and the value is a colon separated list of owner UID, owner GID and
|
||||||
access mode. E.g. `file_permissions=(["/etc/shadow"]="0:0:400")`.
|
access mode. E.g. `file_permissions=(["/etc/shadow"]="0:0:400")`. When directories are listed with a trailing backslash ("/") **all** files and directories contained within the listed directory will have the same owner UID, owner GID, and access mode applied recursively.
|
||||||
|
|
||||||
packages.arch
|
packages.arch
|
||||||
=============
|
=============
|
||||||
|
@ -292,10 +292,15 @@ _make_custom_airootfs() {
|
|||||||
# Warn if the file does not exist
|
# Warn if the file does not exist
|
||||||
elif [[ ! -e "${airootfs_dir}${filename}" ]]; then
|
elif [[ ! -e "${airootfs_dir}${filename}" ]]; then
|
||||||
_msg_warning "Cannot change permissions of '${airootfs_dir}${filename}'. The file or directory does not exist."
|
_msg_warning "Cannot change permissions of '${airootfs_dir}${filename}'. The file or directory does not exist."
|
||||||
|
else
|
||||||
|
if [[ "${filename: -1}" == "/" ]]; then
|
||||||
|
chown -fhR -- "${permissions[0]}:${permissions[1]}" "${airootfs_dir}${filename}"
|
||||||
|
chmod -fR -- "${permissions[2]}" "${airootfs_dir}${filename}"
|
||||||
else
|
else
|
||||||
chown -fh -- "${permissions[0]}:${permissions[1]}" "${airootfs_dir}${filename}"
|
chown -fh -- "${permissions[0]}:${permissions[1]}" "${airootfs_dir}${filename}"
|
||||||
chmod -f -- "${permissions[2]}" "${airootfs_dir}${filename}"
|
chmod -f -- "${permissions[2]}" "${airootfs_dir}${filename}"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
_msg_info "Done!"
|
_msg_info "Done!"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user