aboutsummaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2014-08-25 15:37:45 -0400
committerWilliam Hubbs <w.d.hubbs@gmail.com>2014-08-27 17:48:34 -0500
commit6f3f50d4530f583d0d2aedec8af20077a9d07f4f (patch)
tree6d7d1057bd33180bdbb23fc6579e2aaadda72caa /sh
parent4f4f00d612ce6b43a2dcba9e0c39816e5d6d92a7 (diff)
tmpfiles.sh: add support for + modifier
systemd added support for b+, c+, p+, and L+ in 2e78fa79 and 1554afae to remove the target path if it already exists.
Diffstat (limited to 'sh')
-rwxr-xr-xsh/tmpfiles.sh.in19
1 files changed, 17 insertions, 2 deletions
diff --git a/sh/tmpfiles.sh.in b/sh/tmpfiles.sh.in
index 42a36392..41f86cf1 100755
--- a/sh/tmpfiles.sh.in
+++ b/sh/tmpfiles.sh.in
@@ -304,6 +304,7 @@ for FILE in $tmpfiles_d ; do
# But IS allowed when globs are expanded for the x/r/R/z/Z types.
while read cmd path mode uid gid age arg; do
LINENUM=$(( LINENUM+1 ))
+ FORCE=0
# Unless we have both command and path, skip this line.
if [ -z "$cmd" -o -z "$path" ]; then
@@ -311,13 +312,20 @@ for FILE in $tmpfiles_d ; do
fi
case $cmd in
- *!) [ "$BOOT" -eq "1" ] || continue; cmd=${cmd%!} ;;
+ \#*) continue ;;
esac
+ while [ ${#cmd} -gt 1 ]; do
+ case $cmd in
+ *!) cmd=${cmd%!}; [ "$BOOT" -eq "1" ] || continue 2 ;;
+ *+) cmd=${cmd%+}; FORCE=1; ;;
+ *) warninvalid ; continue 2 ;;
+ esac
+ done
+
# whine about invalid entries
case $cmd in
f|F|w|d|D|p|L|c|b|x|X|r|R|z|Z) ;;
- \#*) continue ;;
*) warninvalid ; continue ;;
esac
@@ -338,6 +346,13 @@ for FILE in $tmpfiles_d ; do
[ -n "$EXCLUDE" ] && checkprefix $path $EXCLUDE && continue
[ -n "$PREFIX" ] && ! checkprefix $path $PREFIX && continue
+
+ if [ $FORCE -gt 0 ]; then
+ case $cmd in
+ p|L|c|b) [ -f "$path" ] && dryrun_or_real rm -f "$path"
+ esac
+ fi
+
[ "$VERBOSE" -eq "1" ] && echo _$cmd "$@"
_$cmd "$@"
rc=$?