You are not logged in.

#1 2006-03-26 02:54:20

McQueen
Member
From: Arizona
Registered: 2006-03-20
Posts: 382

Modify a Script To Not Run at Shutdown?

Using the archstats script listed below, how could I alter the script so that it only runs the $ARCHSTATS_CMD command during boot but not when shutting down? I see that is handled by the 'stop)' section, but I am unclear how to properly remove this portion and still have the script operate as desired.

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

# NOTE: If you use an alternate location for your archstats.conf file,
# make sure to set that accordingly with the -c switch
#


# Set this to the 'archstats' client path
#
ARCHSTATS_CMD='/usr/bin/archstats'

case "$1" in
    start)
        stat_busy "Updating ArchStats"
        if [ -x "$ARCHSTATS_CMD" ]; then
            "$ARCHSTATS_CMD" -u
            stat_done
        else
            stat_fail
        fi
    ;;
    stop)
        stat_busy "Updating ArchStats"
        if [ -x "$ARCHSTATS_CMD" ]; then
            "$ARCHSTATS_CMD" -u
            stat_done
        else
            stat_fail
        fi
    ;;
    *)
        echo "usage: $0 {start|stop}"
    ;;
esac
exit 0

/path/to/Truth

Offline

#2 2006-03-26 03:15:36

stingray
Member
From: Lima, Peru SA
Registered: 2006-03-24
Posts: 188

Re: Modify a Script To Not Run at Shutdown?

I would guess this, just remark out the "stop" code. Just add "#" to the start of a line to remark it out, so it does not run.

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

# NOTE: If you use an alternate location for your archstats.conf file,
# make sure to set that accordingly with the -c switch
#


# Set this to the 'archstats' client path
#
ARCHSTATS_CMD='/usr/bin/archstats'

case "$1" in
    start)
        stat_busy "Updating ArchStats"
        if [ -x "$ARCHSTATS_CMD" ]; then
            "$ARCHSTATS_CMD" -u
            stat_done
        else
            stat_fail
        fi
    ;;
    stop)
#        stat_busy "Updating ArchStats"
#        if [ -x "$ARCHSTATS_CMD" ]; then
#            "$ARCHSTATS_CMD" -u
#            stat_done
#        else
#            stat_fail
#        fi
    ;;
    *)
        echo "usage: $0 {start|stop}"
    ;;
esac
exit 0

Offline

#3 2006-03-26 11:30:39

_Gandalf_
Member
Registered: 2006-01-12
Posts: 735

Re: Modify a Script To Not Run at Shutdown?

stingray, You can't have an empty command, like u can't use
if [ .. ]; then
fi

You have to use
if [ ... ]; then
  /bin/true
fi

therefore, it must be

#!/bin/bash 

. /etc/rc.conf 
. /etc/rc.d/functions 

# NOTE: If you use an alternate location for your archstats.conf file, 
# make sure to set that accordingly with the -c switch 
# 


# Set this to the 'archstats' client path 
# 
ARCHSTATS_CMD='/usr/bin/archstats' 

case "$1" in 
   start) 
      stat_busy "Updating ArchStats" 
      if [ -x "$ARCHSTATS_CMD" ]; then 
         "$ARCHSTATS_CMD" -u 
         stat_done 
      else 
         stat_fail 
      fi 
   ;; 
   stop)
     /bin/true
   ;; 
   *) 
      echo "usage: $0 {start|stop}" 
   ;; 
esac 
exit 0

Offline

#4 2006-03-26 13:59:09

McQueen
Member
From: Arizona
Registered: 2006-03-20
Posts: 382

Re: Modify a Script To Not Run at Shutdown?

Great, thanks for the help.


/path/to/Truth

Offline

#5 2006-03-26 14:18:59

stingray
Member
From: Lima, Peru SA
Registered: 2006-03-24
Posts: 188

Re: Modify a Script To Not Run at Shutdown?

Ok, that makes sense. I've got some experience programming, but bran new to Linux.  Working through some of that learning curve.  Thanks!

Offline

#6 2006-03-26 15:39:22

_Gandalf_
Member
Registered: 2006-01-12
Posts: 735

Re: Modify a Script To Not Run at Shutdown?

Np fellas smile

Offline

Board footer

Powered by FluxBB