Discussion:
[Asterisk-Users] vserver (Debian) - no tty: howto use /usr/sbin/safe_asterisk with "-c" for color CLI?
Robert Michel
2006-07-04 15:10:35 UTC
Permalink
Salve *!

I'm using asterisk for a while and now I want to have a colord CLI.
I have apt-get install asterisk/testing, that is asterisk 1.2.7.1

I use Debian stable/testing on a vserver with any /dev/tty*.
So, of course, I comment out "#TTY=9" inside /usr/sbin/safe_asterisk.

/etc/init.d/asterisk start
calls
/usr/sbin/safe_asterisk

root 5757 1 0 1149 1348 0 16:08 pts/30 00:00:00 /bin/sh/usr/sbin/safe_asterisk -g -vvv -U asterisk
asterisk 5758 5757 0 4502 7992 0 16:08 pts/30 00:00:00 \_/usr/sbin/asterisk -g -vvv -U asterisk


When I start asterisk by hand with "asterisk -cgvvv"
I got a colored CLI ;)

but inside /usr/sbin/safe_asterisk (started by
/etc/init.d/asterisk - with "-U asterisk")
or inside /etc/init.d/asterisk itself all my tries
to use "-c" as additional parameter faild. ;(

E.g. I changed line 52 inside etc/init.d/asterisk
PARAMS="$PARAMS -U $USER"
PARAMS="$PARAMS -c -U $USER"


This does run the CLI with color :)
also with color for asterisk -rcvvv

*but* there is an fast running repeating output
after running /etc/init.d/asterisk start

Use EXIT or QUIT to exit the asterisk console
Use EXIT or QUIT to exit the asterisk console
Use EXIT or QUIT to exit the asterisk console
[...]


The handycap of vserver is, that as ***@guest you can't creat devices
yourself. I think asterisk is also reading from /dev/tty9, so a
ls -s /dev/null /dev/tty9 does not help (tested).

Does somebody have an idea how to deal with this?
Can I run asterisk with color CLI without a TTY*?

Greetings,
rob
Tzafrir Cohen
2006-07-04 16:05:46 UTC
Permalink
Post by Robert Michel
Salve *!
I'm using asterisk for a while and now I want to have a colord CLI.
I have apt-get install asterisk/testing, that is asterisk 1.2.7.1
I use Debian stable/testing on a vserver with any /dev/tty*.
So, of course, I comment out "#TTY=9" inside /usr/sbin/safe_asterisk.
safe_asterisk has a flawed logic: it assumes that the tty device will
always exist. Thus it is not suited for use with screen.

However wouldn't it be better to tell asterisk to have colors even in a
remote terminal unless you use -n?

See attached patch for a possible route. I don't remember if I tested
it, though.
--
Tzafrir Cohen sip:***@local.xorcom.com
icq#16849755 iax:***@local.xorcom.com
+972-50-7952406
***@xorcom.com http://www.xorcom.com
Robert Michel
2006-07-08 10:34:42 UTC
Permalink
Salve Tzafrir, *!

Thank you for your kindly (and good) support. :)

I found a solution for me to get a colored CLI on a
vserver, but to publish it for other *-users,
I feel it must be smarter ;)
Post by Tzafrir Cohen
safe_asterisk has a flawed logic: it assumes that the tty device will
always exist. Thus it is not suited for use with screen.
However wouldn't it be better to tell asterisk to have colors even in a
remote terminal unless you use -n?
On the longterm this is interesting, thank you for the patch,
I will test it in the next time...
But I do have a more general aim, to find a solution to
to cope with the restriction of vserver that ***@guest
can't create new terminals with mknode.

I personaly could life with an asterisk patch, or manualy
solution that works only until the next crash - but I'm
keen to find and promote a solution that would also help
vserver usersers in other cases and that would be working
without the support of ***@host, the vserver provider.

***@guest := root of one vserver (guest)
***@host := root/admin of the sytem that serve the
different vserver instances


On the vserer mailinglist I do also have a discussion
with Herbert Poetzl (vsever developer) and I wrote
to that list:

Well I like the "one task, one tool" philosophy,
or just the slogan "Devide et impera!" So I'm not
happy with the need to modificate asterisk scripts
or binary to run on a vserver.... remember in May
someone ask here on the list for the power to
create a fix terminal to use with perl.

But you are right, there are options for ***@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
***@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 ***@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 ***@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 ***@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

############################################


I seems to work, but it is not smart to have
2 files, and no automaticaly restory in case
something crash.
- what would be smarter then run a bash?


Maybe some others here on the list does have
ideas and tips ;)


This workaround is running on my vserver and I
personal did not need any help - but again, I'm
keen to find a smart solution in general for
this topic and I think my solution is not
smart engough to give it away for others how
to cope with the restriction of vserers. ;)

I will go on playing with expect, how to merge it
into one script and how to insert it into safe_asterisk.
And if I don't find the trick will ask other mailinglists
e.g. debian-users - BUT when someone of you like this
topic and find a smart solution - I would be happy
about feedback :)


BTW: vserver - when you have the power to be ***@host
than linux-vserver.org worse IMHO look for you, too:

