How does "shutdown" in Solaris 2.6 notify users of impending shutdown?

2007-12-25 11:39:00

Ok.. Boy what a FLOOD of mail from people!!! (see the "thanks" area

below). This is my final summary and I've got a good handle on my

stupid script mistake, etc..

Basically, most people initially said that I should be using the

scripted version of shutdown (the SYSV version, not the /usr/ucb

version). As it turned out, that is what I was using, but when I

quoted which version I was using, I wasn't logged on as root. Also, a

number of people reported my script mistake which was to remove the

"-x" (see comment on first bullet below) which indicates that the "if"

statement is a compound-if statement -- my mistake! I'm far from a

shell guru! Also, a number of people indicated that the "stock"

behavior under CDE is that nobody gets notified.. While this is true,

it is an easy fix by just adding the "-a" to the wall command in the

notify routine within /usr/sbin/shutdown (or /etc/shutdown on older

Solaris?). I believe that once this is done, CDE users will receive

the same messages that openwindow users normally do (according to some

of the mail I received!).

I'm also enclosing the smbwall script that I referred to since at

least one person was interested and perhaps others might find it

interesting. Keep in mind that I was thinking that I had tweaked the

smbwall script from its original condition, but upon checking a minute

ago, I found that I changed very little (ok, almost none!) from the

stock version supplied with Samba (see ~/examples/misc/wall.perl in

any Samba tar file).

#!/usr/local/bin/perl

#

#@(#) smb-wall.pl Description:

#@(#) A perl script which allows you to announce whatever you choose to

#@(#) every PC client currently connected to a Samba Server...

#@(#) ...using "smbclient -M" message to winpopup service.

#@(#) Default usage is to message every connected PC.

#@(#) Alternate usage is to message every pc on the argument list.

#@(#) Hacked up by Keith Farrar <farrar@parc.xerox.com>

#

# Cleanup and corrections by

# Michal Jaegermann <michal@ellpspace.math.ualberta.ca>

# Message to send can be now also fed (quietly) from stdin; a pipe will do.

#=============================================================================

$smbstatus = "/usr/local/samba/bin/smbstatus";

$smbshout = "/usr/local/samba/bin/smbclient -d 3 -M";

if (@ARGV) {

    @clients = @ARGV;

    undef @ARGV;

}

else { # no clients specified explicitly

    open(PCLIST, "$smbstatus |") || die "$smbstatus failed!.\n$!\n";

    while(<PCLIST>) {

        last if /^Locked files:/;

        split(' ', $_, 6);

        # do not accept this line if less then six fields

        next unless $_[5];

        # if you have A LOT of clients you may speed things up by

        # checking pid - no need to look further if this pid was already

        # seen; left as an exercise :-)

        $client = $_[4];

        print "\n",$client;

# next unless $client =~ /^\w+\./; # expect 'dot' in a client name

        next if grep($_ eq $client, @clients); # we want this name once

        push(@clients, $client);

    }

    close(PCLIST);

}

if (-t) {

    print <<'EOT';

Enter message for Samba clients of this host

(terminated with single '.' or end of file):

EOT

    while (<>) {

        last if /^\.$/;

        push(@message, $_);

    }

}

else { # keep quiet and read message from stdin

    @message = <>;

}

foreach(@clients) {

    print "To $_:\n";

    if (open(SENDMSG,"|$smbshout $_")) {

        print SENDMSG @message;

        close(SENDMSG);

    }

    else {

        warn "Cannot notify $_ with $smbshout:\n$!\n";

    }

}

exit 0;

==============================================================

Many thanks to the following people :

Alan Orndorff

Brooke King

Charles Nguyen

D'Arcey L Carroll

David Evans

David L. Markowitz

Deiter Gobbers

Eugene Kramer

Francis Liu

Harvey Wamboldt

John Horne

Kevin Sheehan

Lee Trujillo

Leif Erickson

Mark Neill

Ramindur Singh

Raymond Wong

Rodney C. Marable

Roger Fujii

Ronald Loftin

Sabrina Downard

Sean Quaint

Sebastian Benoit

Thomas Leitner

Thomas Lester

Thomas Lewis

Tim Pointing

W. Holzmann

Wales Wong

Rick Flower writes:

>

> Ok.. I fudged up and should've waited a bit longer before posting my

> summary.. I got ahead of myself! Anyway, I've found my problem with

> CDE users not being able to get broadcast messages IF they do not have

> a "console" window open. As it turns out, there were a few problems

> with the stock version of /usr/sbin/shutdown (which is what I was

> using and hadn't particularly checked -- as opposed to the "binary"

> ucb version). The changes I made are outlined below :

>

> o Changed the "notify" routine in /usr/sbin/shutdown to only

> use the "-a" argument to /usr/sbin/showmount and tossed out

> the illegal "-x" it was also using (I'm not sure what the -x

> did or WHY it was there!).

>

> o Changed the "notify" routine in /usr/sbin/shutdown to add

> the "-a" argument to the call for /usr/sbin/wall to ensure

> that we also get coverage to the PTY's (that gets the CDE

> people!)

>

> o Added a call to my smbwall script for Samba clients to ensure

> that all Samba users (non-interactive) are aware of system

> shutdowns.

Comments

Got something to say?

You must be logged in to post a comment.