(OPPS, I mean to send this to the list last night.) Hello:
Thanks. >> Anyway, I would like to have the system confirm a shutdown or reboot >> before actually doing it. >Why? >And who will be allowed to initiate a shutdown that way? >Without knowing that, it's hard to suggest a sane approach. I was just thinking about the possibility of having more than one SSH session open, and mistakenly shutting down the wrong one. I agree that this should be unlikely to occur, but I wanted to see if I could devise a simply second step to help prevent it. >> I could do something like rename the shutdown/reboot/halt commands, >Do not fiddle with system commands, you are asking for trouble. Yep, I was thinking the same thing. Hence, the rc.shutdown question. >>[...] >> seems like the cleanest solution would be to run a script >> from rc.shutdown to ask for conformation. >>[...] >> What am I missing? >When init(8) is in the middle of dying, > fork(2) & execl(3) & waitpid(2) /bin/sh /etc/rc shutdown >is the very last thing it does before starting to kill off its >remaining children, i.e. all remaining userland processes. >At that point during init(8)'s death, most userland processes >are already dead, including all getty(8) terminal sessions, >so no user is logged in any more. I am not so sure about this. It appears that rc.shutdown is the first thing to run (if something is there) during the shutdown/halt/reboot process. This is based on empirical observations. For example, I make a simple script: #!/bin/sh Echo blah Sleep 10 Put this somewhere, point to it from /etc/rc.shutdown and enter "halt" from a SSH session. On the SSH terminal, nothing happens, but the connection is not immediately dropped either. If I go over and look and the console, I see: "/ect/rc.shutdown in progress ... blah" And then, 10 seconds later: "/etc/rc.shutdown complete." At that point, the ssh connection is dropped, and the machine goes down. Now, if I do this again from the ssh terminal, but this time, after entering "halt," but within 10 seconds, enter "ctrl-C" in the SSH terminal, I get a shell prompt back, and the machine does not go down (the ssh connection stays up). On the console, the same messages appear, including the "rc.shutdown complete," but the rest of the shutdown process is aborted (the system stays up). If I modify the script to include "echo blah > /dev/ttyp0" (or whatever the user is connected to), then, when I enter "halt" the "/etc/rc.shutdown in progress" and "rc.shutdown complete" still go to the console, but "blah" comes up in the ssh terminal window. So, it seems to me that rc.shutdown could be used in this way, as long as I could reliably figure out a way to redirect input/output to whatever terminal was used to start the shutdown process. I can think of a pretty messy way to do this by parsing through the output of ps, but thought there must be a better way. Thanks Bye - ted PS: I am the only useless staff here.