]> git.pld-linux.org Git - projects/rc-scripts.git/blobdiff - run-parts
- some formatting, respect to use functios (RETVAL variable vs exit calls)
[projects/rc-scripts.git] / run-parts
index 70ed7d4bfe76da6b873aea6a48878db1a52f88cf..8b473a599fafb6ea0dac8725efa484797bcb759a 100755 (executable)
--- a/run-parts
+++ b/run-parts
 # keep going when something fails
 set +e
 
-if [ "$1" = "-u" ]; then
-       workasuser=yes
+if [ "$1" = "--test" ]; then
+       test=yes
+       shift
+fi
+
+if [ "$1" = "--" ]; then
        shift
 fi
 
 # std checks
 if [ $# -lt 1 ]; then
-       echo "Usage: run-parts [-u] <dir> <args...>"
+       echo "Usage: run-parts [-u] [--test] <dir> <args...>"
        exit 1
 fi
 
 if [ ! -d $1 ]; then
        echo "Is not a directory: $1"
-       echo "Usage: run-parts [-u] <dir> <args...>"
+       echo "Usage: run-parts [-u] [--test] <dir> <args...>"
        exit 1
 fi
 
@@ -36,9 +40,9 @@ fi
 RUNPARTS_DIR=$1
 
 # assign absolute dir name
-olddir=`pwd`
+olddir=$(pwd)
 cd $RUNPARTS_DIR
-RUNPARTS_ADIR=`pwd`
+RUNPARTS_ADIR=$(pwd)
 cd $olddir
 unset olddir
 
@@ -60,10 +64,9 @@ for i in $RUNPARTS_DIR/*[!~,] ; do
 
        if [ -x "$i" ]; then
                runprog="$i $@"
-               if [ "$workasuser" = "yes" ]; then
-                       runuser="$(/bin/ls -l "$i" | awk ' { print $3 } ' 2> /dev/null)"
-                       [ -z "$runuser" ] && echo "Warning: Can't find owner for [$i] file. Not running." && continue
-                       runprog="/bin/su $runuser -s /bin/sh -c $runprog"
+               if [ "$test" = yes ]; then
+                       echo "$runprog"
+                       continue
                fi
                $runprog 2>&1 | awk -v "progname=$i" \
                        'progname {
@@ -75,6 +78,3 @@ for i in $RUNPARTS_DIR/*[!~,] ; do
 done
 
 exit 0
-
-# This must be last line !
-# vi:syntax=sh
This page took 0.411376 seconds and 4 git commands to generate.