OpenWrt Forum Archive

Topic: Asterisk on OpenWRT

The content of this topic has been archived between 31 Mar 2018 and 1 Apr 2018. Unfortunately there are posts – most likely complete pages – missing.

I'd like to start a thread dedicated to the Asterisk package.

I have written an improved startup script (as /etc/init.d/S60asterisk) in order to fix three problems present in the current releases found by http://nthill.free.fr/openwrt/tracker/p … e=Asterisk :

1. The "registry" file astdb is located on flash (in /usr/lib/asterisk). Being this file re-written often, the flash chip can be worn out. My startup script, when called with argument "start", moves it to a RAM-based partition (/var/spool/asterisk) and puts in place a symbolic link; when called with "stop" it saves it back to its original place.

2. Asterisk runs as root, which is definitely not_good for a server with exposure to the big bad Internet. As "su" is unavailable on OpenWRT, my script chmod's +s the executable and changes its owner to "asterisk.asterisk" (also libraries, config files etc. are chown'd to the same user, but only if at least one of them is owned by root: this avoids unnecessary directory updates unless the user creates a new file there and forgets to chown it "asterisk.asterisk"). If such user or group do not exist, appropriate entries are created in /etc/passwd and /etc/group with UID and GID both equal to 5060. If such UID or GID are already taken by other users, the script terminates with an error message and the user has to fix it manually.

3.  In many installations (such as mine :-) ) Asterisk runs on machines with a dynamically assigned IP address. Starting Asterisk before the establishment of the connection to the Internet seems to create problems, even if Asterisk binds to 0.0.0.0 rather than the external interface. So, I have put in place a loop that delays the startup until a default route is defined (it checks every 2 seconds for 0.0.0.0 in the output of "route"). This gives pppd the time to connect to the Internet (generally through PPPoE).

The script follows; bug reports are welcome.

Enzo

#!/bin/sh

DEFAULT=/etc/default/asterisk
OPTIONS=""
[ -f $DEFAULT ] && . $DEFAULT
[ "$ENABLE_ASTERISK" = "yes" ] || exit 0

# do a "chown -R" only if some file in the dir is owned by root
cond_chown_r() { # user file-or-dir
  MATCHLIST=$(ls -ld $2 | grep 'root')
  MATCHLIST=$MATCHLIST$(ls -l $2 | grep 'root')
  if [ ! -z "$MATCHLIST" ] ; then 
    chown -R $1 $2
    echo chown -R $1 $2
  fi
}

# replace symlinks to /rom/... with actual copies
deromize() {
  if [ -L $1 ] ; then
    POINTEDFILE="$(ls -l /etc/group |  cut -d '>' -f 2-)"
    rm $1
    cp $POINTEDFILE $1
  fi
}

case $1 in
 start)
  [ -d /var/run ] || mkdir -p /var/run
  [ -d /var/log/asterisk ] || mkdir -p /var/log/asterisk
  [ -d /var/spool/asterisk ] || mkdir -p /var/spool/asterisk

  deromize /etc/group
  # create the group "asterisk", unless already there
  if [ -z "$(grep '^asterisk:' /etc/group)" ] ; then
    MATCHING="$(grep ':5060:' /etc/group)"
    if [ -z "$MATCHING" ] ; then
      echo "asterisk:x:5060:" >> /etc/group
    else
      echo "** error in ${0} - GID 5060 already in use by others:"
      echo $MATCHING
      exit 1
    fi
  fi
  
  deromize /etc/passwd
  # create the user "asterisk", unless already there
  if [ -z "$(grep '^asterisk:' /etc/passwd)" ] ; then
    MATCHING="$(grep ':5060:' /etc/passwd)"
    if [ -z "$MATCHING" ] ; then 
      echo "asterisk:*:5060:5060:asterisk:/tmp:/bin/ash" >> /etc/passwd 
    else
      echo "** error in ${0} - UID 5060 already in use by others:"
      echo $MATCHING
      exit 1
    fi
  fi
  # change ownership of all relevant directories      
  cond_chown_r asterisk.asterisk /var/log/asterisk
  cond_chown_r asterisk.asterisk /var/spool/asterisk
  cond_chown_r asterisk.asterisk /etc/asterisk
  cond_chown_r asterisk.asterisk /usr/lib/asterisk
  cond_chown_r asterisk.asterisk /usr/sbin/asterisk
  # make the binary suid, so it won't run as root 
  chmod +s /usr/sbin/asterisk
  
  while [ -z "$(route | grep '0\.0\.0\.0')" ] ; do 
    echo "waiting for default route to exist..."
    logger -p user.info "waiting for default route to exist..Æ?."
    sleep 2
  done
  
  if [ -f /usr/lib/asterisk/astdb ] ; then
    mv /usr/lib/asterisk/astdb /var/spool/asterisk/astdb
    ln -s /var/spool/asterisk/astdb /usr/lib/asterisk/astdb
  fi
  
  /usr/sbin/asterisk $OPTIONS
  ;;
 stop)
 
  [ -f /var/run/asterisk.pid ] && kill $(cat /var/run/asterisk.pid) >/dev/null 2>&1

  if [ -L /usr/lib/asterisk/astdb ] ; then
    rm /usr/lib/asterisk/astdb
  fi
  if [ -f /var/spool/asterisk/astdb ] ; then
    mv -f /var/spool/asterisk/astdb /usr/lib/asterisk/astdb 
  fi
  ;;
 *)
  echo "usage: $0 (start|stop)"
  exit 1
esac

exit $?

(Last edited by enzo on 23 Sep 2005, 07:05)

Hi Enzo,

Enzo wrote:

1. The "registry" file astdb is located on flash (in /usr/lib/asterisk). Being this file re-written often, the flash chip can be won out. My startup script, when called with argument "start", moves it to a RAM-based partition (/var/spool/asterisk) and puts in place a symbolic link; when called with "stop" it saves it back to its original place.

The startup script are not (yet) called on shutdown / reboot. Does it really matters if the file is created from scratch at every startup ? i.e. Can we patch asterisk to find it in /var/spool/asterisk (on tmpfs) instead ?

--
Nico

Nico wrote:

Hi Enzo,

Enzo wrote:

1. The "registry" file astdb is located on flash (in /usr/lib/asterisk). Being this file re-written often, the flash chip can be won out. My startup script, when called with argument "start", moves it to a RAM-based partition (/var/spool/asterisk) and puts in place a symbolic link; when called with "stop" it saves it back to its original place.

The startup script are not (yet) called on shutdown / reboot. Does it really matters if the file is created from scratch at every startup ? i.e. Can we patch asterisk to find it in /var/spool/asterisk (on tmpfs) instead ?

--
Nico