Herbert gave the hint on vserver mailinglist that
there is a "project which uses Linux-VServer to isolate
several asterisk instances on a single host":
"Virtual Private Asterisk (VPA"):
http://www.telephreak.org/papers/vpa/


And beside the interesst of security or to have more
instances on a single host, I think vserver could help
you to move one asterisk installation to another machine,
or testing on the same machine - one extension could
become the gateway to the test system ;)

--8<--
[2]Linux-VServer-Paper-08
08. Field of Application

The primary goal of this project is to create virtual servers sharing
the same machine. A virtual server operates like a normal Linux
server. It runs normal services such as telnet, mail servers, web
servers, and SQL servers.
08.0. Administrative Separation [...]
08.1. Service Separation [...]
08.2. Enhancing Security [...]
08.3. Easy Maintenance

One key feature of a virtual server is the independence from the
actual hardware. Most hardware issues are irrelevant for a virtual
server installation.

The main server acts as a host and takes care of all the details. The
virtual server is just a client and ignores all the details. As such,
the client can be moved to another physical server with very few
manipulations.

For example, to move the virtual server from one physical computer to
another, it sufficient to do the following:
* shutdown the running server
* copy it over to the other machine
* copy the configuration
* start the virtual server on the new machine

No adjustments to user setup, password database or hardware
configuration are required, as long as both machines are binary
compatible.

08.4. Fail-over Scenarios

Pushing the limit a little further, replication technology could be
used to keep an up-to-the-minute copy of the filesystem of a running
Virtual Server. This would permit a very fast fail-over if the running
server goes offline for whatever reason.

All the known methods to accomplish this, starting with network
replication via rsync, or drbd, via network devices, or shared disk
arrays, to distributed filesystems, can be utilized to reduce the
down-time and improve overall efficiency.

08.5. For Testing [...]
-->8--
2. http://linux-vserver.org/?action=find&find=Linux-VServer-Paper-08
And of course: http://linux-vserver.org/


Have a nice weekend,
rob





