]>
Commit | Line | Data |
---|---|---|
8dbd5412 | 1 | #!/bin/sh |
2 | ||
3 | # run-parts - concept taken from Debian | |
4 | # | |
ffe19b59 | 5 | # modified for PLD Linux by Pawel Wilk <siefca@pld-linux.org> |
b55c6107 | 6 | # |
7 | # NOTE: | |
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 | |
13 | # | |
8dbd5412 | 14 | |
15 | # keep going when something fails | |
16 | set +e | |
17 | ||
aefe871b ER |
18 | if [ "$1" = "--test" ]; then |
19 | test=yes | |
20 | shift | |
21 | fi | |
22 | ||
23 | if [ "$1" = "--" ]; then | |
24 | shift | |
25 | fi | |
26 | ||
b55c6107 | 27 | # std checks |
8dbd5412 | 28 | if [ $# -lt 1 ]; then |
aefe871b | 29 | echo "Usage: run-parts [-u] [--test] <dir> <args...>" |
8dbd5412 | 30 | exit 1 |
31 | fi | |
32 | ||
33 | if [ ! -d $1 ]; then | |
b55c6107 | 34 | echo "Is not a directory: $1" |
aefe871b | 35 | echo "Usage: run-parts [-u] [--test] <dir> <args...>" |
8dbd5412 | 36 | exit 1 |
37 | fi | |
38 | ||
b55c6107 | 39 | # assign passed dir name |
40 | RUNPARTS_DIR=$1 | |
41 | ||
42 | # assign absolute dir name | |
bf14fcab | 43 | olddir=$(pwd) |
b55c6107 | 44 | cd $RUNPARTS_DIR |
bf14fcab | 45 | RUNPARTS_ADIR=$(pwd) |
b55c6107 | 46 | cd $olddir |
47 | unset olddir | |
48 | ||
49 | # export directories for our descendants | |
50 | export RUNPARTS_ADIR RUNPARTS_DIR | |
51 | ||
52 | # shift args | |
53 | shift | |
54 | ||
6e2f824d | 55 | # Ignore *~ and *, scripts |
127911f1 | 56 | for i in $RUNPARTS_DIR/*[!~,] ; do |
1050f687 JR |
57 | [ -d "$i" ] && continue |
58 | # Don't run *.{rpmsave,rpmorig,rpmnew,swp} scripts | |
59 | [ "${i%.rpmsave}" != "${i}" ] && continue | |
60 | [ "${i%.rpmorig}" != "${i}" ] && continue | |
61 | [ "${i%.rpmnew}" != "${i}" ] && continue | |
62 | [ "${i%.swp}" != "${i}" ] && continue | |
63 | [ "${i%,v}" != "${i}" ] && continue | |
6e2f824d | 64 | |
1050f687 JR |
65 | if [ -x "$i" ]; then |
66 | runprog="$i $@" | |
aefe871b ER |
67 | if [ "$test" = yes ]; then |
68 | echo "$runprog" | |
69 | continue | |
70 | fi | |
1050f687 JR |
71 | $runprog 2>&1 | awk -v "progname=$i" \ |
72 | 'progname { | |
73 | print progname ":\n" | |
74 | progname=""; | |
75 | } | |
76 | { print; }' | |
77 | fi | |
8dbd5412 | 78 | done |
79 | ||
80 | exit 0 |