I'm not very familiar with Asterisk (yet) but I've read that astdb is meant as non-volatile repository, much like the Windows Registry. I would recommend to add to the shutdown / reboot procedures provisions for calling an equivalent of /etc/init.d/rcS with "start" replaced by "stop" and a $(ls -r ...) to reverse the order of execution:

#!/bin/sh

# Stop all init scripts in /etc/init.d
# executing them in reverse numerical order.
#
for i in $(ls -r /etc/init.d/S??*) ;do

     # Ignore dangling symlinks (if any).
     [ ! -f "$i" ] && continue

     case "$i" in
        *.sh)
            # Source shell script for speed.
            (
                trap - INT QUIT TSTP
                set stop
                . $i
            )
            ;;
        *)
            # No sh extension, so fork subprocess.
            $i stop
            ;;
    esac
done

Meanwhile, the administrator should remember to issue a "/etc/init/d/S60asterisk stop" before shutdown or anyway after being aware of important modifications to astdb.

Enzo

Is there any gsm06.10-to-raw executable already packaged for OpenWRT? Something like Sox or even simpler, like Jutta's old "toast". If not, I'll try to write one using libgsm, which is available in .ipk form .

My application is a replacement for MP3 in music-on-hold generation, along the lines of http://www.voip-info.org/wiki-Asterisk+mpg123+faking+it . OpenWRT doesn't have a lot of memory, and MP3 is unnecessarily wasteful: a u-Law compander would take half space, much less CPU power, and the quality would be toll-grade anyway... GSM 06.10 is not very suitable to music, but filtering the band aggressively before the encoding (and choosing the right music) there are almost no artifacts, and the quality is not too bad; and it takes only 96.5 Kb of file space per minute of audio...  Skeptics may want to try e.g. https://em.no-ip.com/bwv846lg.wav (1'58", 180 Kb).   

Enzo

enzo wrote:

Is there any gsm06.10-to-raw executable already packaged for OpenWRT? Something like Sox or even simpler, like Jutta's old "toast". If not, I'll try to write one using libgsm, which is available in .ipk form .

OK, I hacked together a mipsel binary for toast statically linked with the GSM library code (Nico may consider adding a port of the Debian "libgsm-tools" to his existing port of "libgsm" and "libgsm-dev"). For obscure reasons, I couldn't manage to use the "custom mode" method ("Option 2" at http://www.voip-info.org/wiki-Asterisk+ … faking+it) so I had to fall back on the "mpg123 spoofing" ("Option 1" in the same page), which is less clean and flexible but at least it has the advantage of working for me ;-)

