aboutsummaryrefslogtreecommitdiffstats
path: root/rc.d/init.d/functions
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2000-01-21 03:25:02 +0000
committerBill Nottingham <notting@redhat.com>2000-01-21 03:25:02 +0000
commit2f9439e3df69681302ce1d6707f5034db8ecf002 (patch)
tree9d7ff90b0ff6d9b23effd94cf9d1ca9378f35421 /rc.d/init.d/functions
parent91eebcef71afd5b6039f43f8cdc76f71449640d5 (diff)
downloadinitscripts-2f9439e3df69681302ce1d6707f5034db8ecf002.tar
initscripts-2f9439e3df69681302ce1d6707f5034db8ecf002.tar.gz
initscripts-2f9439e3df69681302ce1d6707f5034db8ecf002.tar.bz2
initscripts-2f9439e3df69681302ce1d6707f5034db8ecf002.tar.xz
initscripts-2f9439e3df69681302ce1d6707f5034db8ecf002.zip
add --user option to daemon
Diffstat (limited to 'rc.d/init.d/functions')
-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.