Koozali.org: home of the SME Server

the opposite of rc.local?

E-MaN_

the opposite of rc.local?
« on: August 30, 2006, 11:16:21 AM »
I'm looking for the correct place to be able to notify windows users that the server is going down or reboot.

In rc.local I've put a line: echo server is up! | smbclient  -M winboxes

Now I would like to have somewhere:
echo server is going down/reboot in xx seconds, please logoff | smbclient -M winboxes

I couldn't find this anywhere in the forums.

Offline smeghead

  • *
  • 563
  • +0/-0
the opposite of rc.local?
« Reply #1 on: August 30, 2006, 01:40:50 PM »
Write your own script called say, down.sh, that controls this:


#!/bin/bash

SHUTDOWNDELAY=1
DELAY=$[$1-$SHUTDOWNDELAY]

echo Server is going down in $N minutes please save your work and log off! | smbclient -M winboxes
sleep "$DELAY"m
echo Warning:  only 1 minute left before server reboots! | smbclient -M winboxes
shutdown -k +$SHUTDOWNDELAY

exit 0

Put this into a script in say /usr/local (which is on the path) and use this to manage the shutdown (don't forget to make it executable)

Call it with:

down.sh 5
..................

E-MaN_

the opposite of rc.local?
« Reply #2 on: August 30, 2006, 03:59:43 PM »
Ok. Great!

And what if I would make that automatic?

Is there a place I could create/replace the template to reboot, so if I'm booting it from the server-panel it will run that part?

Offline smeghead

  • *
  • 563
  • +0/-0
the opposite of rc.local?
« Reply #3 on: August 30, 2006, 05:40:55 PM »
The 'action/event' that is attached to the panel button is not templated and would require hacking to acheive what you want, could be done but would not be recommended.
..................

E-MaN_

the opposite of rc.local?
« Reply #4 on: August 30, 2006, 11:39:59 PM »
ok then. I can't just add een template to achieve what I want.
I'll stick with your solution then.

Thank you.

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
the opposite of rc.local?
« Reply #5 on: August 31, 2006, 04:07:42 AM »
Quote from: "smeghead"
The 'action/event' that is attached to the panel button is not templated and would require hacking to acheive what you want...


That is incorrect.

OP should create a notification script. Add a symlink to that script into /etc/e-smith/events/halt and /etc/e-smith/events/reboot.

Nothing else needs to be done. No existing scripts need to be hacked. No additional ways to trigger a shutdown or reboot need to be created.

Offline smeghead

  • *
  • 563
  • +0/-0
the opposite of rc.local?
« Reply #6 on: August 31, 2006, 05:37:40 AM »
Sweet, hadn't thought of doing it that way.

Just goes to show that Charlies intimate knowledge of the innner workings has its benefits.
..................

E-MaN_

the opposite of rc.local?
« Reply #7 on: August 31, 2006, 09:50:20 AM »
That's great! Thank you Charly.
I knew it should be easy ;)

I'll implement both suggestions.