Link to home
Start Free TrialLog in
Avatar of djc2
djc2

asked on

KDE: need a customized shutdown script for kdm

I'm using kde 1.1.1 and running kdm. I want to customize the shutdown and reboot options that appear as button items from kdm. I see that I can choose different commands using kdmconfig.

This is my problem: my lab computer also runs Windows95 (a problem in and of itself, of course!) with which a lab colleague of mine does some analysis. The computer runs linux at all times except when he uses it to run Windows. Sometimes, I am using the computer remotely from my office at the same that he needs to reboot into Windows. I've instructed him to always call me first before rebooting out of kdm, but he consistently forgets, which boots me off the system in the middle of doing something. I realize I could just disable shutdown and reboot so that he couldn't do this, but that's not what I want. I want him to be able to reboot, but not if someone (i.e., me) is logged on. What's the best way to do this? The only way I can think of is to link shutdown to some script which runs "who" or something like that to see if someone is logged on, and if so, disallow him to reboot (in which case he gets on the phone, calls me, and we arrange something). I don't know how to write such a script. So, could someone either provide a nice, clean script, or alternatively a better solution? Ideally, the script would pop up a console window or something telling him who's logged on if it can't reboot.
Thanks!
Dave
Avatar of jlevie
jlevie

I've always had a problem with folks who conviently "consistantly forget" to do the right thing. If it were me I'd take away his privs to shutdown or reboot the box for a while (and threaten him with serious mayhem if he touches the power switch). You might find that his memory improves drastically afterwards.

It can be a bit tricky to properly wrap the normal shutdown process in a script and have it do the right thing. I'd need to experiment a bit to make sure it would work, but I can think of a couple of ways to do it.
Greetings.

Offhand, I can think of two alternatives:

o) Tweak the scripts that are run before shutdown.(On redhat, that would be /etc/rc.d/init.d/halt, among others)

o)PAM can provide some way of doing what you're after, if it doesn't already.

I'd have to work on the mechanics of both - and none of them will orevent him from pulling the power cord, hit the off button, or other similarly radical actions. So the physical intimidation jlevie suggests may be the way to go.

CHeers,
    alf
Avatar of djc2

ASKER

In theory I agree with the proposal of
taking away his shutdown privileges, and I certainly have a problem with him consistently forgetting. But, there's not much I can do: the
problem is that he uses the computer for
important experiments that have
to happen at a certain time, and if he
doesn't have shutdown privileges and he
can't track me down, he'll have no choice but to do a hard reboot. So, taking away his privileges is not a viable option.

What I had in mind was more in the line
of tweaking the scripts, but I wouldn't
have much of a clue how to do it.

-Dave
I'd like to propose a compromise solution that doesn't require major surgery to the normal system installation. However it does require a different method of invoking the shutdown and thus may or may not be acceptable.

The difference in the process is that it would have to be done on a command line login to the console. It's easy enough to get to, just do ctrl-alt-F1. He'd then have to log in and execute my script, which will check for any users other than root and his login. To cover the case of it being required to reboot, even when there are looged on users, the script can ask for confirmation before proceeding. That would be preferable to just hitting the reset.

Avatar of djc2

ASKER

jlevie, I think your script is what I'm looking for. But one thing I would prefer is for it to be usable from kdm. Using kdmconfig, I could easily redirect reboot and shutdown from the normal scripts to a modified script such as yours. Is there then a way for the scripts interaction to take place in the console window that can (somehow, but I don't know how) appear on the bottom right of the kdm login screen?
I'll see, but there are problems in trying to do this sort of thing from a X session. Mostly because one of the first things that happens is that the shutdown kills X, which in turn makes the controlling tty for the script disappear, which in turn creates error handling problems. Like I said, it can be tricky.
Avatar of djc2

ASKER

jlevie,
      If your console window script
is functional, I'd like to have that. Tell you what, I'll give you the 150 points for that, and then if you feel like coming up with something that can work straight from kdm, I could give you more points for that when you get it working. Thanks!
-Dave
I'll have the console tool for you this weekend. I've had a few work-related network emergencies over the last few days and have had precious little time to spare.
ASKER CERTIFIED SOLUTION
Avatar of jlevie
jlevie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of djc2

ASKER

Jim,
      It works great! Thanks a ton!
Dave