]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/scripts/run-parts
"All connection fine" message now only showed one time.
[people/pmueller/ipfire-2.x.git] / src / scripts / run-parts
CommitLineData
649fd295
MT
1#!/bin/sh
2# run-parts: Runs all the scripts found in a directory.
3
4# keep going when something fails
5set +e
6
7if [ $# -lt 1 ]; then
8 echo "Usage: run-parts <directory>"
9 exit 1
10fi
11
12if [ ! -d $1 ]; then
13 echo "Not a directory: $1"
14 echo "Usage: run-parts <directory>"
15 exit 1
16fi
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:
21IGNORE_SUFFIXES="~ ^ , .bak .new .rpmsave .rpmorig .rpmnew .swp"
22
23# Main loop:
24for 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
47done
48
49exit 0