]> git.pld-linux.org Git - projects/rc-scripts.git/blame - run-parts
- 0.4.0.7 release
[projects/rc-scripts.git] / run-parts
CommitLineData
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
16set +e
17
b55c6107 18# std checks
8dbd5412 19if [ $# -lt 1 ]; then
20 echo "Usage: run-parts <dir> <args...>"
21 exit 1
22fi
23
24if [ ! -d $1 ]; then
b55c6107 25 echo "Is not a directory: $1"
26 echo "Usage: run-parts <dir> <args...>"
8dbd5412 27 exit 1
28fi
29
b55c6107 30# assign passed dir name
31RUNPARTS_DIR=$1
32
33# assign absolute dir name
34olddir=`pwd`
35cd $RUNPARTS_DIR
36RUNPARTS_ADIR=`pwd`
37cd $olddir
38unset olddir
39
40# export directories for our descendants
41export RUNPARTS_ADIR RUNPARTS_DIR
42
43# shift args
44shift
45
6e2f824d 46# Ignore *~ and *, scripts
127911f1 47for i in $RUNPARTS_DIR/*[!~,] ; do
6e2f824d
AM
48 [ -d $i ] && continue
49 # Don't run *.{rpmsave,rpmorig,rpmnew,swp} scripts
50 [ "${i%.rpmsave}" != "${i}" ] && continue
51 [ "${i%.rpmorig}" != "${i}" ] && continue
52 [ "${i%.rpmnew}" != "${i}" ] && continue
53 [ "${i%.swp}" != "${i}" ] && continue
54 [ "${i%,v}" != "${i}" ] && continue
55
56 if [ -x $i ]; then
57 $i $* 2>&1 | awk -v "progname=$i" \
58 'progname {
59 print progname ":\n"
60 progname="";
61 }
62 { print; }'
63 fi
8dbd5412 64done
65
66exit 0
This page took 0.052467 seconds and 4 git commands to generate.