[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: terminals - tty



On Wed, 2001-11-21 at 15:37, madhombre wrote:
> I was wondering if there was anyway of running commands on different ternimals on startup
> 
> I use my debian laptop to as a client and also to monitor my 2
> servers, can I auto ssh into the servers on tty2 and tty3, maybe even
> do shutdown command on all three 
> (order has to be correct!)

I'm not sure what you mean my order has to be correct but you should be
able to run any command you want on any terminal you want by changing
your /etc/inittab file.  Changing for example:

default inittab portion:

1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6

New inittab portion:

1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:once:ssh server1
6:23:once:ssh server2

Should spawn a ssh on tty5 and tty6 once each boot (assuming you boot
into level 2 or 3, or just put boot instead of once if neccessary) to
your servers on those terminals.  Man inittab is quite usefull to read. 
 
I'm unclear on what you mean by do shutdown command on all three.  Set
up passwordless logins for ssh (ssh-keygen -t rsa and copy the
id_rsa.pub to your servers authorized_keys2).  

You could create a script from the /etc/init.d/skeleton as a template in
the /etc/init.d directory that is run at runlevels 0 and 6 

that essentially runs
ssh server1 shutdown -h now
ssh server2 shutdown -h now

then insert it into your notebook's rc scripts with:
update-rc.d yourscript stop 05 0 6

the 05 is to make sure it's run before the firewalling is changed or
networking is taken down etc.  I'm not sure this is a good idea to kill
your servers every time the laptop reboots but it's what you asked for.

--mike



Reply to: