1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

GOOD NEWS New Incredible PBX for RasPi3

Discussion in 'Today's Tech News & Events' started by wardmundy, Sep 14, 2017.

  1. wardmundy

    wardmundy Nerd Uno

    Joined:
    Oct 12, 2007
    Messages:
    13,825
    Likes Received:
    2,293
    A less elaborate, but still helpful, rendition of @TirsoJRP masterpiece...

    [​IMG]

    [​IMG]
     
  2. TirsoJRP

    TirsoJRP Member

    Joined:
    Jan 8, 2015
    Messages:
    72
    Likes Received:
    25
    pbxstatus mod for Raspberry Pi users:

    Adds CPU temperature and chan_dongle details: name, provider, signal level and states.

    replace /usr/local/sbin/pbxstatus with the code below:

    Code:
    #!/bin/bash
    DN="\Z1\ZrDN\Z0\ZR";
    UP="\Zr\Z2UP\Z0\ZR";
    
    if hostname -I > /etc/hostip; then
        _IP="Private IP: `cat /etc/hostip`"
      if [ -f "/etc/pbx/.phone" ]; then
        _PHONE="Ph: `cat /etc/pbx/.phone`"
      else
        _PHONE=" "
      fi
        _PUBLIC="Public  IP: `curl -s -S --user-agent "Mozilla/4.0" http://myip.incrediblepbx.com | awk 'NR==2'` $_PHONE"
    else
       _IP=""
       _PUBLIC=""
    fi
    version=`cat /etc/pbx/.version`
    astversion=`asterisk -rx "core show version" | grep -m 2 ^ | tail -1 | cut -f 2 -d " "`
    fpbxversion=`cat /var/www/html/admin/modules/core/module.xml | grep version | head -n 1 | cut -f 2 -d ">" | cut -f 1 -d "<"`
    OSrelease=`cat /etc/os-release | grep "PRETTY_NAME" | cut -f 2 -d "=" | sed "s|\"||g" | sed "s|(Core)|Core|"`
    #OSrelease=" `cat /etc/os-release | cut -f 1 -d "(" | sed 's|Scientific Linux release|Scientific Linux|'`"
    
    test=`cat /etc/os-release | grep "Scientific Linux"`
    if [[ -z $test ]]; then
     TITLE="Incredible PBX $version for Raspberry Pi 2/3"
    else
     TITLE="  Incredible PBX $version for Scientific Linux"
    fi
    
    test=`asterisk -rx "cdr show status" | grep Enabled`
    if [[ -z $test ]]; then
     asterisk="$DN"
    else
     asterisk="$UP"
    fi
    test=`service apache2 status | grep running`
    if [[ -z $test ]]; then
     apache="$DN"
    else
     apache="$UP"
    fi
    test=`ps aux | grep -c mysqld`
    if [ "$test" -lt "2" ]; then
     mysql="$DN"
    else
     mysql="$UP"
    fi
    test=`service webmin status | grep -c running`
    if [[ -z $test ]]; then
     webmin="$DN"
    else
     webmin="$UP"
    fi
    test=`service ssh status | grep -c running`
    if [[ -z $test ]]; then
     ssh="$DN"
    else
     ssh="$UP"
    fi
    test=`asterisk -rx "module show like sccp" | grep -c Running`
    if [[ -z $test ]]; then
     sccp="$DN"
    else
     sccp="$UP"
    fi
    test=`ps aux | grep -c sendmail`
    if [ "$test" -lt "2" ]; then
     sendmail="$DN"
    else
     sendmail="$UP"
    fi
    test=`ps aux | grep -c faxgetty`
    if [ "$test" -lt "2" ]; then
     faxgetty="$DN"
    else
     faxgetty="$UP"
    fi
    test=`ps aux | grep -c iaxmodem`
    if [ "$test" -lt "2" ]; then
     iaxmodem="$DN"
    else
     iaxmodem="$UP"
    fi
    test=`service fail2ban status | grep running`
    if [[ -z "$test" ]]; then
     fail2ban="$DN"
    else
     fail2ban="$UP"
    fi
    test=`ps aux | grep -c ntpd`
    if [ "$test" -lt "2" ]; then
     ntpd="$DN"
    else
     ntpd="$UP"
    fi
    test=`iptables -nL | grep DROP`
    if [[ -z $test ]]; then
     IPtables="$DN"
    else
     IPtables="$UP"
    fi
    #IPPORT=`ifconfig | head -1 | cut -f 1 -d ":"`
    IPPORT=`ifconfig | grep inet | head -1 | cut -f 2 -d ":" | cut -f 1 -d " "`
    #IPPORT='eth0'
    test=`/sbin/ifconfig | grep -c inet`
    if [ "$test" -lt "2" ]; then
     eth0="$DN"
    else
     eth0="$UP"
    fi
    
    test=`cat /etc/pbx/.version`
    if [[ "$test" < "13-12.17" ]]; then
     gvoauth="$UP"
    else
     gvoauth="$UP"
    fi
    test=`ps aux | grep -c hfaxd`
    if [ "$test" -lt "2" ]; then
     hfax="$DN"
    else
     hfax="$UP"
    fi
    test=`ps aux | grep -c nrservice`
    if [ "$test" -lt "2" ]; then
     nrclient="$DN"
    else
     nrclient="$UP"
    fi
    test=`asterisk -rx "module show like chan_dongle" | grep -c Running`
    if [[ -z $test ]]; then
     chan_dongle="$DN"
    else
     chan_dongle="$UP"
    fi
    
    revision=`cat /proc/cpuinfo | grep Revision | cut -f 2 -d ":"`
    if [ "$revision" = " a21041" ]; then
      model="2B"
    elif [ "$revision" = " a01041" ]; then
      model="2B"
    elif [ "$revision" = " a02082" ]; then
      model="3B"
    elif [ "$revision" = " a22042" ]; then
      model="2B"
    elif [ "$revision" = " a01040" ]; then
      model="2B"
    elif [ "$revision" = " a02082" ]; then
      model="3B"
    elif [ "$revision" = " a22082" ]; then
      model="3B"
    elif [ "$revision" = " a32082" ]; then
      model="3B"
    elif [ "$revision" = " 9000c1" ]; then
      model="ZeroW"
    elif [ "${revision:0:3}" = " 00" ]; then
      model="1"
    elif [ "$revision" = " 900092" ]; then
      model="0"
    else
      model="3"
    fi
    TITLE="Incredible PBX $version for Raspberry Pi $model"
    
    
    RAM=`free | tr -s " " | grep -m 2 ^ | tail -1 | cut -f 4 -d " "`
    if [ -z "$RAM" ]; then
     RAM="`free | grep -m 2 ^ | tail -1 | cut -f 18 -d " "`"
     if [ -z "$RAM" ]; then
      RAM=" `free | grep -m 2 ^ | tail -1 | cut -f 19 -d " "`"
     fi
    fi
    DISK=`df -h | tr -s ' ' |grep " /" | head -n 1 | cut -f 4 -d " "`
    #DISK=`df -h | grep -m 2 ^ | tail -1 | cut -f 15 -d " "`
    if [ -z "$DISK" ]; then
     DISK=" `df -h | grep -m 2 ^ | tail -1 | cut -f 9 -d " "`"
    fi
    if [ "${#DISK}" -eq "4" ]; then
     DISK=" $DISK"
    fi
    
    NOW=`date`
    
    #Temperature
    TEMP=`/opt/vc/bin/vcgencmd measure_temp | cut -d '=' -f2 | sed 's/..$//'`
    
    TEMPINT=`printf '%.*f\n' 0 $TEMP`
    
    if ((TEMPINT <= 40)); then
      TEMP="4\ZB$TEMP°C"
    elif ((TEMPINT >= 40 && TEMPINT <= 50)); then
      TEMP="2\ZB$TEMP°C"
    elif ((TEMPINT >= 50 && TEMPINT <= 60)); then
      TEMP="3$TEMP°C!"
    elif ((TEMPINT >= 60)); then
      TEMP="1$TEMP°C!!"
    fi
    
    #chan_dongle
    devs=0
    IFS=$'\n'
    dongles=`asterisk -rx "dongle show devices" | sed -n '1!p'`
    for don in $dongles
     do
     devs=$((devs+1))
     DEV=`echo $don | cut -c 1-13`
     RSTATE=`echo $don | cut -c 20-30 | sed 's/ //g'`
     PROV=`echo $don | cut -c 49-59 | sed 's/[^ ]\+/\L\u&/g'`
     RSSI=`echo $don | cut -c 31-32 | sed 's/ //g'`
     
    if ((RSSI <= 2)); then
      RSSI="\Z1OOOO"
    elif ((RSSI >= 2 && RSSI <= 9)); then
      RSSI="\Z1●OOO"
    elif ((RSSI >= 10 && RSSI <= 14)); then
      RSSI="\Z3●●OO"
    elif ((RSSI >= 15 && RSSI <= 19)); then
      RSSI="\Z6●●●O"
    elif ((RSSI >= 20)); then
      RSSI="\Z2●●●●"
    fi
    
    PROV="$PROV$RSSI "
     
      case "$RSTATE" in
       Free)
        state="\Z2Free";;
       Dialing)
        state="\Z4Dialing";;
       Outgoing)
        state="\Z6Outgoing call";;
       Notconnec)
        state="\Z1Not Connected";;
       Incoming)
        state="\Z5Incoming call";;
      esac
    
     cdmsg="$cdmsg$DEV$PROV\Zr$state\ZR\Z0\n"
     headers="\nDevice       Provider    Ɏ   State\n\ZB"
    done
    unset IFS
    #end of chan_dongle
    
    MSGLEN=`echo ${#TEMP}`
    
    TOP="\n\ZbAsterisk\ZB: $asterisk      \ZbApache\ZB: $apache \Zb MariaDB\ZB: $mysql\n\ZbSendMail\ZB: $sendmail    \ZbIPtables\ZB: $IPtables      \ZbSSH\ZB: $ssh\n\ZbLAN port\ZB: $eth0    \ZbFail2Ban\ZB: $fail2ban   \ZbWebmin\ZB: $webmin\n\ZbGV OAUTH\ZB: $gvoauth  \Zb Chan-SCCP\ZB: $sccp   \ZbNR VPN\ZB: $nrclient\n\ZbFaxGetty\ZB: $faxgetty  \Zb IAX Modem\ZB: $iaxmodem  \ZbHylaFax\ZB: $hfax\n"
    #DNG="\Z0\ZbChDongle\ZB: $chan_dongle     \ZbDevices:  $devs\n$cdmsg\Z$TEMP\n\Zr\Z4\Zb"
    if [[ $MSGLEN > 7 ]]; then
     DNG="\Z0\ZbTemp \Z$TEMP \Z0\ZbChan_Dongle\ZB: $chan_dongle  \ZbDevices:  $devs\n$cdmsg\n\Zr\Z4\Zb"
    else
     DNG="\Z0\ZbTemp: \Z$TEMP \Z0\ZbChan_Dongle\ZB: $chan_dongle  \ZbDevices:  $devs\n$cdmsg\n\Zr\Z4\Zb"
    fi
    MID="RAM\ZB:$RAM  Raspbian (Jessie)  \ZbDisk\ZB:$DISK\ZR\Z0\n\n\Z5\Zb"
    BOT="Asterisk $astversion  +  GUI ver. $fpbxversion\ZB\Z0\n\n\ZR\Zb$_IP\n\n$_PUBLIC\ZB\n\n\Zb\Z4System Time: $NOW"
    
    
    MSGLEN=`echo ${#MID}`
    
    if [ "$MSGLEN" -gt "95" ]; then
    # MID2=`echo $MID| sed -e 's/  / /g'`
     MID2=$MID
     MID=`echo $MID2| sed -e 's/Disk/ Disk/g'`
     MID2=`echo $MID| sed -e 's/: /:/g'`
    fi
    
    MSG="$TOP$DNG$MID$BOT"
    
    lines=$((22 + devs))
    
    dialog --no-lines --colors --title "$TITLE" --msgbox "$MSG" $lines 47
    
    clear
     
  3. TirsoJRP

    TirsoJRP Member

    Joined:
    Jan 8, 2015
    Messages:
    72
    Likes Received:
    25
    I am having an issue with chan_dongle IncrediblePBX and I am going nuts on this one.

    I have been able to replicate the issue. On the network where the RPi was configured it works flawlessly (dhcp, reserved, 10.0.1.4/24), If I try on another network (10.0.0.4/24) it is one way audio only.

    As soon as I troubleshoot the issue I will report back.

    Edit 1: It is not limited to chan_dongle.

    Edit 2: No audio on *43... did I miss something with the firewall configuration?
     
    #43 TirsoJRP, Feb 19, 2018 at 6:50 PM
    Last edited: Feb 19, 2018 at 9:09 PM
  4. geopeterwc

    geopeterwc Guru

    Joined:
    Aug 17, 2010
    Messages:
    194
    Likes Received:
    45
    Not the firewall, but the RPi needs to know what network it's on. When you moved the RPi to the new network, did you go back into the Asterisk SIP Settings and update the "Local Network Settings" to reflect the new network? Click the "Detect External IP" button and then "Submit" and "Apply Config"? (I don't know how many times I've been tripped up by failing to perform this very simple, but important step.)

    You can access the RPi GUI from a computer/browser on the same network, provided you know the IP address assigned to the RPi.

    /Pete./
     
    wardmundy likes this.

Share This Page