[crontabs] run-parts: add --list option

Marcela Mašláňová mmaslano at fedoraproject.org
Mon Oct 18 09:56:09 UTC 2010


commit ed54c10f6f1083987d841b005da0cb8deeaff29b
Author: Petr Lautrbach <plautrba at redhat.com>
Date:   Mon Oct 18 11:51:12 2010 +0200

    run-parts: add --list option
    
    Signed-off-by: Marcela Mašláňová <mmaslano at redhat.com>

 run-parts |   31 +++++++++++++++++++++++++++----
 1 files changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/run-parts b/run-parts
index 6ab6f11..6b047a4 100755
--- a/run-parts
+++ b/run-parts
@@ -5,10 +5,28 @@
 set +e
 
 if [ $# -lt 1 ]; then
-	echo "Usage: run-parts <dir>"
+	echo "Usage: run-parts [--list] <dir>"
 	exit 1
 fi
 
+while [ $# -gt 1 ]; do
+	case $1 in
+		--list)
+			list=1
+			shift
+			;;
+		--)
+			# -- end of options
+			shift
+			break
+			;;
+		*)
+			# directory
+			break
+			;;
+	esac
+done
+
 if [ ! -d $1 ]; then
 	echo "Not a directory: $1"
 	exit 1
@@ -39,14 +57,19 @@ for i in $(LC_ALL=C; echo $1/*[^~,]) ; do
 		if [ -r $1/whitelist ]; then
 			grep -q "^$(basename $i)$" $1/whitelist && continue
 		fi
-		logger -p cron.notice -t "run-parts($1)[$$]" "starting $(basename $i)"
-		$i 2>&1 | awk -v "progname=$i" \
+		# list executable files in directory
+		if [ ${list:-0} != 0 ]; then
+			echo $i;
+		else # run executable files
+			logger -p cron.notice -t "run-parts($1)[$$]" "starting $(basename $i)"
+			$i 2>&1 | awk -v "progname=$i" \
 			      'progname {
 				   print progname ":\n"
 				   progname="";
 			       }
 			       { print; }'
-		logger -i -p cron.notice -t "run-parts($1)" "finished $(basename $i)"
+			logger -i -p cron.notice -t "run-parts($1)" "finished $(basename $i)"
+		fi
 	fi
 done
 


More information about the scm-commits mailing list