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
25 echo "Usage: run-parts [-u] <dir> <args...>"
30 echo "Is not a directory: $1"
31 echo "Usage: run-parts [-u] <dir> <args...>"
35 # assign passed dir name
38 # assign absolute dir name
45 # export directories for our descendants
46 export RUNPARTS_ADIR RUNPARTS_DIR
51 # Ignore *~ and *, scripts
52 for i in $RUNPARTS_DIR/*[!~,] ; do
53 [ -d "$i" ] && continue
54 # Don't run *.{rpmsave,rpmorig,rpmnew,swp} scripts
55 [ "${i%.rpmsave}" != "${i}" ] && continue
56 [ "${i%.rpmorig}" != "${i}" ] && continue
57 [ "${i%.rpmnew}" != "${i}" ] && continue
58 [ "${i%.swp}" != "${i}" ] && continue
59 [ "${i%,v}" != "${i}" ] && continue
63 if [ "$workasuser" = "yes" ]; then
64 runuser="$(/bin/ls -l "$i" | awk ' { print $3 } ' 2> /dev/null)"
65 [ -z "$runuser" ] && echo "Warning: Can't find owner for [$i] file. Not running." && continue
66 runprog="/bin/su $runuser -s /bin/sh -c $runprog"
68 $runprog 2>&1 | awk -v "progname=$i" \
79 # This must be last line !