SUMMARY: Shutdown script

From: Chuck Yerkes (cyerkes@jpmorgan.com)
Date: Mon Apr 05 1993 - 00:45:55 CDT


I was so good. I summarized within 14 hours, to the wrong address.
Oy!

Okay. The orig question (at tail) had to do with shutdown
running a script just before halting (or whatever) the machine.

Many people responded with "rename shutdown and have the
script run it". Not enough. I want the functionality
of shutdown (rwall's, countdowns, etc).

Other people responded with "Run shutdown in a cronjob
after the script". I want the future admins here not to
have to change shutdown habits, they must be able to type
shutdown -r +5 "EVERYONE OFF" and have it behave like
a normal shutdown.

Other people (Wayne Schmidt was the first) suggested some
tricks (what I was seeking).

His idea follows (titles "WAYNE'S SCRIPT"). He wins second
prize (a can of self-obtained Cheese-Wiz/Brie Flavored).

First prize goes to Daniel Trinkle (trinkle@cs.purdue.edu) for
the following that he wrote (probably before my question:

> If you want, you can grab /pub/trinkle/shutdown.tar.Z from
> ftp.cs.purdue.edu. It is a shutdown that allows you to control the
> actions of shutdown with configuration scripts. It also allows
> non-root users to shut down the system if they are in a control list
> and they know their login password (verification of identity).
>
> With this version you could probably easily do what you want.
>
> Daniel Trinkle trinkle@cs.purdue.edu

Thanks go to:
 wayne@internet.sbi.com (Wayne Schmidt)
 louis@andataco.com
 scheller@c3ot.saic.com (Mark J. Scheller)
 emccaff@pica.army.mil PICA.ARMY.MIL (Ennis W. McCaffrey )
 davidl@Newbridge.COM (David Law)
 receda@chj401.SINet.SLB.COM (Wilson Receda)
 trinkle@cs.purdue.edu (Daniel Trinkle)
 matt@wbst845e.xerox.com (Matt Goheen)
 Joseph C. Konczal <konczal@mail-gw.ncsl.nist.gov>
 laugh@life.dal.mcd.mot.com (Annette D. Smith)
 mdl@cypress.com (J. Matt Landrum)
 mce@sdcc10.UCSD.EDU (Mark Edwards)

And others who sent in later that I got rid of because the
solutions were not what I needed and I thought I had summarized
already.

chuck
-------------------------------------------
WAYNE'S SCRIPT

sure you'll want to rewrite the shutdown process, but don't, IMHO, rewrite
shutdown. Have a wrapper script that does the following:

1) calls shutdown -k ( fakes out the users )
2) then something as simple as doing the following.

#!/bin/sh
RCDIR = "/usr/local/etc/shutdown"
LIST = "sybase optical bwnfs tops <INSERT_HERE>"
for ELEMENT in $LIST
do
        if ( test -f $RCDIR/KILLS.$ELEMENT ) then
                if ( test -x $RCDIR/KILLS.$ELEMENT ) then
                                $RCDIR/KILLS.$ELEMENT
                else
                    echo "PROBLEMS %% no kill script:"
                    echo "-----------------------------------"
                    $RCDIR/KILLS.$ELEMENT
                    echo "-----------------------------------"
                fi
        else
            echo "PROBLEMS %% no execute permission:"
            echo "-----------------------------------"
            $RCDIR/KILLS.$ELEMENT
            echo "-----------------------------------"
        fi
done
                

3) when everything external is shutdown then either use
        shutdown or fasthalt or whatever strikes your fancy.

----------------------------------------------
Original Message:
> Subject: Modifying shutdown.
>
> The machine: SPARC ][ with 4.1.2.
>
> Problem:
> We have a number of machines that are running various odd processes.
> When they crash, we go through some manual recovery (check optical disk
> states, DBMS stuff, etc).
> When we reboot a machine (controlled), we'd like to do some things
> before the halt happens (make sure that Sybase is down, and unmount
> optical disks, etc).
>
> Shutdown sends a SIGTERM (-15) to all the processes, but there is
> often not enough time to do some of the things we'd like. We use
> "shutdown" to send messages out to the users and give use some time.
>
> What we'd like:
> We'd like to have shutdown run and wait for a script before shutting
> down. I could rewrite shutdown, but it already does quite a bit that
> we want (annoying users with notices, locking out logins, etc). Right
> now I use "shutdown -k" (fake a shutdown), followed by running a script
> to do that voodoo that I need to do, followed by a "reboot". I'd like
> to be able to do these at 5AM and don't want to have to be here.
>
> Any thoughts?
>
> chuck yerkes



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:07:41 CDT