wok-next annotate libpaper/stuff/run-parts @ rev 21724

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