tmpfiles.sh: add support for C action

Recursively copies files or directories.  Added by systemd in 849958d1.
This commit is contained in:
Andrew Gregory 2014-08-25 15:46:28 -04:00 committed by William Hubbs
parent 6f3f50d453
commit d4204a97a2

View File

@ -80,6 +80,17 @@ _c() {
fi fi
} }
_C() {
# recursively copy a file or directory
local path=$1 mode=$2 uid=$3 gid=$4 age=$5 arg=$6
if [ ! -e "$path" ]; then
dryrun_or_real cp -r "$arg" "$path"
_restorecon "$path"
[ $uid != '-' ] && dryrun_or_real chown "$uid" "$path"
[ $gid != '-' ] && dryrun_or_real chgrp "$gid" "$path"
[ $mode != '-' ] && dryrun_or_real chmod "$mode" "$path"
fi
}
_f() { _f() {
# Create a file if it doesn't exist yet # Create a file if it doesn't exist yet
@ -325,7 +336,7 @@ for FILE in $tmpfiles_d ; do
# whine about invalid entries # whine about invalid entries
case $cmd in case $cmd in
f|F|w|d|D|p|L|c|b|x|X|r|R|z|Z) ;; f|F|w|d|D|p|L|c|C|b|x|X|r|R|z|Z) ;;
*) warninvalid ; continue ;; *) warninvalid ; continue ;;
esac esac
@ -334,7 +345,7 @@ for FILE in $tmpfiles_d ; do
case "$cmd" in case "$cmd" in
p|f|F) mode=0644 ;; p|f|F) mode=0644 ;;
d|D) mode=0755 ;; d|D) mode=0755 ;;
z|Z|x|r|R|L) ;; C|z|Z|x|r|R|L) ;;
esac esac
fi fi