Hello all,
I am having a bit of difficulty with a stop script for an ASE service.  I am
a debutante when it comes to scripting so please be patient.  The script
which works really well at the command line is as follows:
Thanks for any help in advance...
# Define Variables
# set -x
VERSION=1.0
SERVICE=$1
OPERATION=$3
BUNDLE=$2
HOST=`hostname -s`
CHANGE_BUNDLE=/users/local/operator/bin/start_change_bundle_nsm1
LOG_DIR=/var/adm/syslog
LOG=/var/adm/syslog/${SERVICE}_${3}.log
SEPLOG=/var/adm/syslog/SEP_${SERVICE}_${3}.log
SPID1=`ps -e | grep /soft/${SERVICE} | grep -v grep | sed -e 's/^ *//' -e
's/ .*//'`
SPID2=`ps -e | grep /user/${SERVICE} | grep -v grep | sed -e 's/^ *//' -e
's/ .*//'`
/sbin/chmod a+w /dev/console
# trace with a creation first 
echo "" > /dev/console
# Save the old logfile
mv ${LOG} ${LOG}"-1" 3> /dev/null
echo `date` "${SERVICE} (${2}): Creation of the log file" > ${LOG}
echo `date` "${SERVICE} (${2}): version ${VERSION}  - copyright 2001-2030
NagraVision" >> ${LOG}
echo `date` "${SERVICE} (${2}): version ${VERSION}  - copyright 2001-2030
NagraVision" > /dev/console
echo `date` "${SERVICE} (${2}): Create the log file: ${LOG}" > /dev/console
#####################################################################
#                       FUNCTIONS
#####################################################################
#
# Function: kill_all_process_(rep) 
#
# This function kills all the processes, This part is very important to
unmount a file system.
#
#####################################################################
kill_all_process_user()   
{       
        [ "X$SPID1" != "X" ] && kill -15 $SPID1 && sleep 15 && kill -9
$SPID1
}
kill_all_process_soft()   
{       
        [ "X$SPID2" != "X" ] && kill -15 $SPID2 && sleep 15 && kill -9
$SPID2
}
###################################################################
#                           MEAT
###################################################################
#
#  Running start/stop command processes.  If none present echo command
#  line options
#
# Check if all the executable program are installed
###################################################################
case $3 in
'start')
        echo `date` "${SERVICE} (${3}): inserting Y into active field of
watchdog.dat file for ${SERVICE}"  >/dev/console
        echo `date` "+++++++++++++++++++++++++++++++++++++++++++++++"
>>${LOG}
        echo `date` "${SERVICE} (${3}): starting up"         >> ${LOG}
        
        `${CHANGE_BUNDLE} ${HOST} ${SERVICE} ${BUNDLE} 1 > ${SEPLOG} 2>&1`
        ;;
'stop')
        echo `date` "${SERVICE} (${3}): inserting N into active field of
watchdog.dat file for ${SERVICE}"  >/dev/console
        echo `date` "${SERVICE} (${3}): stopping ${SERVICE}" >/dev/console
        echo `date` "-------------------------------------------- --" >>
${LOG}
        echo `date` "${SERVICE} (${3}): shutting down" >> ${LOG}
   `${CHANGE_BUNDLE} ${HOST} ${SERVICE} ${BUNDLE} 0 > ${SEPLOG} 2>&1`
        kill_all_process_user > /tmp/kill.log 2>&1
        kill_all_process_soft > /dev/kill2.log 2>&1
        ;;
*)
        echo "usage is: service_ac ${SERVICE} ${BUNDLE} {start|stop}" >
/dev/console
        exit 1
        ;;
esac
#
exit 0
Received on Fri Dec 21 2001 - 09:36:56 NZDT