Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  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.
  5.  
  6. # keep going when something fails
  7. set +e
  8.  
  9. if [ $# -lt 1 ]; then
  10. echo "Usage: run-parts <directory>"
  11. exit 1
  12. fi
  13.  
  14. if [ ! -d $1 ]; then
  15. echo "Not a directory: $1"
  16. echo "Usage: run-parts <directory>"
  17. exit 1
  18. fi
  19.  
  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"
  24.  
  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
  47.  
  48. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement