[CentOS] Assistance with startup script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Could someone give me some assistance in getting this startup script to conform to chkconfig and such where the service will start up after networking comes up, and then shut down when networking goes away? Where all do entries need to be made, and what would they consist of?

Many thanks.....

Sam
------------------------------------------------------------------------

#! /bin/sh
export PATH=/bin:/usr/bin


LDMHOME=/usr/local/ldm
LDMBIN=$LDMHOME/bin
LDMADMIN=$LDMBIN/ldmadmin
PQCHECK=$LDMBIN/pqcheck
PQCAT=$LDMBIN/pqcat
PQ=$LDMHOME/data/ldm.pq
LOG="logger -p local0.err $0:"

case "$1" in

start)
   $LOG 'Starting LDM system...'
   if [ -x $LDMADMIN ] ; then
   if su - ldm -c "$LDMADMIN isrunning"; then
           $LOG "LDM system is already running."
   else
       if [ ! -f $PQ ] ; then
       $LOG "Product-queue doesn't exist.  Creating..."
       if ! su - ldm -c "$LDMADMIN mkqueue"; then
           $LOG "Aborting..."
           exit 1
       fi
       else
       #
       # Test the product-queue for corruption.
       #
       if ! $PQCHECK -l /dev/null -q $PQ; then
           case $? in
           1)  $LOG "System error checking product-queue.  Aborting..."
           exit 1
           ;;
           2)  $LOG "Adding writer-counter to product-queue..."
           if ! $PQCHECK -F -q $PQ; then
               $LOG "Aborting..."
               exit 1
           fi
           ;;
           3)  $LOG "Product-queue was incorrectly closed.  " \
               "Checking..."
           if $PQCAT -s -l /dev/null; then
               $LOG "Product-queue appears OK. "
               $LOG "Clearing writer-counter..."
               if ! $PQCHECK -F -q $PQ; then
               $LOG "Couldn't clear counter.  Aborting..."
               exit 1
               fi
           else
               $LOG "Product-queue appears corrupt.  Deleting."
               rm $PQ
               if ! su - ldm -c "$LDMADMIN mkqueue -f"; then
               $LOG "Couldn't make new product-queue.  Aborting..."
               exit 1
               fi
           fi
           ;;
           4)  $LOG "Product-queue is corrupt.  Deleting."
           rm $PQ
           if ! su - ldm -c "$LDMADMIN mkqueue -f"; then
               $LOG "Couldn't make new product-queue.  Aborting..."
               exit 1
           fi
           ;;
           esac
       fi
       fi
       su - ldm -c "$LDMADMIN clean"
       su - ldm -c "$LDMADMIN start"
   fi
   fi
   ;;

stop)
   $LOG 'Stopping the LDM system.'
   if [ -x $LDMADMIN ] ; then
       su - ldm -c "$LDMADMIN stop"
   fi
   ;;

esac

--
Sam W.Drinkard -- sam@xxxxxxxxxx
WEB http://wa4phy.net
Augusta Mesonet
cell 706.825.8513 Home 706.868.7253
MAIL 4438 Branchwood Drive,
Martinez Georgia, 30907-1304

begin:vcard
fn:Sam W Drinkard
n:Drinkard;Sam W
org:National Weather Service;Augusta Area Mesonet
adr:;;4428 Branchwood Drive;Martinez;GA;30907-1304;USA
email;internet:sam@xxxxxxxxxx
title:Cooperative Weather Observer
tel;home:706-868-7253
tel;cell:706-825-8513
x-mozilla-html:TRUE
url:http://wa4phy.net
version:2.1
end:vcard

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux