Startup/shutdown script to startup/shutdown entire network ?

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

I've got one Ubuntu computer with a monitor, and a few others that are "headless".

Normally I go through and shutdown the headless systems via SSH before shutting down the main system, but this is a bit of a hassle.

Any suggestions for a script I can run when I shut this system down that will go through and shut all of the other systems down first, and when I start this system up will start the other systems up after this one starts ?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • kc0tma
  • o|||||||o
  • Web Master
  • User avatar
  • Posts: 3318
  • Loc: Trout Creek, MT

Post 3+ Months Ago

Do your headless horsemen have wake on lan?

To shut them down, you could ssh root@192.168.1.5 init 0 which is the same as ssh'ing and then typing the command only in a one-liner, but I'm not sure how that would handle requiring the root password to be typed in if it were scripted.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

WOL, yes. I haven't figured out how to use that yet. I tried once.
  • Daemonguy
  • Moderator
  • Web Master
  • User avatar
  • Posts: 2700
  • Loc: Somewhere outside the box in Sarasota, FL.

Post 3+ Months Ago

I have always been a big fan of dssh; though the version we use is a wrapper around dsadm to DirStore... but I did find this;
http://pvid.net/w/index.php?title=DSSH&redirect=no

Which is available.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

Alright here's where I am now.

I've got all systems setup so that I can login with my usual account via SSH from my main system without a password using ssh-keygen which comes in handy anyways.

Using visudo to edit /etc/sudoers I've granted my usual account permission to run shutdown via sudo without a password.

Code: [ Select ]
username ALL=NOPASSWD: /sbin/shutdown


With that setup I can use a one-liner to shutdown the remote systems via SSH.

Code: [ Select ]
me@computer:~$ ssh me@192.168.1.101 'sudo shutdown -h 0'
me@computer:~$
  1. me@computer:~$ ssh me@192.168.1.101 'sudo shutdown -h 0'
  2. me@computer:~$


Now I've fiddled with update-rc.d but I don't quite understand how to write the actual script to be executed in /etc/init.d/ and haven't gotten it to work or log any obvious messages.

An alternative I'm considering if I can't get this to work is to setup a crontab for root on each of the systems that uses nmap every 15 minutes to see if the main system is online, and shut itself down if it goes two consecutive checks without seeing the main system online.
  • Daemonguy
  • Moderator
  • Web Master
  • User avatar
  • Posts: 2700
  • Loc: Somewhere outside the box in Sarasota, FL.

Post 3+ Months Ago

I still thin you should look into dssh.

As an example I can do the same to 100 nodes, geographically dispersed across several continents;

dssh -N WEB.CUST.PROD sudo shutdown -h now

The -N is a flag that is used (in our case) as a tag which itself defines a subset of nodes. The one above offers something similar.
Then of course the WEB.CUST.PROD is the name of the subset list. Every node in the subset list would then have me log in, sudo my request of shutdown -h now.

Seems easy enough to me.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

That does look pretty easy. :D
I'm guessing I still need to setup each of the systems to let a user shut them down without any passwords if I want to automate the task at shutdown.

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 67 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.