diff options
author | David Kaspar [Dee'Kej] <dkaspar@redhat.com> | 2018-06-12 16:56:10 +0200 |
---|---|---|
committer | Dee'Kej <deekej@linuxmail.org> | 2018-06-14 16:11:54 +0200 |
commit | ead5bff2561eae45007c8d9e949379c3454c0183 (patch) | |
tree | 9a06467233a11dc341fb16744c43a0380ddaa249 /usr/libexec/import-state | |
parent | 17804e1638381978174cfd31ff59e466bcc13cf5 (diff) | |
download | initscripts-ead5bff2561eae45007c8d9e949379c3454c0183.tar initscripts-ead5bff2561eae45007c8d9e949379c3454c0183.tar.gz initscripts-ead5bff2561eae45007c8d9e949379c3454c0183.tar.bz2 initscripts-ead5bff2561eae45007c8d9e949379c3454c0183.tar.xz initscripts-ead5bff2561eae45007c8d9e949379c3454c0183.zip |
specfile: services from /usr/lib/systemd moved to /usr/libexec
Diffstat (limited to 'usr/libexec/import-state')
-rwxr-xr-x | usr/libexec/import-state | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/usr/libexec/import-state b/usr/libexec/import-state new file mode 100755 index 00000000..be2d13eb --- /dev/null +++ b/usr/libexec/import-state @@ -0,0 +1,39 @@ +#!/bin/bash +# import-state: import state files from initramfs (e.g. network config) + +# Copy state into root folder: +# ============================ +cd /run/initramfs/state + +IFS_backup=$IFS +IFS=$'\n' # Process find's results line by line + +dirs_found=$(find . -type d) + +for dir in $dirs_found; do + pushd "$dir" > /dev/null + + # Remove initial '.' char from the find's result: + dest_dir="${dir/\./}" + + # Create destination folder if it does not exist (with the same rights): + if [[ -n "$dest_dir" && ! -d "$dest_dir" ]]; then + mkdir -p "$dest_dir" + chmod --reference="$PWD" "$dest_dir" + chown --reference="$PWD" "$dest_dir" + fi + + # Copy all files that are not directory: + find . -mindepth 1 -maxdepth 1 -not -type d -exec cp -av -t "$dest_dir" {} \; > /dev/null + + popd > /dev/null +done + +IFS=$IFS_backup + + +# Run restorecon on the copied files: +# =================================== +if [ -e /sys/fs/selinux/enforce ] && [ -x /usr/sbin/restorecon ]; then + find . -mindepth 1 -print0 | { cd / && xargs --null restorecon -iF; } +fi |