#!/bin/sh # # functions This file contains functions to be used by most or all # shell scripts in the /etc/init.d directory. # # Version: @(#) /etc/init.d/functions 1.01 26-Oct-1993 # # Author: Miquel van Smoorenburg, # Hacked by: Greg Galloway and Marc Ewing # Hacked more: Vanilla Development Team # # First set up a default search path. export PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin" # A function to start a program and a specified user daemon_user() { # Test syntax. gotbase= case $1 in '') echo '$0: Usage: daemon_user [+/-nicelevel] {user} {program}' return 1;; --check) shift base=$1 gotbase="yes" shift nicelevel=0 ;; -*|+*) nicelevel=$2 shift;; *) nicelevel=0;; esac # Save basename. [ -z $gotbase ] && base=`basename $2` # See if it's already running. pid=`pidofproc $base` [ -n "$pid" ] && ps h $pid >/dev/null 2>&1 && return # make sure it doesn't core dump anywhere; while this could mask # problems with the daemon, it also closes some security problems ulimit -c 0 # Echo daemon [ "$BOOTUP" = "verbose" ] && echo -n " $base" # And start it up. nice -n $nicelevel initlog $INITLOG_ARGS -c "su -c '$2' - $1" && success "$base startup" || failure "$base startup" } # A function to start a program. run_as() { # Test syntax. gotbase= case $1 in '') echo '$0: Usage: run_as [+/-nicelevel] {user} {program}' return 1;; --check) shift base=$1 gotbase="yes" shift nicelevel=0 ;; -*|+*) nicelevel=$1 shift;; *) nicelevel=0;; esac # make sure it doesn't core dump anywhere; while this could mask # problems with the daemon, it also closes some security problems ulimit -c 0 # And start it up. nice -n $nicelevel initlog $INITLOG_ARGS -c "su -c '$2' - '$1'" }