aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xrc.d/init.d/functions27
1 files changed, 20 insertions, 7 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions
index 3dfde002..bd8c3eb8 100755
--- a/rc.d/init.d/functions
+++ b/rc.d/init.d/functions
@@ -53,7 +53,10 @@ fi
daemon() {
# Test syntax.
gotbase=
- case $1 in
+ user=
+ nicelevel=0
+ while [ "$1" != "${1##-}" -o "$1" != "${1##+}" ]; do
+ case $1 in
'') echo '$0: Usage: daemon [+/-nicelevel] {program}'
return 1;;
--check)
@@ -61,13 +64,19 @@ daemon() {
base=$1
gotbase="yes"
shift
- nicelevel=0
;;
-
+ --user)
+ shift
+ daemon_user=$1
+ shift
+ ;;
-*|+*) nicelevel=$1
- shift;;
- *) nicelevel=0;;
- esac
+ shift
+ ;;
+ *) nicelevel=0
+ ;;
+ esac
+ done
# Save basename.
[ -z $gotbase ] && base=`basename $1`
@@ -84,7 +93,11 @@ daemon() {
[ "$BOOTUP" = "verbose" ] && echo -n " $base"
# And start it up.
- nice -n $nicelevel initlog $INITLOG_ARGS -c "$*" && success "$base startup" || failure "$base startup"
+ if [ -z "$daemon_user" ]; then
+ nice -n $nicelevel initlog $INITLOG_ARGS -c "$*" && success "$base startup" || failure "$base startup"
+ else
+ nice -n $nicelevel initlog $INITLOG_ARGS -c "su $daemon_user -c \"$*\"" && success "$base startup" || failure "$base startup"
+ fi
}
# A function to stop a program.