run-parts: add --list option

Signed-off-by: Marcela Mašláňová <mmaslano@redhat.com>
This commit is contained in:
Petr Lautrbach 2010-10-18 11:51:12 +02:00 committed by Marcela Mašláňová
parent 520e3c1458
commit ed54c10f6f

View File

@ -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,6 +57,10 @@ for i in $(LC_ALL=C; echo $1/*[^~,]) ; do
if [ -r $1/whitelist ]; then
grep -q "^$(basename $i)$" $1/whitelist && continue
fi
# 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 {
@ -48,6 +70,7 @@ for i in $(LC_ALL=C; echo $1/*[^~,]) ; do
{ print; }'
logger -i -p cron.notice -t "run-parts($1)" "finished $(basename $i)"
fi
fi
done
exit 0