run-parts: add --list option
Signed-off-by: Marcela Mašláňová <mmaslano@redhat.com>
This commit is contained in:
parent
520e3c1458
commit
ed54c10f6f
25
run-parts
25
run-parts
@ -5,10 +5,28 @@
|
|||||||
set +e
|
set +e
|
||||||
|
|
||||||
if [ $# -lt 1 ]; then
|
if [ $# -lt 1 ]; then
|
||||||
echo "Usage: run-parts <dir>"
|
echo "Usage: run-parts [--list] <dir>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
if [ ! -d $1 ]; then
|
||||||
echo "Not a directory: $1"
|
echo "Not a directory: $1"
|
||||||
exit 1
|
exit 1
|
||||||
@ -39,6 +57,10 @@ for i in $(LC_ALL=C; echo $1/*[^~,]) ; do
|
|||||||
if [ -r $1/whitelist ]; then
|
if [ -r $1/whitelist ]; then
|
||||||
grep -q "^$(basename $i)$" $1/whitelist && continue
|
grep -q "^$(basename $i)$" $1/whitelist && continue
|
||||||
fi
|
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)"
|
logger -p cron.notice -t "run-parts($1)[$$]" "starting $(basename $i)"
|
||||||
$i 2>&1 | awk -v "progname=$i" \
|
$i 2>&1 | awk -v "progname=$i" \
|
||||||
'progname {
|
'progname {
|
||||||
@ -48,6 +70,7 @@ for i in $(LC_ALL=C; echo $1/*[^~,]) ; do
|
|||||||
{ print; }'
|
{ 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
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user