[Asterisk-Users] vserver (Debian) - no tty: howto use /usr/sbin/safe_asterisk with "-c" for color CLI?

Robert Michel news at robertmichel.de
Sat Jul 8 09:19:36 MST 2006


Salve Tzafrir!

On Sat, 08 Jul 2006, Tzafrir Cohen wrote:

> >  But you are right, there are options for root at guest
> >  to work around. My skripting skills are not so high
> >  and my try would be better inside the asterisk scripts
> >  for shure - but I'm looking for a solution that is
> >  indepentend of the task - finaly it should be
> >  a skript/demon that request a pseudo terminal
> >  and link this to a fix /dev/tty$n ($n choosen by
> >  root at guest). 
> >  The most perfect solution would be maybe, when
> >  this pseudotty process take care that his "device"
> >  exist and if not, that it is created again.
> > 
> >  ############################################
> >  Howto creat a /dev/tty9 on a vserver without
> >  the right to use mknode,
> >  proposed by news at robertmichel.de 2006.07.07
> >  ############################################
> > 
> >  Create two files:
> >     /dev/init.d/pseudo-tty9
> >     #!/usr/bin/expect -f
> >     # Some software likes to have an own terminal
> >     # but no function to request a pseudo terminal.
> >     # On some vservers exist no or not enough 
> >     # tty devices, and root at guest does not have the
> >     # power to create some with mknode.
> >     # The idea of this script is to run a bash
> >     # as the user asterisk and detach it.
> >     #
> >     # expect "#" and "$" are part of the promt ;)2006
> >     # 2006.07.07 by news at RobertMichel.de
> > 
> >     spawn dtach -A /tmp/pseudoterm.socket.9 -e a bash
> >     expect "#" { send "/etc/init.d/pseudo-tty9-ln.sh\r" }
> >     expect "#" { send "su - asterisk\r" } 
> >     expect "$" { send "a" }
> >     #EOF
> > 
> >  And:
> >     /etc/init.d/pseudo-tty9-ln.sh
> >     #!/bin/bash
> > 
> >     ln -sf $(tty) /dev/tty9
> >     #EOF
> > 
> >  and run then:
> >      update-rc.d -n pseudotty9 defaults
> >  as well as:
> >      /dev/init.d/pseudo-tty9
> 
> And what happens when your current ssh session terminates and the sshd
> destoys its current pty? Will asterisk just hang?

ps:
root     16333     1  0   403  368   0 Jul07 ?        00:00:00 dtach -A
/tmp/pseudoterm.socket.9 -e a bash
root     16334 16333  0  1516 1236   0 Jul07 pts/43   00:00:00  \_ bash


root     30470 15809  0  1518 1568   0 Jul07 pts/39   00:00:00  \_
/bin/bash
root     25570 30470  0  1174 1696   0 16:38 pts/39   00:00:00  |   \_
rasterisk asterisk -crvvvvvv


root     25555     1  0  1152 1172   0 16:38 pts/39   00:00:00 /bin/bash
-x /usr/sbin/safe_asterisk -g -vvv -U asterisk
asterisk 25557 25555  0  4331 8412   0 16:38 pts/39   00:00:00  \_
/usr/sbin/asterisk -g -vvv -U asterisk -vvvgc
[...]

ls -lh /dev/
lrwxrwxrwx  1 root root 11 2006-07-07 23:16 /dev/tty9 -> /dev/pts/43


PID 30470 and its childs are part of my ssh session.
I now close screen and ssh and relogin again.


root     16333     1  0   403  368   0 Jul07 ?        00:00:00 dtach -A
/tmp/pseudoterm.socket.9 -e a bash
root     16334 16333  0  1516 1236   0 Jul07 pts/43   00:00:00  \_ bash


root     25555     1  0  1152 1172   0 16:38 ?        00:00:00 /bin/bash
-x /usr/sbin/safe_asterisk -g -vvv -U asterisk
asterisk 25557 25555  0  4522 8372   0 16:38 ?        00:00:00  \_
/usr/sbin/asterisk -g -vvv -U asterisk -vvvgc
[...]


And now I use asterisk -crvvv

root     16333     1  0   403  368   0 Jul07 ?        00:00:00 dtach -A
/tmp/pseudoterm.socket.9 -e a bash
root     16334 16333  0  1516 1236   0 Jul07 pts/43   00:00:00  \_ bash


root     25555     1  0  1152 1172   0 16:38 ?        00:00:00 /bin/bash
-x /usr/sbin/safe_asterisk -g -vvv -U asterisk
asterisk 25557 25555  0  4522 8372   0 16:38 ?        00:00:00  \_
/usr/sbin/asterisk -g -vvv -U asterisk -vvvgc


root      7472  7471  0  1517 2696   0 18:02 ?        00:00:00
\_ SCREEN
root      7894  7472  0  1518 2692   0 18:04 pts/14   00:00:00
\_ /bin/bash
root      8051  7894  0  1174 1692   0 18:05 pts/14   00:00:00
|   \_ rasterisk asterisk -crvvv


No, it willnot hang up.
 
> If you want to create your own independent terminal device, use screen.

dtach offers just the dtach feature of screen and AFAIunderstand:
with or without screen detaching is necessary to be independend
from ssh. (see man dtach)
I didn't know a tool or trick that work inside a skript
without user action, so I use 'expect' to do this.
(see man expect)

Ok, maybe it is an ugly hack, but it is independent from
an asterisk or vserver modification. ;)

> Also, creating a process that gives a full shell access without asking
> too many questions is probably not the best idea.

Why? What is the weak point compared with a normal server with
a non faked /dev/tty9?

OKOK, your are right, colors are not soooo important,
but nice and very helpfull ;)

Greetings,
rob



More information about the asterisk-users mailing list