# common customizations and tasks for init scripts that manage
# services to run under svscan

# How to get the service name from the path the initscript was called at.
# For example, how to get svscan from /etc/rc.d/init.d/S50svscan.init
SERVICE=$(basename $0 .init)

# location of daemontools binaries
UCSPI_TCP_BIN=/usr/local/bin

# location of the rlc-* scripts of the runlevelconf package
RUNLEVELCONF_BIN=/command

# current runlevel	
RUNLEVEL=$(/sbin/runlevel | cut -d' ' -f2)                       
#RUNLEVEL=$(who -r|awk '{ print $3 }')   # this works on solaris 

# Location of service and service log directories# 	
VARSERVICEROOT=/var/service

# service specific tcprules `cdb' file. Do not leave out
# $SERVICE
CDB=$VARSERVICEROOT/$SERVICE/tcprules.cdb

# Location of svscan's run file		
SVSCANCONF=/var/service/svscan

# runlevelconf's directory
RUNLEVELCONF=/var/service/runlevelconf

# location of this file, dt function files,
# dt-color and dt-service.init
DTRUNCONF=/var/service/dt-run

# PATH containing basic system utilities
# such as grep, egrep, sed, awk.
PATH=/command:/command:/bin:/usr/bin:/usr/sbin

# Max seconds to wait for a service to stop
MAX_STOP=120

# Max seconds to wait for a service to start
MAX_START=120

#############End config################

# svscan's directory; not customizable anymore because
# we use svscanboot 
SERVICEROOT=/service

PATH=$UCSPI_TCP_BIN:$RUNLEVELCONF_BIN:$PATH
export PATH SERVICEROOT 


if [ -f $DTRUNCONF/dt-color.functions ]; then
    . $DTRUNCONF/dt-color.functions
else
    echo "$(basename $0): cannot find  dt-color.functions."
    exit 1
fi

isup() {
    svstat $1 | grep -q ": up (pid"
}

isdown() {
    svstat $1 | grep -q ": down"
}