PS: Thanks to the guy who had run his autorespond
"I'm out of the office" against this mailinglist.
I think this is the reason why I missed some mails
and had to ask my friend to forward me some, to get
the right sender ID for answering...
Tzafrir Cohen
2006-07-08 11:55:13 UTC
Permalink
Post by Robert Michel
Salve Tzafrir, *!
Thank you for your kindly (and good) support. :)
I found a solution for me to get a colored CLI on a
vserver, but to publish it for other *-users,
I feel it must be smarter ;)
Post by Tzafrir Cohen
safe_asterisk has a flawed logic: it assumes that the tty device will
always exist. Thus it is not suited for use with screen.
However wouldn't it be better to tell asterisk to have colors even in a
remote terminal unless you use -n?
On the longterm this is interesting, thank you for the patch,
I will test it in the next time...
But I do have a more general aim, to find a solution to
can't create new terminals with mknode.
I personaly could life with an asterisk patch, or manualy
solution that works only until the next crash - but I'm
keen to find and promote a solution that would also help
vserver usersers in other cases and that would be working
different vserver instances
On the vserer mailinglist I do also have a discussion
Well I like the "one task, one tool" philosophy,
or just the slogan "Devide et impera!" So I'm not
happy with the need to modificate asterisk scripts
or binary to run on a vserver.... remember in May
someone ask here on the list for the power to
create a fix terminal to use with perl.
Right. Don't use safe_asterisk . asterisk daemonises just fine on its
own. asterisk -r gives you a nice console. If you want a complete trace,
you have the logs at your disposal: take a visit at logger.conf.
Post by Robert Michel
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
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,
############################################
/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
# 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
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
/etc/init.d/pseudo-tty9-ln.sh
#!/bin/bash
ln -sf $(tty) /dev/tty9
#EOF
update-rc.d -n pseudotty9 defaults
/dev/init.d/pseudo-tty9
############################################
I seems to work, but it is not smart to have
2 files, and no automaticaly restory in case
something crash.
- what would be smarter then run a bash?
Maybe some others here on the list does have
ideas and tips ;)
You've just added quite a few more points of failure to Asterisk and
complicated thinhgs even further. Why bother using safe_sterisk?
--
Tzafrir Cohen sip:***@local.xorcom.com
icq#16849755 iax:***@local.xorcom.com
+972-50-7952406
***@xorcom.com http://www.xorcom.com
Robert Michel
2006-07-08 14:10:54 UTC
Permalink
Salve Tzafrir!
Post by Tzafrir Cohen
Right. Don't use safe_asterisk . asterisk daemonises just fine on its
own. asterisk -r gives you a nice console. If you want a complete trace,
you have the logs at your disposal: take a visit at logger.conf.
AFAIK will safe_asterik restart automaticaly asteriks when asterik will crash.
Wrong?
Post by Tzafrir Cohen
You've just added quite a few more points of failure to Asterisk and
complicated thinhgs even further.
Well, I must agree - that's the wrong way.
When I and other test that patch and it is working,
will it become part of standard asterisk?
Post by Tzafrir Cohen
Why bother using safe_sterisk?
Has been safe_asterik sinificant reason for trouble?
(Sorry when I'm new and missed discussion about it)

Greetings,
rob
Tzafrir Cohen
2006-07-08 15:18:36 UTC
Permalink
Post by Robert Michel
Salve Tzafrir!
Post by Tzafrir Cohen
Right. Don't use safe_asterisk . asterisk daemonises just fine on its
own. asterisk -r gives you a nice console. If you want a complete trace,
you have the logs at your disposal: take a visit at logger.conf.
AFAIK will safe_asterik restart automaticaly asteriks when asterik will crash.
Wrong?
Post by Tzafrir Cohen
You've just added quite a few more points of failure to Asterisk and
complicated thinhgs even further.
Well, I must agree - that's the wrong way.
When I and other test that patch and it is working,
will it become part of standard asterisk?
Are colors that important to you? It shouldn't be complicated to get it
working. I'll have a look.
Post by Robert Michel
Post by Tzafrir Cohen
Why bother using safe_sterisk?
Has been safe_asterik sinificant reason for trouble?
(Sorry when I'm new and missed discussion about it)
Extra layer of complication. And a non-optimal handling of errors. It
can just too easily get asterisk into a loop where it remains
non-functional but impossible to kill with standard scripts.
--
Tzafrir Cohen sip:***@local.xorcom.com
icq#16849755 iax:***@local.xorcom.com
+972-50-7952406
***@xorcom.com http://www.xorcom.com
Martin Joseph
2006-07-08 16:25:00 UTC
Permalink
<snip>
Are colors that important to you? It shouldn't be complicated to get it
working. I'll have a look.
<snip>

Actually I have noticed that the color console is major cpu eater,
versus the monochrome one...

I use both screen and ssh to remotely keep a console open...

Marty

PS Man, I am getting an education from Tzafrir... Although my head
hurts a bit.
Robert Michel
2006-07-08 16:34:42 UTC
Permalink
Salve Martin!
<snip>
Are colors that important to you? It shouldn't be complicated to get it
working. I'll have a look.
<snip>
Actually I have noticed that the color console is major cpu eater,
versus the monochrome one...
Good point.

Even when no other "asterisk -crvvv" is conected?
In case yes, would be an idea that the master asterisk
fall back to monochrome if there is no connection,
or even better, that the demon is very time monochrome
and only "asterisk -crvvv" creates the colored highlighting?
PS Man, I am getting an education from Tzafrir... Although my head
hurts a bit.
**g**

Greetings,
rob
Robert Michel
2006-07-08 16:42:45 UTC
Permalink
Salve Martin!
Post by Robert Michel
Post by Martin Joseph
Actually I have noticed that the color console is major cpu eater,
versus the monochrome one...
Good point.
Even when no other "asterisk -crvvv" is conected?
In case yes, would be an idea that the master asterisk
fall back to monochrome if there is no connection,
or even better, that the demon is very time monochrome
and only "asterisk -crvvv" creates the colored highlighting?
In this case:
IMHO best solution would be to have it as CLI comand, too:
CLI> color (on|of)
Post by Robert Michel
Post by Martin Joseph
PS Man, I am getting an education from Tzafrir... Although my head
hurts a bit.
**g**
I forgot you to ask: You don't feel yourself enlightened now?
;)

Cheers,
rob

Tzafrir Cohen
2006-07-08 15:12:40 UTC
Permalink
Post by Robert Michel
Salve Tzafrir, *!
Thank you for your kindly (and good) support. :)
I found a solution for me to get a colored CLI on a
vserver, but to publish it for other *-users,
I feel it must be smarter ;)
Post by Tzafrir Cohen
safe_asterisk has a flawed logic: it assumes that the tty device will
always exist. Thus it is not suited for use with screen.
However wouldn't it be better to tell asterisk to have colors even in a
remote terminal unless you use -n?
On the longterm this is interesting, thank you for the patch,
I will test it in the next time...
But I do have a more general aim, to find a solution to
can't create new terminals with mknode.
I personaly could life with an asterisk patch, or manualy
solution that works only until the next crash - but I'm
keen to find and promote a solution that would also help
vserver usersers in other cases and that would be working
different vserver instances
On the vserer mailinglist I do also have a discussion
Well I like the "one task, one tool" philosophy,
or just the slogan "Devide et impera!" So I'm not
happy with the need to modificate asterisk scripts
or binary to run on a vserver.... remember in May
someone ask here on the list for the power to
create a fix terminal to use with perl.
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
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,
############################################
/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
# 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
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
/etc/init.d/pseudo-tty9-ln.sh
#!/bin/bash
ln -sf $(tty) /dev/tty9
#EOF
update-rc.d -n pseudotty9 defaults
/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?

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

If you want to create your own independent terminal device, use screen.
--
Tzafrir Cohen sip:***@local.xorcom.com
icq#16849755 iax:***@local.xorcom.com
+972-50-7952406
***@xorcom.com http://www.xorcom.com
Robert Michel
2006-07-08 16:19:36 UTC
Permalink
This post might be inappropriate. Click to display it.
Tzafrir Cohen
2006-07-08 15:16:00 UTC
Permalink
This post might be inappropriate. Click to display it.
Loading...