]>
Commit | Line | Data |
---|---|---|
649fd295 MT |
1 | #!/bin/sh |
2 | # run-parts: Runs all the scripts found in a directory. | |
3 | ||
4 | # keep going when something fails | |
5 | set +e | |
6 | ||
7 | if [ $# -lt 1 ]; then | |
8 | echo "Usage: run-parts <directory>" | |
9 | exit 1 | |
10 | fi | |
11 | ||
12 | if [ ! -d $1 ]; then | |
13 | echo "Not a directory: $1" | |
14 | echo "Usage: run-parts <directory>" | |
15 | exit 1 | |
16 | fi | |
17 | ||
18 | # There are several types of files that we would like to | |
19 | # ignore automatically, as they are likely to be backups | |
20 | # of other scripts: | |
21 | IGNORE_SUFFIXES="~ ^ , .bak .new .rpmsave .rpmorig .rpmnew .swp" | |
22 | ||
23 | # Main loop: | |
24 | for SCRIPT in $1/* ; do | |
25 | # If this is not a regular file, skip it: | |
26 | if [ ! -f $SCRIPT ]; then | |
27 | continue | |
28 | fi | |
29 | # Determine if this file should be skipped by suffix: | |
30 | SKIP=false | |
31 | for SUFFIX in $IGNORE_SUFFIXES ; do | |
32 | if [ ! "`basename $SCRIPT $SUFFIX`" = "`basename $SCRIPT`" ]; then | |
33 | SKIP=true | |
34 | break | |
35 | fi | |
36 | done | |
37 | if [ "$SKIP" = "true" ]; then | |
38 | continue | |
39 | fi | |
40 | # If we've made it this far, then run the script if it's executable: | |
41 | if [ -x $SCRIPT ]; then | |
42 | echo "$SCRIPT:" | |
43 | echo | |
44 | $SCRIPT 2>&1 | |
45 | echo | |
46 | fi | |
47 | done | |
48 | ||
49 | exit 0 |