2012-03-12 13:58:44 +05:30
|
|
|
#!/bin/sh
|
|
|
|
# This is a reimplementation of the systemd tmpfiles.d code
|
|
|
|
# Control creation, deletion, and cleaning of volatile and temporary files
|
|
|
|
#
|
|
|
|
# Copyright (c) 2012 Gentoo Foundation
|
2014-05-26 12:21:37 +05:30
|
|
|
# Released under the 2-clause BSD license.
|
2012-03-12 13:58:44 +05:30
|
|
|
#
|
2014-05-26 12:21:37 +05:30
|
|
|
# This instance is a pure-POSIX sh version, written by Robin H Johnson
|
|
|
|
# <robbat2@gentoo.org>, based on the Arch Linux version as of 2012/01/01:
|
2012-03-12 13:58:44 +05:30
|
|
|
# http://projects.archlinux.org/initscripts.git/tree/arch-tmpfiles
|
|
|
|
#
|
|
|
|
# See the tmpfiles.d manpage as well:
|
2016-05-25 14:33:12 +05:30
|
|
|
# https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html
|
|
|
|
# This script should match the old manpage
|
2012-03-12 13:58:44 +05:30
|
|
|
# http://0pointer.de/public/systemd-man/tmpfiles.d.html
|
2016-05-25 14:33:12 +05:30
|
|
|
# as of 2012/03/12 and also implements some more recent features
|
2012-03-12 13:58:44 +05:30
|
|
|
#
|
|
|
|
|
2012-09-27 03:43:16 +05:30
|
|
|
DRYRUN=0
|
2014-08-06 03:42:35 +05:30
|
|
|
CHECKPATH="@LIBEXECDIR@/bin/checkpath"
|
2012-09-27 03:43:16 +05:30
|
|
|
|
2013-07-25 11:28:38 +05:30
|
|
|
checkprefix() {
|
|
|
|
n=$1
|
|
|
|
shift
|
|
|
|
for x in $@; do
|
|
|
|
case $n in
|
|
|
|
${x}*) return 0 ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2012-03-12 13:58:44 +05:30
|
|
|
warninvalid() {
|
|
|
|
printf "tmpfiles: ignoring invalid entry on line %d of \`%s'\n" "$LINENUM" "$FILE"
|
|
|
|
error=$(( error+1 ))
|
|
|
|
} >&2
|
|
|
|
|
2016-03-12 23:31:51 +05:30
|
|
|
invalid_option() {
|
|
|
|
printf "tmpfiles: invalid option '%s'\n" "$1" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2012-09-27 03:43:16 +05:30
|
|
|
dryrun_or_real() {
|
|
|
|
local dryrun=
|
|
|
|
[ $DRYRUN -eq 1 ] && dryrun=echo
|
|
|
|
$dryrun "$@"
|
|
|
|
}
|
|
|
|
|
2016-05-25 14:33:12 +05:30
|
|
|
_chattr() {
|
|
|
|
local attr="$2"
|
|
|
|
case $attr in
|
|
|
|
[+-=]*) : ;;
|
|
|
|
'') return ;;
|
|
|
|
*) attr="+$attr" ;;
|
|
|
|
esac
|
|
|
|
local IFS=
|
|
|
|
dryrun_or_real chattr $1 "$attr" -- $3
|
|
|
|
}
|
|
|
|
|
2012-03-12 13:58:44 +05:30
|
|
|
relabel() {
|
2012-03-13 00:29:53 +05:30
|
|
|
local path
|
2012-03-12 13:58:44 +05:30
|
|
|
local paths=$1 mode=$2 uid=$3 gid=$4
|
|
|
|
|
|
|
|
for path in ${paths}; do
|
2012-03-13 00:29:53 +05:30
|
|
|
if [ -e "$path" ]; then
|
2014-08-14 01:56:37 +05:30
|
|
|
[ -x /sbin/restorecon ] && dryrun_or_real restorecon $CHOPTS "$path"
|
2012-09-27 03:43:16 +05:30
|
|
|
[ $uid != '-' ] && dryrun_or_real chown $CHOPTS "$uid" "$path"
|
|
|
|
[ $gid != '-' ] && dryrun_or_real chgrp $CHOPTS "$gid" "$path"
|
|
|
|
[ $mode != '-' ] && dryrun_or_real chmod $CHOPTS "$mode" "$path"
|
2012-03-12 13:58:44 +05:30
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
2012-03-13 00:29:53 +05:30
|
|
|
|
2015-07-11 02:15:11 +05:30
|
|
|
splitpath() {
|
|
|
|
local path=$1
|
|
|
|
while [ -n "$path" ]; do
|
|
|
|
echo $path
|
|
|
|
path=${path%/*}
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2014-07-15 23:57:32 +05:30
|
|
|
_restorecon() {
|
|
|
|
local path=$1
|
|
|
|
if [ -x /sbin/restorecon ]; then
|
2015-07-11 02:15:11 +05:30
|
|
|
dryrun_or_real restorecon -F $(splitpath "$path")
|
2014-07-15 23:57:32 +05:30
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-03-12 13:58:44 +05:30
|
|
|
_b() {
|
|
|
|
# Create a block device node if it doesn't exist yet
|
|
|
|
local path=$1 mode=$2 uid=$3 gid=$4 age=$5 arg=$6
|
2013-07-27 21:23:32 +05:30
|
|
|
if [ ! -e "$path" ]; then
|
|
|
|
dryrun_or_real mknod -m $mode $path b ${arg%:*} ${arg#*:}
|
2014-07-15 23:57:32 +05:30
|
|
|
_restorecon "$path"
|
2014-08-13 12:20:34 +05:30
|
|
|
dryrun_or_real chown $uid:$gid $path
|
2013-07-27 21:23:32 +05:30
|
|
|
fi
|
2012-03-12 13:58:44 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
_c() {
|
|
|
|
# Create a character device node if it doesn't exist yet
|
|
|
|
local path=$1 mode=$2 uid=$3 gid=$4 age=$5 arg=$6
|
2013-07-27 21:23:32 +05:30
|
|
|
if [ ! -e "$path" ]; then
|
|
|
|
dryrun_or_real mknod -m $mode $path c ${arg%:*} ${arg#*:}
|
2014-07-15 23:57:32 +05:30
|
|
|
_restorecon "$path"
|
2014-08-13 12:20:34 +05:30
|
|
|
dryrun_or_real chown $uid:$gid $path
|
2013-07-27 21:23:32 +05:30
|
|
|
fi
|
2012-03-12 13:58:44 +05:30
|
|
|
}
|
|
|
|
|
2014-08-26 01:16:28 +05:30
|
|
|
_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
|
|
|
|
}
|
2012-03-12 13:58:44 +05:30
|
|
|
|
|
|
|
_f() {
|
|
|
|
# Create a file if it doesn't exist yet
|
|
|
|
local path=$1 mode=$2 uid=$3 gid=$4 age=$5 arg=$6
|
|
|
|
|
|
|
|
[ $CREATE -gt 0 ] || return 0
|
|
|
|
|
2012-03-13 00:29:53 +05:30
|
|
|
if [ ! -e "$path" ]; then
|
2014-08-06 03:42:35 +05:30
|
|
|
dryrun_or_real $CHECKPATH -fq -m "$mode" -o "$uid:$gid" "$path"
|
2012-10-12 00:04:19 +05:30
|
|
|
[ -z "$arg" ] || _w "$@"
|
2012-03-12 13:58:44 +05:30
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_F() {
|
|
|
|
# Create or truncate a file
|
|
|
|
local path=$1 mode=$2 uid=$3 gid=$4 age=$5 arg=$6
|
|
|
|
|
|
|
|
[ $CREATE -gt 0 ] || return 0
|
|
|
|
|
2014-08-06 03:42:35 +05:30
|
|
|
dryrun_or_real $CHECKPATH -Fq -m "$mode" -o "$uid:$gid" "$path"
|
2012-10-12 00:04:19 +05:30
|
|
|
[ -z "$arg" ] || _w "$@"
|
2012-03-12 13:58:44 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
_d() {
|
|
|
|
# Create a directory if it doesn't exist yet
|
|
|
|
local path=$1 mode=$2 uid=$3 gid=$4
|
|
|
|
|
|
|
|
[ $CREATE -gt 0 ] || return 0
|
|
|
|
|
|
|
|
if [ ! -d "$path" ]; then
|
2014-08-06 03:42:35 +05:30
|
|
|
dryrun_or_real mkdir -p "$path" 2>/dev/null
|
2015-07-11 02:15:11 +05:30
|
|
|
_restorecon "$path"
|
2014-08-06 03:42:35 +05:30
|
|
|
dryrun_or_real $CHECKPATH -dq -m "$mode" -o "$uid:$gid" "$path"
|
2012-03-12 13:58:44 +05:30
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_D() {
|
|
|
|
# Create or empty a directory
|
|
|
|
local path=$1 mode=$2 uid=$3 gid=$4
|
|
|
|
|
2012-03-13 00:29:53 +05:30
|
|
|
if [ -d "$path" ] && [ $REMOVE -gt 0 ]; then
|
2012-09-27 03:43:16 +05:30
|
|
|
dryrun_or_real find "$path" -mindepth 1 -maxdepth 1 -xdev -exec rm -rf {} +
|
2014-07-15 23:57:32 +05:30
|
|
|
_restorecon "$path"
|
2012-03-12 13:58:44 +05:30
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $CREATE -gt 0 ]; then
|
2014-08-06 03:42:35 +05:30
|
|
|
dryrun_or_real mkdir -p "$path" 2>/dev/null
|
2015-07-11 02:15:11 +05:30
|
|
|
_restorecon "$path"
|
2014-08-06 03:42:35 +05:30
|
|
|
dryrun_or_real $CHECKPATH -Dq -m "$mode" -o "$uid:$gid" "$path"
|
2012-03-12 13:58:44 +05:30
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-06-14 06:55:33 +05:30
|
|
|
_v() {
|
|
|
|
# Create a subvolume if the path does not exist yet and the file system
|
|
|
|
# supports this (btrfs). Otherwise create a normal directory.
|
|
|
|
# TODO: Implement btrfs subvol creation.
|
|
|
|
_d "$@"
|
|
|
|
}
|
|
|
|
|
2016-05-25 14:33:12 +05:30
|
|
|
_q() {
|
|
|
|
# Similar to _v. However, make sure that the subvolume will be assigned
|
|
|
|
# to the same higher-level quota groups as the subvolume it has
|
|
|
|
# been created in.
|
|
|
|
# TODO: Implement btrfs subvol creation.
|
|
|
|
_d "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
_Q() {
|
|
|
|
# Similar to q. However, instead of copying the higher-level quota
|
|
|
|
# group assignments from the parent as-is, the lowest quota group
|
|
|
|
# of the parent subvolume is determined that is not the
|
|
|
|
# leaf quota group.
|
|
|
|
# TODO: Implement btrfs subvol creation.
|
|
|
|
_d "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
_h() {
|
|
|
|
# Set file/directory attributes. Lines of this type accept
|
|
|
|
# shell-style globs in place of normal path names.
|
|
|
|
# The format of the argument field matches chattr
|
|
|
|
_chattr '' "$6" "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
_H() {
|
|
|
|
# Recursively set file/directory attributes. Lines of this type accept
|
|
|
|
# shell-syle globs in place of normal path names.
|
|
|
|
# Does not follow symlinks
|
|
|
|
_chattr -R "$6" "$1"
|
|
|
|
}
|
|
|
|
|
2012-03-12 13:58:44 +05:30
|
|
|
_L() {
|
|
|
|
# Create a symlink if it doesn't exist yet
|
|
|
|
local path=$1 mode=$2 uid=$3 gid=$4 age=$5 arg=$6
|
2013-07-17 03:39:05 +05:30
|
|
|
[ ! -e "$path" ] && dryrun_or_real ln -s "$arg" "$path"
|
2014-07-15 23:57:32 +05:30
|
|
|
_restorecon "$path"
|
2012-03-12 13:58:44 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
_p() {
|
|
|
|
# Create a named pipe (FIFO) if it doesn't exist yet
|
|
|
|
local path=$1 mode=$2 uid=$3 gid=$4
|
|
|
|
|
|
|
|
[ $CREATE -gt 0 ] || return 0
|
|
|
|
|
|
|
|
if [ ! -p "$path" ]; then
|
2014-08-06 03:42:35 +05:30
|
|
|
dryrun_or_real $CHECKPATH -pq -m $mode -o "$uid:$gid" "$path"
|
2012-03-12 13:58:44 +05:30
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_x() {
|
|
|
|
# Ignore a path during cleaning. Use this type to exclude paths from clean-up as
|
|
|
|
# controlled with the Age parameter. Note that lines of this type do not
|
|
|
|
# influence the effect of r or R lines. Lines of this type accept shell-style
|
|
|
|
# globs in place of of normal path names.
|
|
|
|
:
|
|
|
|
# XXX: we don't implement this
|
|
|
|
}
|
|
|
|
|
2013-03-11 11:33:06 +05:30
|
|
|
_X() {
|
|
|
|
# Ignore a path during cleanup. Use this type to prevent path
|
|
|
|
# removal as controled with the age parameter. Note that if path is
|
|
|
|
# a directory, the content of the directory is not excluded from
|
|
|
|
# clean-up, only the directory itself.
|
|
|
|
# Lines of this type accept shell-style globs in place of normal path names.
|
|
|
|
:
|
|
|
|
# XXX: we don't implement this
|
|
|
|
}
|
|
|
|
|
2012-03-12 13:58:44 +05:30
|
|
|
_r() {
|
|
|
|
# Remove a file or directory if it exists. This may not be used to remove
|
|
|
|
# non-empty directories, use R for that. Lines of this type accept shell-style
|
|
|
|
# globs in place of normal path names.
|
|
|
|
local path
|
|
|
|
local paths=$1
|
|
|
|
|
|
|
|
[ $REMOVE -gt 0 ] || return 0
|
|
|
|
|
2012-03-13 00:29:53 +05:30
|
|
|
for path in ${paths}; do
|
|
|
|
if [ -f "$path" ]; then
|
2012-09-27 03:43:16 +05:30
|
|
|
dryrun_or_real rm -f "$path"
|
2012-03-13 00:29:53 +05:30
|
|
|
elif [ -d "$path" ]; then
|
2012-09-27 03:43:16 +05:30
|
|
|
dryrun_or_real rmdir "$path"
|
2012-03-12 13:58:44 +05:30
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
_R() {
|
|
|
|
# Recursively remove a path and all its subdirectories (if it is a directory).
|
|
|
|
# Lines of this type accept shell-style globs in place of normal path names.
|
|
|
|
local path
|
|
|
|
local paths=$1
|
|
|
|
|
|
|
|
[ $REMOVE -gt 0 ] || return 0
|
|
|
|
|
2012-03-13 00:29:53 +05:30
|
|
|
for path in ${paths}; do
|
2012-09-27 03:43:16 +05:30
|
|
|
[ -d "$path" ] && dryrun_or_real rm -rf --one-file-system "$path"
|
2012-03-12 13:58:44 +05:30
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
_w() {
|
|
|
|
# Write the argument parameter to a file, if it exists.
|
|
|
|
local path=$1 mode=$2 uid=$3 gid=$4 age=$5 arg=$6
|
2012-09-27 03:43:16 +05:30
|
|
|
if [ -f "$path" ]; then
|
|
|
|
if [ $DRYRUN -eq 1 ]; then
|
|
|
|
echo "echo \"$arg\" >>\"$path\""
|
|
|
|
else
|
|
|
|
echo "$arg" >>"$path"
|
|
|
|
fi
|
|
|
|
fi
|
2012-03-12 13:58:44 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
_z() {
|
|
|
|
# Set ownership, access mode and relabel security context of a file or
|
|
|
|
# directory if it exists. Lines of this type accept shell-style globs in
|
|
|
|
# place of normal path names.
|
|
|
|
[ $CREATE -gt 0 ] || return 0
|
|
|
|
|
|
|
|
relabel "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
_Z() {
|
|
|
|
# Recursively set ownership, access mode and relabel security context of a
|
|
|
|
# path and all its subdirectories (if it is a directory). Lines of this type
|
|
|
|
# accept shell-style globs in place of normal path names.
|
|
|
|
[ $CREATE -gt 0 ] || return 0
|
|
|
|
|
|
|
|
CHOPTS=-R relabel "$@"
|
|
|
|
}
|
|
|
|
|
2014-03-26 21:43:20 +05:30
|
|
|
BOOT=0 CREATE=0 REMOVE=0 CLEAN=0 VERBOSE=0 DRYRUN=0 error=0 LINENO=0
|
2013-07-25 11:28:38 +05:30
|
|
|
EXCLUDE=
|
|
|
|
PREFIX=
|
2016-03-13 00:40:42 +05:30
|
|
|
FILES=
|
2016-03-12 23:43:56 +05:30
|
|
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case $1 in
|
|
|
|
--boot) BOOT=1 ;;
|
|
|
|
--create) CREATE=1 ;;
|
|
|
|
--remove) REMOVE=1 ;;
|
|
|
|
--clean) CLEAN=1 ;; # TODO: Not implemented
|
|
|
|
--verbose) VERBOSE=1 ;;
|
|
|
|
--dryrun|--dry-run) DRYRUN=1 ;;
|
|
|
|
--exclude-prefix=*) EXCLUDE="${EXCLUDE}${1##--exclude-prefix=} " ;;
|
|
|
|
--prefix=*) PREFIX="${PREFIX}${1##--prefix=} " ;;
|
|
|
|
-*) invalid_option "$1" ;;
|
2016-03-13 00:40:42 +05:30
|
|
|
*) FILES="${FILES} $1"
|
2016-03-12 23:43:56 +05:30
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $(( CLEAN )) -eq 1 ] ; then
|
|
|
|
printf '%s clean mode is not implemented\n' "${0##*/}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$CREATE$REMOVE" = '00' ]; then
|
|
|
|
printf 'usage: %s [--exclude-prefix=path] [--prefix=path] [--boot] [--create] [--remove] [--clean] [--verbose] [--dry-run]\n' "${0##*/}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-03-13 00:29:53 +05:30
|
|
|
# XXX: The harcoding of /usr/lib/ is an explicit choice by upstream
|
2016-03-13 00:40:42 +05:30
|
|
|
tmpfiles_dirs='/usr/lib/tmpfiles.d /run/tmpfiles.d /etc/tmpfiles.d'
|
2012-03-12 13:58:44 +05:30
|
|
|
tmpfiles_basenames=''
|
2016-03-13 00:40:42 +05:30
|
|
|
|
|
|
|
if [ -z "${FILES}" ]; then
|
|
|
|
# Build a list of sorted unique basenames
|
|
|
|
# directories declared later in the tmpfiles_d array will override earlier
|
|
|
|
# directories, on a per file basename basis.
|
|
|
|
# `/etc/tmpfiles.d/foo.conf' supersedes `/usr/lib/tmpfiles.d/foo.conf'.
|
|
|
|
# `/run/tmpfiles/foo.conf' will always be read after `/etc/tmpfiles.d/bar.conf'
|
|
|
|
for d in ${tmpfiles_dirs} ; do
|
|
|
|
[ -d $d ] && for f in ${d}/*.conf ; do
|
|
|
|
case "${f##*/}" in
|
|
|
|
systemd.conf|systemd-*.conf) continue;;
|
|
|
|
esac
|
|
|
|
[ -f $f ] && tmpfiles_basenames="${tmpfiles_basenames}\n${f##*/}"
|
|
|
|
done # for f in ${d}
|
|
|
|
done # for d in ${tmpfiles_dirs}
|
|
|
|
FILES="$(printf "${tmpfiles_basenames}\n" | sort -u )"
|
|
|
|
fi
|
|
|
|
|
2012-03-12 13:58:44 +05:30
|
|
|
tmpfiles_d=''
|
2016-03-13 00:40:42 +05:30
|
|
|
|
|
|
|
for b in ${FILES} ; do
|
|
|
|
if [ "${b##*/}" != "${b}" ]; then
|
|
|
|
# The user specified a path on the command line
|
|
|
|
# Just pass it through unaltered
|
|
|
|
tmpfiles_d="${tmpfiles_d} ${b}"
|
|
|
|
else
|
|
|
|
real_f=''
|
|
|
|
for d in $tmpfiles_dirs ; do
|
|
|
|
f=${d}/${b}
|
|
|
|
[ -f "${f}" ] && real_f=$f
|
|
|
|
done
|
|
|
|
[ -f "${real_f}" ] && tmpfiles_d="${tmpfiles_d} ${real_f}"
|
|
|
|
fi
|
2012-03-12 13:58:44 +05:30
|
|
|
done
|
|
|
|
|
|
|
|
error=0
|
|
|
|
|
|
|
|
# loop through the gathered fragments, sorted globally by filename.
|
|
|
|
# `/run/tmpfiles/foo.conf' will always be read after `/etc/tmpfiles.d/bar.conf'
|
2016-03-13 00:40:42 +05:30
|
|
|
FILE=
|
2012-03-12 13:58:44 +05:30
|
|
|
for FILE in $tmpfiles_d ; do
|
|
|
|
LINENUM=0
|
|
|
|
|
|
|
|
### FILE FORMAT ###
|
|
|
|
# XXX: We ignore the 'Age' parameter
|
|
|
|
# 1 2 3 4 5 6 7
|
|
|
|
# Cmd Path Mode UID GID Age Argument
|
|
|
|
# d /run/user 0755 root root 10d -
|
|
|
|
# Mode, UID, GID, Age, Argument may be omitted!
|
2014-03-26 21:43:20 +05:30
|
|
|
# If Cmd ends with !, the line is only processed if --boot is passed
|
2012-03-12 13:58:44 +05:30
|
|
|
|
2012-03-13 00:29:53 +05:30
|
|
|
# XXX: Upstream says whitespace is NOT permitted in the Path argument.
|
|
|
|
# But IS allowed when globs are expanded for the x/r/R/z/Z types.
|
2012-10-12 00:04:20 +05:30
|
|
|
while read cmd path mode uid gid age arg; do
|
2012-03-12 13:58:44 +05:30
|
|
|
LINENUM=$(( LINENUM+1 ))
|
2014-08-26 01:07:45 +05:30
|
|
|
FORCE=0
|
2012-03-12 13:58:44 +05:30
|
|
|
|
2012-03-13 00:29:53 +05:30
|
|
|
# Unless we have both command and path, skip this line.
|
2012-10-12 00:04:20 +05:30
|
|
|
if [ -z "$cmd" -o -z "$path" ]; then
|
2012-03-12 13:58:44 +05:30
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2014-03-26 21:43:20 +05:30
|
|
|
case $cmd in
|
2014-08-26 01:07:45 +05:30
|
|
|
\#*) continue ;;
|
2014-03-26 21:43:20 +05:30
|
|
|
esac
|
|
|
|
|
2014-08-26 01:07:45 +05:30
|
|
|
while [ ${#cmd} -gt 1 ]; do
|
|
|
|
case $cmd in
|
|
|
|
*!) cmd=${cmd%!}; [ "$BOOT" -eq "1" ] || continue 2 ;;
|
|
|
|
*+) cmd=${cmd%+}; FORCE=1; ;;
|
|
|
|
*) warninvalid ; continue 2 ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2012-03-12 13:58:44 +05:30
|
|
|
# whine about invalid entries
|
2012-10-12 00:04:20 +05:30
|
|
|
case $cmd in
|
2016-05-25 14:33:12 +05:30
|
|
|
f|F|w|d|D|v|p|L|c|C|b|x|X|r|R|z|Z|q|Q|h|H) ;;
|
2012-03-12 13:58:44 +05:30
|
|
|
*) warninvalid ; continue ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# fall back on defaults when parameters are passed as '-'
|
2012-10-12 00:04:20 +05:30
|
|
|
if [ "$mode" = '-' -o "$mode" = '' ]; then
|
|
|
|
case "$cmd" in
|
2012-03-12 13:58:44 +05:30
|
|
|
p|f|F) mode=0644 ;;
|
2015-06-14 06:55:33 +05:30
|
|
|
d|D|v) mode=0755 ;;
|
2014-08-26 01:16:28 +05:30
|
|
|
C|z|Z|x|r|R|L) ;;
|
2012-03-12 13:58:44 +05:30
|
|
|
esac
|
|
|
|
fi
|
2012-10-12 00:04:20 +05:30
|
|
|
|
|
|
|
[ "$uid" = '-' -o "$uid" = '' ] && uid=0
|
|
|
|
[ "$gid" = '-' -o "$gid" = '' ] && gid=0
|
|
|
|
[ "$age" = '-' -o "$age" = '' ] && age=0
|
|
|
|
[ "$arg" = '-' -o "$arg" = '' ] && arg=''
|
2012-03-12 13:58:44 +05:30
|
|
|
set -- "$path" "$mode" "$uid" "$gid" "$age" "$arg"
|
|
|
|
|
2013-07-25 11:28:38 +05:30
|
|
|
[ -n "$EXCLUDE" ] && checkprefix $path $EXCLUDE && continue
|
|
|
|
[ -n "$PREFIX" ] && ! checkprefix $path $PREFIX && continue
|
2014-08-26 01:07:45 +05:30
|
|
|
|
|
|
|
if [ $FORCE -gt 0 ]; then
|
|
|
|
case $cmd in
|
|
|
|
p|L|c|b) [ -f "$path" ] && dryrun_or_real rm -f "$path"
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2012-03-12 13:58:44 +05:30
|
|
|
[ "$VERBOSE" -eq "1" ] && echo _$cmd "$@"
|
2012-09-27 03:43:16 +05:30
|
|
|
_$cmd "$@"
|
|
|
|
rc=$?
|
2012-03-12 13:58:44 +05:30
|
|
|
if [ "${DRYRUN}" -eq "0" ]; then
|
|
|
|
[ $rc -ne 0 ] && error=$((error + 1))
|
|
|
|
fi
|
|
|
|
done <$FILE
|
|
|
|
done
|
|
|
|
|
|
|
|
exit $error
|
|
|
|
|
|
|
|
# vim: set ts=2 sw=2 sts=2 noet ft=sh:
|