]>
Commit | Line | Data |
---|---|---|
8dbd5412 | 1 | #!/bin/sh |
2 | ||
3 | # run-parts - concept taken from Debian | |
4 | # | |
ec8b15cb | 5 | # modified for PLD 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 | ||
b55c6107 | 18 | # std checks |
8dbd5412 | 19 | if [ $# -lt 1 ]; then |
20 | echo "Usage: run-parts <dir> <args...>" | |
21 | exit 1 | |
22 | fi | |
23 | ||
24 | if [ ! -d $1 ]; then | |
b55c6107 | 25 | echo "Is not a directory: $1" |
26 | echo "Usage: run-parts <dir> <args...>" | |
8dbd5412 | 27 | exit 1 |
28 | fi | |
29 | ||
b55c6107 | 30 | # assign passed dir name |
31 | RUNPARTS_DIR=$1 | |
32 | ||
33 | # assign absolute dir name | |
34 | olddir=`pwd` | |
35 | cd $RUNPARTS_DIR | |
36 | RUNPARTS_ADIR=`pwd` | |
37 | cd $olddir | |
38 | unset olddir | |
39 | ||
40 | # export directories for our descendants | |
41 | export RUNPARTS_ADIR RUNPARTS_DIR | |
42 | ||
43 | # shift args | |
44 | shift | |
45 | ||
46 | # exec progs if any | |
47 | for i in $RUNPARTS_DIR/* ; do | |
8dbd5412 | 48 | [ -d $i ] && continue |
49 | if [ -x $i ]; then | |
50 | $i $* | |
51 | fi | |
52 | done | |
53 | ||
54 | exit 0 |