So, I placed a file called "bwv846ql.gsm.mp3" (yes, it must end in ".mp3" although it's GSM-encoded) in /usr/lib/asterisk/mohmp3, and I created a /usr/bin/mpg123 shell script containing:

#!/bin/sh
# toast was compiled trivially inside the src directory with:
#   mipsel-linux-gcc -ansi -pedantic -O2 -DNeedFunctionPrototypes=1 \
#                    -DSASR -DDWAV49 -DNDEBUG -I../inc -o toast *.c
#
# The file fed to toast must be in GSM format with Microsoft-style
# framing but no RIFF headers (i.e., a stripped WAV49 files) like
# one produced by feeding a Sun u-Law file to:
#  /usr/bin/toast -c -s file.au >file.gsm
# or a raw little-endian 16-bit PCM file to:
#  /usr/bin/toast -c -l file.raw >file.gsm
# etc. (for more choices of formats, see: "toast -h")
# Nevertheless, it must end in .mp3, or else Asterisk, not finding
# any ".mp3" file, won't execute mpg123 at all...
# For comfortable playback as MOH, use an input file about 25 dB
# below maximum dynamics (i.e., about sixteen times below saturation
# level).
#
while [ 1 ] ; do
  /usr/bin/toast -c -d -l </usr/lib/asterisk/mohmp3/bwv846ql.gsm.mp3
  if $? ; then exit 1; fi
done

Interested parties may grab a copy of my mipsel binary of toast (72,036 byte long), and the GSM-encoded music file I used with it, from https://em.no-ip.com/OpenWRT/MOH/ .

Enzo

Other proposed little patch for the Asterisk package: these three entries are creatd by Asterisk in /var . They should be moved to a directory writable by non-root, better if on RAMdisk (e.g., /var/spool/asterisk). At present I've had to make /var writable by world, which is not very good...

srwx------    1 asterisk asterisk        0 May  5 19:32 asterisk.ctl
-rw-------    1 asterisk asterisk        6 May  5 19:32 asterisk.pid
prwx------    1 asterisk asterisk        0 Jan  1  2000 autodial.ctl

Enzo

In order to mail out notices of received voicemails (optionally with the voicemail file as attachment) Asterisk needs access to a command-line program with syntax equivalent to "sendmail -t". There is a package for OpenWRT called "mini_sendmail" that could fit the bill, but unfortunately the program it derives from is buggy :-(  Rather than fixing the source code, I chose to work around the bugs with a suitable ash script, which can be installed directly as /usr/sbin/sendmail (chmod'd executable by world, of course: "chmod 755  /usr/sbin/sendmail"). I'm posting it here, hoping it can be useful to others.

Enzo

#!/bin/sh
# this script tries to fix two bugs in mini_sendmail 1.3.5:
# 1. The broken parsing of recipient addresses when "-t" is used
# 2. The habit of appending the hostname to the envelope sender if none is specified
# It also add the specified mail relay, so that this script may be named /usr/sbin/sendmail
# and used like the "real thing".
#
SMTPRELAY=192.168.0.128
BROKENMAILER=/usr/sbin/mini_sendmail
#
# ---- NO CONFIGURABLE PARAMETERS BELOW THIS LINE ----
#
IFS=' ' # only space in IFS
# save the message from stdin to a temp file, and its headers only to another
TEMPH=/tmp/xxxTMP.$$.h
TEMPM=/tmp/xxxTMP.$$.m
HEADERS=true
while read LINE; do {
 if [ -z "$LINE" ]; then HEADERS=false; fi
 if $HEADERS ; then
  echo "$LINE" >>$TEMPH
 fi
 echo "$LINE" >>$TEMPM
} done

# Now scan the positional parameters rotating them left...
HAS_T=false
HAS_F=false
for ARG in $@ ; do
 shift
 OPT=$(echo $ARG|cut -c 1-2)
 if [ _$OPT = '_-f' ] ; then
   HAS_F=true
   # if there is no '@', append one
   if [ $(expr "$ARG" : '[^@]*@') = "0" ] ; then
     ARG=${ARG}\@
   fi
 elif [ "_$ARG" = '_-t' ] ; then
   # there is a '-t' parameter, zap it but remember to emulate it later
   ARG=""
   HAS_T=true
 fi
 # re-append the scanned param to the end of the list
 set -- $@ "$ARG"
done

if $HAS_T ; then
 # extract recipients from headers
 set -- $@ $(egrep '(^To:|^Cc:|^Bcc:)' $TEMPH|tr '[,<> ]' '\n' |grep '@'|tr '\n' ' ')
fi

if ! $HAS_F ; then
 # add a synthetic "-fuser@" to pre-empt the broken mailer
 set -- "-f${LOGNAME}@" $@
fi

$BROKENMAILER -s$SMTPRELAY  $@ <$TEMPM
rm $TEMPH $TEMPM

(Last edited by enzo on 8 May 2005, 04:44)

Hi Enzo,

Before 'beautifting' the scripts shouldn't asterisk work seamlesly? I compiled it, configured it and it seems all to work. However there are still some problems creating segmentation faults.
A simple example to create a segmentation fault is to call youself (using for example X-lite). Also callthrough has problems. Debugging is impossible because the debug information must be stripped in order to fit into my WRT54G.
I looked for solutions or at least some hints on the net but the closest i found is the one below where there ae also problems using low-memory devices: http://lists.digium.com/pipermail/aster … 07380.html
No segmentation faults are present on my normal Debian server and this one is running now 24/7. Using a 4 watts WRT54 instead of a 60 watts PC (and no noise!) would be great... My aim is to really use my WRT at home. However I'm not confident enough to let it run...
What are your experiences using * on the WRT?

rzeldent wrote:

Hi Enzo,

Before 'beautifting' the scripts shouldn't asterisk work seamlesly?

Yes, but the frequent writes to astdb in the long run can ruin the flash memory. My script, among other things, moves it to a RAM partition.

rzeldent wrote:

I compiled it, configured it and it seems all to work. However there are still some problems creating segmentation faults.
A simple example to create a segmentation fault is to call youself (using for example X-lite).

I noticed: at least in my case, that occurred when a line was put on hold (this always happens if X-Lite calls itself). It turned out that the problem was due to the  line

noload => res_musiconhold.so

in /etc/asterisk/modules.conf, which prevents the relative module from being loaded (I know, Asterisk shouldn't crash because of that, but...). You may uncomment it, and either comment out all the lines in /etc/asterisk/musiconhold.conf , or enable music on hold, in which case I recommend my "MP3 emulation by way of GSM" I described in another post of this thread.

rzeldent wrote:

Also callthrough has problems.

Can you elaborate on this?

rzeldent wrote:

Debugging is impossible because the debug information must be stripped in order to fit into my WRT54G.

Using gdbserver, you only need symbols in the copy of asterisk kept on the host: the copy running under gdbserver on the target may be stripped. By the way, you'll need a very recent version of gdb (you may build it yourself: see my posts at http://openwrt.org/forum/viewtopic.php?pid=6472 ).

rzeldent wrote:

I looked for solutions or at least some hints on the net but the closest i found is the one below where there ae also problems using low-memory devices: http://lists.digium.com/pipermail/aster … 07380.html
No segmentation faults are present on my normal Debian server and this one is running now 24/7. Using a 4 watts WRT54 instead of a 60 watts PC (and no noise!) would be great...

Absolutely! And even better would be putting an ATA in the same box, e.g. using a WRT54GSP2. Unfortunately I've been told that the hardware is different enough to make it difficult to run OpenWRT on it.

rzeldent wrote:

My aim is to really use my WRT at home. However I'm not confident enough to let it run...
What are your experiences using * on the WRT?

Excellent so far: I'm using it at home without apparent flaws, and "top" reports a memory usage of only about 4.4Mb:

Mem: 23008K used, 7376K free, 0K shrd, 696K buff, 11920K cached
Load average: 0.06, 0.01, 0.00    (State: S=sleeping R=running, W=waiting)

  PID USER     STATUS   RSS  PPID %CPU %MEM COMMAND
 2362 root     R        416  2313  4.7  1.3 top
14442 asterisk S       4436 14428  0.0 14.5 asterisk
14437 asterisk S       4436 14428  0.0 14.5 asterisk
14427 asterisk S       4436     1  0.0 14.5 asterisk
14428 asterisk S       4436 14427  0.0 14.5 asterisk
14439 asterisk S       4436 14428  0.0 14.5 asterisk
14438 asterisk S       4436 14428  0.0 14.5 asterisk
14432 asterisk S       4436 14428  0.0 14.5 asterisk
14440 asterisk S       4436 14428  0.0 14.5 asterisk
14433 asterisk S       4436 14428  0.0 14.5 asterisk
14431 asterisk S       4436 14428  0.0 14.5 asterisk
 2312 root     S        852   434  0.0  2.8 dropbear
 1080 root     S        616   486  0.0  2.0 pppd
 2313 root     S        556  2312  0.0  1.8 ash
  427 nobody   S        456     1  0.0  1.5 dnsmasq
  486 root     S        444     1  0.0  1.4 S50pppoe
14434 root     S        428 14433  0.0  1.4 mpg123
  434 root     S        412     1  0.0  1.3 dropbear
  525 root     S        400     1  0.0  1.3 crond
   41 root     S        384     1  0.0  1.2 syslogd
    1 root     S        384     0  0.0  1.2 init
 1184 root     S        384     1  0.0  1.2 init
  439 root     S        376     1  0.0  1.2 httpd
   36 root     S        340     1  0.0  1.1 klogd
 1415 root     S        332     1  0.0  1.0 noip
  499 root     S        272     1  0.0  0.8 telnetd
14436 root     S        264 14434  0.0  0.8 toast
    3 root     SWN        0     1  0.0  0.0 ksoftirqd_CPU0
   21 root     SWN        0     1  0.0  0.0 jffs2_gcd_mtd4
    6 root     SW         0     1  0.0  0.0 kupdated
    7 root     SW         0     1  0.0  0.0 mtdblockd
    5 root     SW         0     1  0.0  0.0 bdflush
    2 root     SW         0     1  0.0  0.0 keventd
    4 root     SW         0     1  0.0  0.0 kswapd

(you'll notice toast, which provides the GSM music on hold).

There used to be a minor interoperability issue (common to all versions of Asterisk) with my Sipura SPA-3000 when sending DTMF in rfc2833 mode, but now Nico told me he fixed it in the CVS of the OpenWRT port, and is also fixed in Asterisk's CVS HEAD on asterisk.org .

I take this occasion to post the latest version of /etc/init.d/S60.asterisk, which makes sure that "/etc/init.d/S60.asterisk stop" won't return before Asterisk has really terminated, and adds a "restart" command:

#!/bin/sh

DEFAULT=/etc/default/asterisk
OPTIONS=""
[ -f $DEFAULT ] && . $DEFAULT
[ "$ENABLE_ASTERISK" = "yes" ] || exit 0

echolog() {
  echo "$@"
  logger -p user.info "$@"
}

# do a "chown -R" only if some file in the dir is owned by root
cond_chown_r() { # user file-or-dir
  MATCHLIST=$(ls -ld $2 | grep 'root')
  MATCHLIST=$MATCHLIST$(ls -lR $2 | grep 'root')
  if [ ! -z "$MATCHLIST" ] ; then 
    chown -R $1 $2
    echo chown -R $1 $2
  fi
}

# replace symlinks to /rom/... with actual copies
deromize() {
  if [ -L $1 ] ; then
    POINTEDFILE="$(ls -l /etc/group |  cut -d '>' -f 2-)"
    rm $1
    cp $POINTEDFILE $1
  fi
}



start() {

  PIDLIST=$(pidof asterisk)
  if [ ! -z "$PIDLIST" ] ; then
   echolog "Asterisk is already running!"
   return 1 
  fi
                  
  [ -d /var/run ] || mkdir -p /var/run
  [ -d /var/log/asterisk ] || mkdir -p /var/log/asterisk
  [ -d /var/spool/asterisk ] || mkdir -p /var/spool/asterisk
  [ -d /var/spool/asterisk/voicemail ] || mkdir -p /var/spool/asterisk/voicemail

  deromize /etc/group
  # create the group "asterisk", unless already there
  if [ -z "$(grep '^asterisk:' /etc/group)" ] ; then
    MATCHING="$(grep ':5060:' /etc/group)"
    if [ -z "$MATCHING" ] ; then
      echo "asterisk:x:5060:" >> /etc/group
    else
      echo "** error in ${0} - GID 5060 already in use by others:"
      echo $MATCHING
      exit 1
    fi
  fi
  
  deromize /etc/passwd
  # create the user "asterisk", unless already there
  if [ -z "$(grep '^asterisk:' /etc/passwd)" ] ; then
    MATCHING="$(grep ':5060:' /etc/passwd)"
    if [ -z "$MATCHING" ] ; then 
      echo "asterisk:*:5060:5060:asterisk:/tmp:/bin/ash" >> /etc/passwd 
    else
      echo "** error in ${0} - UID 5060 already in use by others:"
      echo $MATCHING
      exit 1
    fi
  fi
  # change ownership of all relevant directories      
  cond_chown_r asterisk.asterisk /var/log/asterisk
  cond_chown_r asterisk.asterisk /var/spool/asterisk
  cond_chown_r asterisk.asterisk /etc/asterisk
  cond_chown_r asterisk.asterisk /usr/lib/asterisk
  cond_chown_r asterisk.asterisk /usr/sbin/asterisk
  # the following hack will stay until autodial.ctl and 
  # asterisk.ctl will be moved to a directory writable 
  # by Asterisk (such as /var/spool/asterisk) 
  chgrp asterisk /var/run
  chmod 775 /var/run
  [ -e /var/run/autodial.ctl ] || chown asterisk.asterisk /var/run/autodial.ctl
  [ -e /var/run/asterisk.ctl ] || chown asterisk.asterisk /var/run/asterisk.ctl
  # 
  # make the binary suid, so it won't run as root 
  chmod +s /usr/sbin/asterisk
  
  while [ -z "$(route | grep '0\.0\.0\.0')" ] ; do 
    echolog "waiting for default route to exist..."
    sleep 2
  done
  
  if [ -f /usr/lib/asterisk/astdb ] ; then
    mv /usr/lib/asterisk/astdb /var/spool/asterisk/astdb
    ln -s /var/spool/asterisk/astdb /usr/lib/asterisk/astdb
  fi
  
  /usr/sbin/asterisk $OPTIONS
  logger -p user.info "Asterisk started..Æ’."

}

stop() {
 
  PIDLIST=$(pidof asterisk)
  if [ -z "$PIDLIST" ] ; then
   echolog "Asterisk is already stopped!"
   return 1 
  fi
                  
  [ -f /var/run/asterisk.pid ] && kill $(cat /var/run/asterisk.pid) >/dev/null 2>&1

  ICNT=0
  for ICNT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
    # for max 15 s, see if some process is still alive
    PIDLIST=$(pidof asterisk)
    if [ -z "$PIDLIST" ] ; then
      break
    fi
    sleep 1
  done
  # if still alive after more than 5 s, use "kill -9"
  if [ ! -z "$PIDLIST" ] ; then 
    echolog "killing stubborn processes $PIDLIST"
    for GONER in $PIDLIST; do kill -9 $GONER; done
  fi
  # save astdb to a flash-mapped directory
  if [ -L /usr/lib/asterisk/astdb ] ; then
    rm /usr/lib/asterisk/astdb
  fi
  if [ -f /var/spool/asterisk/astdb ] ; then
    mv -f /var/spool/asterisk/astdb /usr/lib/asterisk/astdb 
  fi
  logger -p user.info "Asterisk stopped..Æ’."

}


case $1 in
 start)
  start
  ;;
 stop)
  stop
  ;;
 restart)
  stop
  start
  ;;
 *)
  echo "usage: $0 (start|stop|restart)"
  exit 1
esac

exit $?

Enzo

(Last edited by enzo on 30 May 2005, 00:25)

hello

i tried your script but it wont load anythink after i executed the script. there is no output on the screen and asterisk is not running after execution.
i use the old-experimental openwrt in connection with asterisk 1.0.7-4 from nico.

i tried both versions of your script. want am i doing wrong? the DEFAULT variable says /etc/default/asterisk. but there is no default directory in /etc

thanks

(Last edited by bjunix on 2 Jun 2005, 12:49)

bjunix wrote:

hello

i tried your script but it wont load anythink after i executed the script. there is no output on the screen and asterisk is not running after execution.
i use the old-experimental openwrt in connection with asterisk 1.0.7-4 from nico.

i tried both versions of your script. want am i doing wrong? the DEFAULT variable says /etc/default/asterisk. but there is no default directory in /etc
thanks

Oh yes: please create a /etc/default/asterisk file containing:

## startup options for /etc/init.d/asterisk
ENABLE_ASTERISK="yes"
OPTIONS=""

This was inherited from another port of Asterisk to OpenWRT, by Felix Fietkau: http://nthill.free.fr/openwrt/tracker/p … hp?id=3914

By the way, in the lat few days I'm having strange problems trying to run Asterisk as non-root: it refuses to start saying:

asterisk: can't load library 'libdl.so.0'

This began to happen at the same time as a similar issue with dnsmasq (see thread http://openwrt.org/forum/viewtopic.php?pid=7844#p7844 ). I have no idea about what may have changed in my setup; it's not an issue of permissions of libdl.so.0 because that file is world-readable. Should anyone experience the same problem, I'd like to hear from him (especially if he finds a solution ;-) ).

In any case, even accepting to run Asterisk as root, the relocation of astdb remains strongly recommended, in order not to damage the flash memory.

Enzo

I'm trying to get asterisk running as well and to be honest, the current situation with OpenWRT is rather confusing. It's not even easy to find the "right" version of OpenWRT to load to start with. All the links lead you to an FTP page that says obsolete and if you read the text file there it points you to an experimental version.  The situation for Asterisk packages is worse in that there seems to be at least 3 separate people doing builds and packages don't appear to have dates associated with them so I'm not sure which development thread is the "current" one.

At the moment, I've got OpenWRT installed and running but I'm not having luck getting Asterisk to work. Specifically, I'm getting this error when I try and start Asterisk:

     root@OpenWrt:/etc/init.d# asterisk: can't load library 'libgcc_s.so.1'

I've tried several of the Asterisk packages and they all get the same error. Currently I'm using the Asterisk package that seems to be part of the standard repository (1.0.7-1).

Can anyone help me straighten out my mess? Thanks!

sbussinger wrote:

I'm trying to get asterisk running as well and to be honest, the current situation with OpenWRT is rather confusing. It's not even easy to find the "right" version of OpenWRT to load to start with. All the links lead you to an FTP page that says obsolete and if you read the text file there it points you to an experimental version.  The situation for Asterisk packages is worse in that there seems to be at least 3 separate people doing builds and packages don't appear to have dates associated with them so I'm not sure which development thread is the "current" one.

At the moment, I've got OpenWRT installed and running but I'm not having luck getting Asterisk to work. Specifically, I'm getting this error when I try and start Asterisk:

     root@OpenWrt:/etc/init.d# asterisk: can't load library 'libgcc_s.so.1'

I've tried several of the Asterisk packages and they all get the same error. Currently I'm using the Asterisk package that seems to be part of the standard repository (1.0.7-1).

Can anyone help me straighten out my mess? Thanks!

Hmm, I've never seen that error, but that library does exist, at least in the Experimental build:

root@OpenWrt:~# ls -l /lib/libgcc_s.so.1
lrwxrwxrwx    1 root     root           22 Jan  1  2000 /lib/libgcc_s.so.1 -> /rom/lib/libgcc_s.so.1
root@OpenWrt:~# ls -l /rom/lib/libgcc_s.so.1
-rw-r--r--    1 root     root        48790 Mar 29 10:48 /rom/lib/libgcc_s.so.1
root@OpenWrt:~#

Are you running Asterisk as root, as it comes out of the box? That error looks similar to the one I've been seeing in the last few days when I try to run it as non-root.

By the way, the Experimental build of OpenWRT is the one you should run, as the one called "stable" doesn't support the hardware in new models and therefore is actually obsolescent. Don't worry about its name: it's actually very stable. I'm still running the release of the 28 March, but there is a fresher one (25 May) at http://downloads.openwrt.org/experimental/ .

Regarding Asterisk, the package tracker returns four Asterisk packages:
http://nthill.free.fr/openwrt/tracker/p … e=asterisk
In the past I installed the third and the fourth, but now I'm running the 1.0.7-1 compiled by myself after downloading and installing the toolchain+sources (http://downloads.openwrt.org/experiment … al.tar.bz2). The reason is that I had to fix an incompatibility with my Sipura-3000 regarding DTMF over RTP; Nico later added the fix it to the CVS, and I think it's now in the version that comes with the current toolchain.  I've had also to add, in /usr/lib/asterisk/sound , a few sound files which were missing from the 1.0.7-4 package:

root@OpenWrt:~# ls -l /usr/lib/asterisk/sounds/
-rw-------    1 asterisk asterisk     4884 Dec 19  2002 agent-pass.gsm
-rw-------    1 asterisk asterisk     7524 Apr 14 23:22 auth-incorrect.gsm
-rw-------    1 asterisk asterisk     1947 Apr 14 23:22 auth-thankyou.gsm
-rw-------    1 asterisk asterisk      858 Apr 19 04:36 beep.gsm
-rw-------    1 asterisk asterisk    23364 Apr 13 15:56 demo-abouttotry.gsm
-rw-------    1 asterisk asterisk     4059 Apr 13 15:55 demo-echodone.gsm
-rw-------    1 asterisk asterisk    31812 Apr 13 15:55 demo-echotest.gsm
-rw-------    1 asterisk asterisk     7920 Apr 14 11:38 demo-thanks.gsm
-rw-------    1 asterisk asterisk     7689 Apr 19 04:36 ss-noservice.gsm
-rw-------    1 asterisk asterisk     8844 Apr 19 04:36 vm-intro.gsm

Some are necessary for the echotest demo application, and some for the voicemail. You may get them from various places, e.g. http://asterisk.gnuinter.net/files/digi … ng/sounds/ .

By the way, if you want to inspect under Windows .ipk package files to check timestamps etc., I found that 7zip does grok them: www.7zip.org

Finally, I note that some applications such as PlayTones, DISA, and SendDTMF if dtmfmode=inband in sip.conf don't seem to work. I hit some of these bugs (PlayTones for sure) also in the standard Asterisk for i386 (see e.g. my post at http://forums.digium.com/viewtopic.php?t=313 , to whom nobody has still replied :-( ); in addition, dtmfmode=inband (only in the OpenWRT version) seems to screw up voice channels as well. I'm not sure about the reason, and perhaps some of these issues have been fixed in the latest release (I'll try it one day or another...)

Cheers --

Enzo

Well, I loaded the latest experimental firmware, reset my NVRAM, and ran FIRSTBOOT in an attempt to get everything reset back to basics again. I finally got it all loaded and running again. After loading the asterisk in the standard package list though it not starts to load and dies with a segment fault:

[snip]

[chan_iax2.so] => (Inter Asterisk eXchange (Ver 2))
  == Manager registered action IAXpeers
  == Parsing '/etc/asterisk/iax.conf': Found
  == Registered channel type 'IAX2' (Inter Asterisk eXchange Driver (Ver 2))
  == Using TOS bits 16
  == IAX Ready and Listening on 0.0.0.0 port 4569
Jan  1 00:27:39 WARNING[2465]: chan_iax2.c:1168 reload_firmware: Error opening firmware directory '/usr/lib/asterisk/firmware/iax': No such file or directory
  == Parsing '/etc/asterisk/iaxprov.conf': Found
    -- Loaded provisioning template 'default'
[app_macro.so] => (Extension Macros)
  == Registered application 'Macro'
[codec_ulaw.so] => (Mu-law Coder/Decoder)
  == Registered translator 'ulawtolin' from format ulaw to slin, cost 1
  == Registered translator 'lintoulaw' from format slin to ulaw, cost 1
[chan_agent.so] => (Agent Proxy Channel)
  == Registered channel type 'Agent' (Call Agent Proxy Channel)
  == Registered application 'AgentLogin'
  == Registered application 'AgentCallbackLogin'
  == Registered application 'AgentMonitorOutgoing'
  == Parsing '/etc/asterisk/agents.conf': Found
[app_transfer.so] => (Transfer)
  == Registered application 'Transfer'
[app_lookupblacklist.so] => (Look up Caller*ID name/number from blacklist database)
  == Registered application 'LookupBlacklist'
[app_enumlookup.so] => (ENUM Lookup)
  == Registered application 'EnumLookup'
  == Parsing '/etc/asterisk/enum.conf': Found
[codec_ilbc.so] => (iLBC/PCM16 (signed linear) Codec Translator)
Segmentation fault

Any suggestions?

P.S. I also loaded interface-wrt and it works except for the packages setup screen which comes out blank. It didn't used to do that and seemed to work fine before I reset everything. Is this an issue with interface-wrt on the latest firmware?

sbussinger wrote:

Well, I loaded the latest experimental firmware, reset my NVRAM, and ran FIRSTBOOT in an attempt to get everything reset back to basics again. I finally got it all loaded and running again. After loading the asterisk in the standard package list though it not starts to load and dies with a segment fault:

[...]
  == Registered application 'LookupBlacklist'
[app_enumlookup.so] => (ENUM Lookup)
  == Registered application 'EnumLookup'
  == Parsing '/etc/asterisk/enum.conf': Found
[codec_ilbc.so] => (iLBC/PCM16 (signed linear) Codec Translator)
Segmentation fault

Any suggestions?

Hm, I see that you load many modules not strictly necessary, and perhaps one of them crashes the application. I seem to remember that  chan_modem.so was giving me a similar problem; surely it is unnecessary on OpenWRT because it's only used to handle ISDN cards. Try to replace the content of your existing /etc/asterisk/modules.conf with this one, which works for me:

;
; Asterisk configuration file
;
; Module Loader configuration file
;

[modules]
autoload=yes
noload => pbx_gtkconsole.so
noload => pbx_kdeconsole.so
;
; Intercom application is obsoleted by
; chan_oss.  Don't load it.
;
noload => app_intercom.so
;
noload => chan_modem.so
;noload => res_musiconhold.so
;
; Load either OSS or ALSA, not both
; By default, load OSS only (automatically) and do not load ALSA
;
noload => chan_alsa.so
noload => chan_oss.so
; Also do not load the following:
;noload => app_adsiprog.so ; Asterisk ADSI Programming Application
;noload => app_db.so
;noload => app_hasnewvoicemail.so
;noload => app_voicemail.so
;noload => chan_skinny.so
;noload => chan_mgcp.so
;noload => cdr_csv.so
;noload => res_adsi.so ; ADSI Resource
;noload => res_agi.so ; Asterisk Gateway Interface (AGI)
; the following two are damn slow due to lack of FPU :-(
noload => codec_ilbc.so
noload => codec_lpc10.so
[global]
;
; Module names listed in "global" section will have symbols globally
; exported to modules loaded after them.
;
; chan_modem.so=yes
sbussinger wrote:

P.S. I also loaded interface-wrt and it works except for the packages setup screen which comes out blank. It didn't used to do that and seemed to work fine before I reset everything. Is this an issue with interface-wrt on the latest firmware?

I don't know, I've never used interface-wrt as I prefer the console prompt (the implementation of the vi editor could be better, but it's basically functional).

At the shell prompt, you may issue "ipkg status" to list all the installed packages. For other options, just issue "ipkg".

Enzo

> Hm, I see that you load many modules not strictly necessary, and perhaps one of them
>  crashes the application. I seem to remember that  chan_modem.so was giving me a
> similar problem; surely it is unnecessary on OpenWRT because it's only used to handle
> ISDN cards. Try to replace the content of your existing /etc/asterisk/modules.conf with
> this one, which works for me:

Ah, good point. I'd assumed that the modules.conf was already pruned down to a reasonable set for the package, but I see that's not the case. I grabbed the modules.conf from my "real" asterisk server and started with that. In that file I take the approach of no loading anything by default and only loading the specific modules I need. By using a very minimal modules.conf it's working OK now. I haven't done much more than an echo test yet, but it seems to be working so far.

Thanks for the help!

Dear all,

CANNOT FIND zaptel.h

I have been using Asterisk on Fedora and I am new to openwrt. I have just check out the openwrt CVS. In using the sample default menuconfig setting, everything is fine and the jffs2 bin files can be generated succesfully.

However, when I selected Asterisk package at the menuconfig and make again, it has the following error.
Is the method I used incorrect? Or anyone can give me some hints.

Thanks.

make[4]: `libtime.a' is up to date.
make[4]: Leaving directory `/root_wrt/openwrt/build_mipsel/asterisk-1.0.7/stdtime'
/root_wrt/openwrt/staging_dir_mipsel/bin/mipsel-linux-uclibc-gcc -pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations  -Iinclude -I../include -D_REENTRANT -D_GNU_SOURCE  -Os -pipe -mips32 -mtune=mips32  -I/root_wrt/openwrt/staging_dir_mipsel/usr/include -I/root_wrt/openwrt/staging_dir_mipsel/usr/include/speex    -DZAPTEL_OPTIMIZATIONS  -DASTERISK_VERSION=\"1.0.7\" -DINSTALL_PREFIX=\"\" -DASTETCDIR=\"/etc/asterisk\" -DASTLIBDIR=\"/usr/lib/asterisk\" -DASTVARLIBDIR=\"/usr/lib/asterisk\" -DASTVARRUNDIR=\"/var/run\" -DASTSPOOLDIR=\"/var/spool/asterisk\" -DASTLOGDIR=\"/var/log/asterisk\" -DASTCONFPATH=\"/etc/asterisk/asterisk.conf\" -DASTMODDIR=\"/usr/lib/asterisk/modules\" -DASTAGIDIR=\"/usr/lib/asterisk/agi-bin\"     -DBUSYDETECT_MARTIN     -DLOW_MEMORY    -c -o channel.o channel.c
channel.c:44:26: linux/zaptel.h: No such file or directory
channel.c:49:2: #error "You need newer zaptel!  Please cvs update zaptel"
channel.c: In function `ast_channel_alloc':
channel.c:303: error: `ZT_TIMERPONG' undeclared (first use in this function)
channel.c:303: error: (Each undeclared identifier is reported only once
channel.c:303: error: for each function it appears in.)
channel.c: In function `ast_queue_frame':
channel.c:418: error: `ZT_TIMERPING' undeclared (first use in this function)
channel.c: In function `ast_settimeout':
channel.c:1129: error: `ZT_TIMERCONFIG' undeclared (first use in this function)
channel.c: In function `ast_read':
channel.c:1242: error: `ZT_GETEVENT' undeclared (first use in this function)
channel.c:1244: error: `ZT_EVENT_TIMER_EXPIRED' undeclared (first use in this function)
channel.c:1246: error: `ZT_EVENT_TIMER_PING' undeclared (first use in this function)
channel.c:1255: error: `ZT_TIMERPONG' undeclared (first use in this function)
channel.c:1260: error: `ZT_TIMERACK' undeclared (first use in this function)
channel.c:1272: error: `ZT_TIMERCONFIG' undeclared (first use in this function)
make[3]: *** [channel.o] Error 1
make[3]: Leaving directory `/root_wrt/openwrt/build_mipsel/asterisk-1.0.7'
make[2]: *** [/root_wrt/openwrt/build_mipsel/asterisk-1.0.7/.built] Error 2
make[2]: Leaving directory `/root_wrt/openwrt/package/asterisk'
make[1]: *** [asterisk-compile] Error 2
make[1]: Leaving directory `/root_wrt/openwrt/package'
laputa wrote:

Dear all,

CANNOT FIND zaptel.h

I have been using Asterisk on Fedora and I am new to openwrt. I have just check out the openwrt CVS. In using the sample default menuconfig setting, everything is fine and the jffs2 bin files can be generated succesfully.

However, when I selected Asterisk package at the menuconfig and make again, it has the following error.
Is the method I used incorrect? Or anyone can give me some hints.

Thanks.

make[4]: `libtime.a' is up to date.
make[4]: Leaving directory `/root_wrt/openwrt/build_mipsel/asterisk-1.0.7/stdtime'
/root_wrt/openwrt/staging_dir_mipsel/bin/mipsel-linux-uclibc-gcc -pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations  -Iinclude -I../include -D_REENTRANT -D_GNU_SOURCE  -Os -pipe -mips32 -mtune=mips32  -I/root_wrt/openwrt/staging_dir_mipsel/usr/include -I/root_wrt/openwrt/staging_dir_mipsel/usr/include/speex    -DZAPTEL_OPTIMIZATIONS  -DASTERISK_VERSION=\"1.0.7\" -DINSTALL_PREFIX=\"\" -DASTETCDIR=\"/etc/asterisk\" -DASTLIBDIR=\"/usr/lib/asterisk\" -DASTVARLIBDIR=\"/usr/lib/asterisk\" -DASTVARRUNDIR=\"/var/run\" -DASTSPOOLDIR=\"/var/spool/asterisk\" -DASTLOGDIR=\"/var/log/asterisk\" -DASTCONFPATH=\"/etc/asterisk/asterisk.conf\" -DASTMODDIR=\"/usr/lib/asterisk/modules\" -DASTAGIDIR=\"/usr/lib/asterisk/agi-bin\"     -DBUSYDETECT_MARTIN     -DLOW_MEMORY    -c -o channel.o channel.c
channel.c:44:26: linux/zaptel.h: No such file or directory
channel.c:49:2: #error "You need newer zaptel!  Please cvs update zaptel"
channel.c: In function `ast_channel_alloc':
channel.c:303: error: `ZT_TIMERPONG' undeclared (first use in this function)
channel.c:303: error: (Each undeclared identifier is reported only once
channel.c:303: error: for each function it appears in.)
channel.c: In function `ast_queue_frame':
channel.c:418: error: `ZT_TIMERPING' undeclared (first use in this function)
channel.c: In function `ast_settimeout':
channel.c:1129: error: `ZT_TIMERCONFIG' undeclared (first use in this function)
channel.c: In function `ast_read':
channel.c:1242: error: `ZT_GETEVENT' undeclared (first use in this function)
channel.c:1244: error: `ZT_EVENT_TIMER_EXPIRED' undeclared (first use in this function)
channel.c:1246: error: `ZT_EVENT_TIMER_PING' undeclared (first use in this function)
channel.c:1255: error: `ZT_TIMERPONG' undeclared (first use in this function)
channel.c:1260: error: `ZT_TIMERACK' undeclared (first use in this function)
channel.c:1272: error: `ZT_TIMERCONFIG' undeclared (first use in this function)
make[3]: *** [channel.o] Error 1
make[3]: Leaving directory `/root_wrt/openwrt/build_mipsel/asterisk-1.0.7'
make[2]: *** [/root_wrt/openwrt/build_mipsel/asterisk-1.0.7/.built] Error 2
make[2]: Leaving directory `/root_wrt/openwrt/package/asterisk'
make[1]: *** [asterisk-compile] Error 2
make[1]: Leaving directory `/root_wrt/openwrt/package'

Hmmm... I wonder why there is "-DZAPTEL_OPTIMIZATIONS": no Zapata cards can be installed on the WRT54G(S), and therefore there is no reason or possibility to run the Zaptel drivers. Try to remove that define and recompile.

Nico, what do you think?

Enzo

Refering to the previous problem adding asterisk in the build-root

I have dig into the issue by adding the package asterisk from ntfill.free.fr and build-root. It has the same error of missing zaptel.h.
-> adding the zaptel.h then it comes to another error of missing speex.h
-> adding the speex.h, then it comes to another error of missing the z lib
-> removing the link to the z lib as I do not use sql then it compiled successfully
-> however, the asterisk and conf is not added into the root fs

I think I get into the wrong way to build-root with asterisk, could someone kindly give me some hints or instruction to add asterisk package in the build-root process?

Many thanks.

laputa wrote:

Refering to the previous problem adding asterisk in the build-root

I have dig into the issue by adding the package asterisk from ntfill.free.fr and build-root. It has the same error of missing zaptel.h.
-> adding the zaptel.h then it comes to another error of missing speex.h
-> adding the speex.h, then it comes to another error of missing the z lib
-> removing the link to the z lib as I do not use sql then it compiled successfully
-> however, the asterisk and conf is not added into the root fs

I think I get into the wrong way to build-root with asterisk, could someone kindly give me some hints or instruction to add asterisk package in the build-root process?

Many thanks.

I think that the most appropriate comments may come from Nico, who, as I understand it, currently is the main maintainer. Why don't you just install a precompiled package, such as the 1.0.7-4 (the forth from the top among the ones listed at http://nthill.free.fr/openwrt/tracker/s … y=asterisk )?

Enzo

enzo wrote:
laputa wrote:

Refering to the previous problem adding asterisk in the build-root

I have dig into the issue by adding the package asterisk from ntfill.free.fr and build-root. It has the same error of missing zaptel.h.
-> adding the zaptel.h then it comes to another error of missing speex.h
-> adding the speex.h, then it comes to another error of missing the z lib
-> removing the link to the z lib as I do not use sql then it compiled successfully
-> however, the asterisk and conf is not added into the root fs

I think I get into the wrong way to build-root with asterisk, could someone kindly give me some hints or instruction to add asterisk package in the build-root process?

Many thanks.

I think that the most appropriate comments may come from Nico, who, as I understand it, currently is the main maintainer. Why don't you just install a precompiled package, such as the 1.0.7-4 (the forth from the top among the ones listed at http://nthill.free.fr/openwrt/tracker/s … y=asterisk )?

Enzo

Further on this matter: After a Linux reinstall to move to Centos 4.1, I have installed the not-so-experimental "whiterussian RC1" branch (http://downloads.openwrt.org/whiterussian/rc1/whiterussian_rc1.tar.bz2 , timestamped 25-Jun-2005 08:41). It contains Asterisk 1.0.7-1 which, if enabled in "make menuconfig", builds fine, apart from a minor flaw: the makefile openwrt/build_mipsel/asterisk-1.0.7/pbx/Makefile mistakenly tests for GTK (on the host system) and that results in abuild error. The fix consists of commenting out the line 19 of that file:

PBX_LIBS+=$(shell gtk-config --cflags >/dev/null 2>/dev/null && echo "pbx_gtkconsole.so")

Enzo

Hi Enzo,

This is now fixed in CVS (whiterussian)

Thanks for your help

(Last edited by Nico on 4 Jul 2005, 15:50)

New package: AGI script for Least-Cost Routing

As hardcore Asterisk users may already know, there is an Asterisk application called LCDial (http://www.voip-info.org/tiki-index.php?page=Application+LCDial ) that allows to call a PSTN number by choosing the cheapest termination provider in a given set. Unfortunately, LCDial relies upon a MySQL database, so it's not suitable to a self-contained OpenWRT platform.

Enter LCDial.sh: an AGI script invoked from extensions.conf with a similar syntax, but using ASCII flat files for its rates tables, and implemented as a shell script (ash, to be precise, with help from sed, expr and cut: all provided by Busybox). In theory it should also work on "regular" Linux platforms. Compared with LCDial, it has an two additional features:

1. An ENUM lookup for a free route is attempted first
2. It is possible to add an extra parameter specifying the maximum cost per minute of a telephone call. This protects against expensive dialling mistakes (such as calling an Inmarsat number ;-) ), or may be used to e.g. allow only calls to toll-free numbers and other zero-cost destinations.

If the lowest-cost provider can't terminate the call, the next is tried, and so on.

I've prepared a package provisionally located at https://em.no-ip.com/OpenWRT/lcdialsh/l … mipsel.ipk . It includes the script itself, SAMPLE configuration files and rates tables, and documentation placed in /tmp/LCDial.sh-doc.txt . The latter is also available at https://em.no-ip.com/OpenWRT/lcdialsh/LCDial.sh-doc.txt for a quick  glance at the features before installing the package.

Before using it, please read both the documentation in that file, and the disclaimer in /etc/asterisk/lcdialsh/rates/README.txt .

In case of any problem, please let me know.

Enzo

Hi Enzo,

I was trying to use the cdr_csv.o module in Asterisk to log my calls and noticed, that it looks for a file in a directory which does not exist. So I added the two lines

  [ -d /var/log/asterisk/cdr-csv ] || mkdir -p /var/log/asterisk/cdr-csv
  [ -f /var/log/asterisk/cdr-csv/Master.csv ] || touch /var/log/asterisk/cdr-csv/Master.csv

(Keep up the good work)
JH

doerner wrote:

Hi Enzo,

I was trying to use the cdr_csv.o module in Asterisk to log my calls and noticed, that it looks for a file in a directory which does not exist. So I added the two lines

  [ -d /var/log/asterisk/cdr-csv ] || mkdir -p /var/log/asterisk/cdr-csv
  [ -f /var/log/asterisk/cdr-csv/Master.csv ] || touch /var/log/asterisk/cdr-csv/Master.csv

(Keep up the good work)
JH

Thanks! I had indeed added the first line (the creation of the directory) in the /et/init.d/S60asterisk script on my system, and forgot to post the change. I'm not sure if the second line is necessary, but it won't hurt.

By the way, can you manage to run Asterisk as non-root? For some reason that ceased to work for me and I had to disable it by commenting out the line:

# cond_chown_r asterisk.asterisk /usr/sbin/asterisk

It must be some system-wide issue on my (old) release of OpenWRT because also dnsmasq malfunctions (and not only for me) if run as non-root.

(Besides, setting the asterisk binary SUID is not the best way of doing it, as I later discovered that asterisk has "-U" and "-G" command lines options...)

Also, even if Asterisk worked correctly as non-root, the TOS bits in the RTP and IAX packets wouldn't be set as desired, because setting the TOS bits is a privileged operation:

Sep 11 11:22:16 WARNING[3554]: rtp.c:915 ast_rtp_settos: Unable to set TOS to 184
Sep 11 11:22:16 WARNING[3554]: rtp.c:915 ast_rtp_settos: Unable to set TOS to 184
Sep 11 11:22:24 WARNING[3554]: rtp.c:915 ast_rtp_settos: Unable to set TOS to 184

In that case, QoS should be implemented by the router on the basis of the UDP ports. An example of how to do that, also including the actual traffic shaping, is at http://www.krisk.org/astlinux/misc/astshape ; for the TOS bits setting alone, laving the shaping to devices downstream, see http://www.voip-info.org/wiki-Asterisk+ … t#comments :

# Set TOS bit
iptables -A OUTPUT -t mangle -p udp -m udp --dport 5060 -j DSCP --set-dscp 0x28
iptables -A OUTPUT -t mangle -p udp -m udp --sport 10000:20000 -j DSCP --set-dscp 0x28

Rather than 0x18 (astshape) or 0x28 (andrewid's comment above) I prefer 0xb8. This value, copied by the Sipura SPA-3000, sets the TOS bits to "low delay + high throughput" (the 0x18 part) and the "precedence" bits to 5, which in RFC 791 used to mean "CRITIC/ECP" and in the DIFFSERV model (RFC 2474/2475) was redefined as "Expedited Forwarding (EF)" (see also http://www.ietf.org/rfc/rfc2598.txt , which says it "can be used to build a low loss, low latency, low jitter, assured bandwidth, end-to-end service through DS domains"). Either way, it looks like something suitable to media packets. For more details, see http://www.cisco.com/warp/public/105/dscpvalues.html .

Enzo

Sorry, posts 26 to 25 are missing from our archive.