]> git.pld-linux.org Git - projects/rc-scripts.git/blame - run-parts.sh
Don't fail if arrays are already assembled (ex raid10 with 4 devices, one device...
[projects/rc-scripts.git] / run-parts.sh
CommitLineData
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
16set +e
17
aefe871b
ER
18if [ "$1" = "--test" ]; then
19 test=yes
20 shift
21fi
22
23if [ "$1" = "--" ]; then
24 shift
25fi
26
b55c6107 27# std checks
8dbd5412 28if [ $# -lt 1 ]; then
aefe871b 29 echo "Usage: run-parts [-u] [--test] <dir> <args...>"
8dbd5412 30 exit 1
31fi
32
33if [ ! -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
37fi
38
b55c6107 39# assign passed dir name
40RUNPARTS_DIR=$1
41
42# assign absolute dir name
bf14fcab 43olddir=$(pwd)
b55c6107 44cd $RUNPARTS_DIR
bf14fcab 45RUNPARTS_ADIR=$(pwd)
b55c6107 46cd $olddir
47unset olddir
48
49# export directories for our descendants
50export RUNPARTS_ADIR RUNPARTS_DIR
51
52# shift args
53shift
54
6e2f824d 55# Ignore *~ and *, scripts
127911f1 56for 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 78done
79
80exit 0
This page took 0.127056 seconds and 4 git commands to generate.