]> git.pld-linux.org Git - projects/rc-scripts.git/blame_incremental - run-parts.sh
more ignores
[projects/rc-scripts.git] / run-parts.sh
... / ...
CommitLineData
1#!/bin/sh
2
3# run-parts - concept taken from Debian
4#
5# modified for PLD Linux by Pawel Wilk <siefca@pld-linux.org>
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#
14
15# keep going when something fails
16set +e
17
18if [ "$1" = "--test" ]; then
19 test=yes
20 shift
21fi
22
23if [ "$1" = "--" ]; then
24 shift
25fi
26
27# std checks
28if [ $# -lt 1 ]; then
29 echo "Usage: run-parts [-u] [--test] <dir> <args...>"
30 exit 1
31fi
32
33if [ ! -d $1 ]; then
34 echo "Is not a directory: $1"
35 echo "Usage: run-parts [-u] [--test] <dir> <args...>"
36 exit 1
37fi
38
39# assign passed dir name
40RUNPARTS_DIR=$1
41
42# assign absolute dir name
43olddir=$(pwd)
44cd $RUNPARTS_DIR
45RUNPARTS_ADIR=$(pwd)
46cd $olddir
47unset olddir
48
49# export directories for our descendants
50export RUNPARTS_ADIR RUNPARTS_DIR
51
52# shift args
53shift
54
55# Ignore *~ and *, scripts
56for i in $RUNPARTS_DIR/*[!~,] ; do
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
64
65 if [ -x "$i" ]; then
66 runprog="$i $@"
67 if [ "$test" = yes ]; then
68 echo "$runprog"
69 continue
70 fi
71 $runprog 2>&1 | awk -v "progname=$i" \
72 'progname {
73 print progname ":\n"
74 progname="";
75 }
76 { print; }'
77 fi
78done
79
80exit 0
This page took 0.06116 seconds and 4 git commands to generate.