wok-next view libpaper/stuff/run-parts @ rev 21271
up openssl10: 1.0.2o to 1.0.2t -> soon EOL
author | Erkan Yilmaz <erkan@slitaz.org> |
---|---|
date | Sat Dec 07 12:21:21 2019 +0000 (2019-12-07) |
parents | |
children |
line source
1 #!/bin/sh
2 # run-parts: Runs all the scripts found in a directory.
3 # from Slackware, by Patrick J. Volkerding with ideas borrowed
4 # from the Red Hat and Debian versions of this utility.
6 # keep going when something fails
7 set +e
9 if [ $# -lt 1 ]; then
10 echo "Usage: run-parts <directory>"
11 exit 1
12 fi
14 if [ ! -d $1 ]; then
15 echo "Not a directory: $1"
16 echo "Usage: run-parts <directory>"
17 exit 1
18 fi
20 # There are several types of files that we would like to
21 # ignore automatically, as they are likely to be backups
22 # of other scripts:
23 IGNORE_SUFFIXES="~ ^ , .bak .new .rpmsave .rpmorig .rpmnew .swp"
25 # Main loop:
26 for SCRIPT in $1/* ; do
27 # If this is not a regular file, skip it:
28 if [ ! -f $SCRIPT ]; then
29 continue
30 fi
31 # Determine if this file should be skipped by suffix:
32 SKIP=false
33 for SUFFIX in $IGNORE_SUFFIXES ; do
34 if [ ! "$(basename $SCRIPT $SUFFIX)" = "$(basename $SCRIPT)" ]; then
35 SKIP=true
36 break
37 fi
38 done
39 if [ "$SKIP" = "true" ]; then
40 continue
41 fi
42 # If we've made it this far, then run the script if it's executable:
43 if [ -x $SCRIPT ]; then
44 $SCRIPT || echo "$SCRIPT failed."
45 fi
46 done
48 exit 0