buttons from sip.conf instead of voicemail.conf?

  1. 14 years ago

    Does anyone parse the sip.conf to build the buttons? I have users that have both soft and hard phones. Soft phones do not have voicemail and/or are the softphone is setup to leave voicemail at the primary (hard phone) mailbox. Hard phones that are in conference rooms, lobbies, server room, etc do not have mailboxes either so I don't see them in fop2.

    Has anyone written a script to parse the sip.conf file instead?

  2. admin

    23 Feb 2010 Administrator

    The latest beta can be used together with a freepbx module to configure users from the extensions instead of voicemail. Please search the forums as there are several posts with the appropiate links... you can try that out. Best regards,

  3. admin

    24 Feb 2010 Administrator

    Quick and dirty, for FreePBX:

    #!/bin/bash
    if [ -e /etc/amportal.conf ]; then
    
    DBNAME=`cat /etc/amportal.conf | sed 's/ //g' | grep ^AMPDBNAME | cut -d= -f2`
    DBUSER=`cat /etc/amportal.conf | sed 's/ //g' | grep ^AMPDBUSER | cut -d= -f2`
    DBPASS=`cat /etc/amportal.conf | sed 's/ //g' | grep ^AMPDBPASS | cut -d= -f2`
    DBHOST=`cat /etc/amportal.conf | sed 's/ //g' | grep ^AMPDBHOST | cut -d= -f2`
    
    mysql -NB -u $DBUSER -p$DBPASS -h $DBHOST $DBNAME -e "select CONCAT('user=',id,':',data,':all') from sip where keyword='secret'" | while read LINEA
    do
    echo $LINEA 
    done
    echo "buttonfile=autobuttons.cfg"
    
    else
    echo "Unable to find /etc/amportal.conf"
    fi
  4. I don't have freepbx but got this to work with asterisk 1.6.0.26
    Create a file called build_buttons.pl and paste following code.

    #!/usr/bin/env perl
    #
    # Extensions
    #
    while (<>) {
            if (m/\[\d/) {
                    chomp $_;
                    s/\[([0-9]+)\]/\1/;
                    print("[SIP/$_]\n");
                    print("type=extension\n");
                    print("extension=$_\n");
                    while (<>) {
                            if (m/^$/) {
                                    last
                            }
                    if (m/^(context|label|vmexten=[0-9]|callerid|mailbox|\[[0-9])/) {
                            s/\<([0-9]+)\]/\1/;
                            s/callerid=/label=/;
                            s/ <\d+>//;
                            if ( m/context/ ) {
                                    $context=$_;
                                    $context=~ s/context=//;
                                    chomp $context;
                            }
                            s/(mailbox=\d+)/\1\@default/;
                            s/vmexten=(\d+)/extenvoicemail=*\1\@$context/;
                            print
                            }
                    }
            }
    }
    
    #The rest of this is just hardcoded buttons.
    #
    # Conference
    #
    print("[CONFERENCE/1600]\n");
    print("type=conference\n");
    print("label=User\n");
    print("extension=1600\n");
    print("context=from-internal-redir\n");
    print("\n");
    
    print("[PARK/default]\n");
    print("extension=700\n");
    print("context=parkedcalls\n");
    print("type=park\n");
    print("Label=Parked \n");
    print("\n");
    
    print("[SIP/VoicePulse]\n");
    print("type=trunk\n");
    print("label=VoicePulse\n");
    
    print("[G1]\n");
    print("type=trunk\n");
    print("label=PRI\n");
    print("channel=DAHDI/1\n");
    print("channel=DAHDI/2\n");
    print("channel=DAHDI/3\n");
    print("channel=DAHDI/4\n");
    print("channel=DAHDI/5\n");
    print("channel=DAHDI/6\n");
    print("channel=DAHDI/7\n");
    print("channel=DAHDI/8\n");
    print("channel=DAHDI/9\n");
    print("channel=DAHDI/10\n");
    print("channel=DAHDI/11\n");
    print("channel=DAHDI/12\n");
    print("channel=DAHDI/13\n");
    print("channel=DAHDI/14\n");
    print("channel=DAHDI/15\n");
    print("channel=DAHDI/16\n");
    print("channel=DAHDI/17\n");
    print("channel=DAHDI/18\n");
    print("channel=DAHDI/19\n");
    print("channel=DAHDI/20\n");
    print("channel=DAHDI/21\n");
    print("channel=DAHDI/22\n");
    print("channel=DAHDI/23\n");

    buttons.cfg only has this line
    #exec build_buttons.pl < /etc/asterisk/sip.conf

or Sign Up to reply!