From 45ac01c4fa7961811bd0969bd80d92505f3b0e6e Mon Sep 17 00:00:00 2001 From: Steve Youngs Date: Wed, 23 Jun 2021 12:09:54 +1000 Subject: [PATCH] New Script -- run-parts A script to use with cron / systemd-timers. It runs all executables in a directory. * usr/bin/run-parts: New. Signed-off-by: Steve Youngs --- usr/bin/run-parts | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 usr/bin/run-parts diff --git a/usr/bin/run-parts b/usr/bin/run-parts new file mode 100755 index 0000000..53e6134 --- /dev/null +++ b/usr/bin/run-parts @@ -0,0 +1,52 @@ +#!/bin/bash +# Copyright © 2021 Steve Youngs. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +# Author: Steve Youngs +# Maintainer: Steve Youngs +# Created: <2021-06-23> +# Time-stamp: +# Homepage: https://git.sxemacs.org/pkgusr +# Keywords: pkgusr package-management tools + +## This file is part of pkgusr + +### Commentary: +# +# Runs all the executable scripts found in a directory, but not +# "backup" files (*.bak, *.orig, *.new, *.rej, *~) +# +# This script is based on the one that Pat Volkerding ships with +# Slackware. + +# keep going when something fails +set +e + +if [ $# -lt 1 ]; then + echo "Usage: run-parts " + exit 1 +fi + +if [ ! -d $1 ]; then + echo "Not a directory: $1" + echo "Usage: run-parts " + exit 1 +fi + +# Main loop: +for SCRIPT in $1/* ; do + # Skip backup, non-regular, non-executable files + if [[ "$SCRIPT" =~ ^.*(~|#|\.(bak|orig|new|rej))$ || + ! -f $SCRIPT || ! -x $SCRIPT ]]; then + continue + fi + # Run what makes it this far. + $SCRIPT || echo "$SCRIPT failed." +done + +exit 0 + +### run-parts ends here +# Local variables: +# coding: utf-8 +# end: -- 2.25.1