Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

FOP2 Community Forum

  1. Home
  2. Support
  3. FOP2 buttons_astcli modification for trunks

FOP2 buttons_astcli modification for trunks

Scheduled Pinned Locked Moved Support
2 Posts 2 Posters 69 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A
    A
    atlantia
    wrote on last edited by
    #1

    Thanks to help from nicolas we were able to modify the buttons_astcli.sh file to declare non numeric SIP peers as trunks. Previously if you ran the script prior to defining the trunks themselves, the script would intepret them as regular peers (and ignore the trunks manually entered).

    Please note this only works for systems where the peer name is numeric and the trunks are not numeric

    Also change the MANAGERSECRET to match your fop2 AMI password.

    #!/bin/bash
    MANAGERUSER=fop2
    MANAGERSECRET=CHANGETOYOURPASSWORD
    MANAGERHOST=localhost
    function isNumeric(){ [ "$(echo $*|grep -v "[^0-9]")" ];}
    /usr/local/fop2/astcli -u $MANAGERUSER -s $MANAGERSECRET -h $MANAGERHOST "sip show peers" |  sed '/Monitored/d' |sed '/Name\/username/d' | sort | while read LINEA
    do
    EXTEN=`echo $LINEA | cut -d\/ -f 1`
    EXTEN=`echo $EXTEN | awk '{ print $1}'`
    CONTEXT=`./astcli -u $MANAGERUSER -s $MANAGERSECRET -h $MANAGERHOST "sip show peer $EXTEN" | grep Context | cut  -d: -f 2 | sed 's/ //g'`
    CIDNAME=`./astcli -u $MANAGERUSER -s $MANAGERSECRET -h $MANAGERHOST "sip show peer $EXTEN" | grep Callerid | cut  -d: -f 2 | cut -d\< -f 1 | sed 's/ "//g' | sed 's/"//g'`
    MAILBOX=`./astcli -u $MANAGERUSER -s $MANAGERSECRET -h $MANAGERHOST "sip show peer $EXTEN" | grep Mailbox | cut  -d: -f 2 | sed 's/ //g'`
    TYPE="type=trunk"
    LABEL="label=$EXTEN"
    EXTENSION="channel=SIP/$EXTEN"
    MAIL="server=0"
    CON=""
    $(isNumeric $EXTEN) && TYPE="type=extension" && LABEL="label=$CIDNAME" && EXTENSION="extension=$EXTEN" && MAIL="mailbox=$MAILBOX" && CON="context=$CONTEXT"
    echo "[SIP/$EXTEN]"
    echo $TYPE
    echo $EXTENSION
    echo $LABEL
    echo $MAIL
    echo $CON
    echo
    done
    
    1 Reply Last reply
    0
    • N
      N
      nicolas
      wrote on last edited by
      #2

      Thanks!

      Just wanted to mention that this script is NOT TO BE USED IN FREEPBX BASED SYSTEMS, it is just for plain/vanilla Asterisk setups.

      1 Reply Last reply
      0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      Powered by NodeBB Contributors
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups