3 # run-parts - concept taken from Debian
5 # modified for PLD Linux by Pawel Wilk <siefca@pld-linux.org>
8 # 1.) run-parts is now able to get arguments!
9 # 2.) relative pathname of the invoked directory can be
10 # obtained by reading RUNPARTS_DIR env. variable
11 # 3.) absolute pathname of the invoked directory can be
12 # obtained by reading RUNPARTS_ADIR env. variable
15 # keep going when something fails
18 if [ "$1" = "-u" ]; then
23 if [ "$1" = "--test" ]; then
28 if [ "$1" = "--" ]; then
34 echo "Usage: run-parts [-u] [--test] <dir> <args...>"
39 echo "Is not a directory: $1"
40 echo "Usage: run-parts [-u] [--test] <dir> <args...>"
44 # assign passed dir name
47 # assign absolute dir name
54 # export directories for our descendants
55 export RUNPARTS_ADIR RUNPARTS_DIR
60 # Ignore *~ and *, scripts
61 for i in $RUNPARTS_DIR/*[!~,] ; do
62 [ -d "$i" ] && continue
63 # Don't run *.{rpmsave,rpmorig,rpmnew,swp} scripts
64 [ "${i%.rpmsave}" != "${i}" ] && continue
65 [ "${i%.rpmorig}" != "${i}" ] && continue
66 [ "${i%.rpmnew}" != "${i}" ] && continue
67 [ "${i%.swp}" != "${i}" ] && continue
68 [ "${i%,v}" != "${i}" ] && continue
72 if [ "$test" = yes ]; then
76 if [ "$workasuser" = "yes" ]; then
77 runuser="$(/bin/ls -l "$i" | awk ' { print $3 } ' 2> /dev/null)"
78 [ -z "$runuser" ] && echo "Warning: Can't find owner for [$i] file. Not running." && continue
79 runprog="/bin/su $runuser -s /bin/sh -c $runprog"
81 $runprog 2>&1 | awk -v "progname=$i" \
92 # This must be last line !