1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. If you had a PIAF Forum account in the vBulletin days, log in with your old credentials. Otherwise, sign up again and we'll get you back in business as soon as we can.
  3. A serious FreePBX vulnerability has been reported. Update your Framework Module immediately. Click here for details.

To Load or Not to Load res_jabber chan_gtalk

Discussion in 'Developers' Corner' started by Hyksos, Feb 10, 2012.

  1. Hyksos Guru

    Like I said in another thread I'm reinstalling the hell out of piaf currently messing with vmware and installing piaf into it from a usb key.

    Works well considering the key never really knows by itself how the machine will set up the /dev/sd*.
    I used iso2usb without any modifications except for messing with the sda, sdb, etc. But I guess that is for another day.

    Doing that I realized that by default piaf creates problem for every install where gvoice won't be used. Yeah It's not news I have to s/load/noload for the modules in modules.conf if I don't use gvoice.

    That is my question, is it really good default behavior to enable those and have the system fill the logs and ramp up memory usage for every install where gvoice is not used and the user doesn't know immediately he should noload those modules?

    Ok, so it's not a bug, I posted it here since my goal is to understand why the system is delivered "broken" or assuming you will use gvoice. Let's be clear by broken I simply mean that if someone inputs no gvoice trunks and doesn't noload the modules the system is indeed not a good "state" and you eventually realize it from the ram usage of the log filling up.

    I lot of stuff is in piaf/incredible that all the people don't use, I'm for that and think it's great that it's easily accessible if I need it (I love piaf like everybody for that reason) but not a lot of it actually "break" the system just because I don't use it.

    I wonder what people who know more about all of it think of this and if it's by design? In a perfect world where I bounty it up to the right guy, what would be the problem if those modules where enabled when the first gvoice trunk is created and disabled when the last one is deleted? Is it all there is to it? Maybe it's not like that simply because the gvoice module was not created by someone on the piaf dev team and so it currently does not enable or disable it's "dependencies" in the modules.conf.

    What am I not getting here?
  2. wardmundy Nerd Uno

    Assumption: Gurus RTFM At Least When Something Is Broken

    Excellent question. The Google Voice setup is by design. Our focus always has been to simplify VoIP deployment for individual users. The thought process was that we're building a setup for "most people" so that it will work out of the box. As delivered with the existing Google Voice module for FreePBX, the system is going to be "broken" for someone insofar as Google Voice is concerned. So the question becomes whether to break it for the majority or for the purists that want a GVoice-free platform. Our thinking was that the purists know better how to diagnose and solve issues. And, the fix is clearly documented in our article explaining how to install PIAF2 (snippet below). It takes less than 30 seconds to fix it. Since Google Voice provides a free calling service in the U.S. and Canada, our assumption remains that "most people" will use it or at least try it. And, once you've tried it, I really can't imagine why anyone wouldn't use it. Google Voice has terrific sound quality! Hope this helps.


    P.S. I've actually looked at modifying the Google Voice setup so that this is automagic. A simple mysql query would tell us whether a Google Voice trunk had been set up. The problem is that an amportal restart is required (with root permissions) to get Google Voice working or disabled. So the test for whether to load these modules would need to occur in /usr/sbin/amportal. Because that really gets into the guts of FreePBX, I'm reluctant to make such a change because it would move us away from distributing a "stock version" of FreePBX.

    Here's the necessary MySQL query if you want to determine whether Google Voice accounts have been enabled:

    mysql --column-names=0 asterisk -uroot -ppassw0rd <<< "SELECT phonenum FROM googlevoice"

    Helpful Asterisk commands to determine if Google Voice is running:

    asterisk -rx "module show like jabber"
    asterisk -rx "core show channeltype gtalk"

    Helpful SED commands to disable Google Voice:

    sed -i 's|load => res_jabber.so|noload => res_jabber.so|' /etc/asterisk/modules.conf
    sed -i 's|load => chan_gtalk.so|noload => chan_gtalk.so|' /etc/asterisk/modules.conf
    amportal restart

    Helpful SED commands to enable Google Voice:

    sed -i 's|noload => res_jabber.so|load => res_jabber.so|' /etc/asterisk/modules.conf
    sed -i 's|noload => chan_gtalk.so|load => chan_gtalk.so|' /etc/asterisk/modules.conf
    amportal restart
  3. dad311 Guru

    Its not so much the chatter, it's the fact that left unused, it can stop the extensions from ringing. This is due to high memory usage a few days after install.

    I do believe the GV modules should be off by default.
  4. Boolah Guru

    What if part of the installation process is to ask the user if they plan to use GV? If they say "Yes", then load the modules. If they say "No", don't. In either case, compile the modules so they're available on the system for the user to enable/disable in the future.
  5. wardmundy Nerd Uno

    We're not going to change the default at this juncture, but that's certainly an approach worth considering. The problem becomes when folks "forget" what choice they made and later complain that Google Voice doesn't work. That was why I mentioned adjusting amportal because then It Just Works™ all the time.

    Another option might be to modify status so that it shows whether GVoice is Enabled or Disabled. We could replace SendMail perhaps (which is always enabled).

    Then we could add Enable-GVoice and Disable-GVoice scripts as shown above. We could add a test in the disable script to warn or refuse to disable (?) if they have Google Voice numbers already set up (using the MySQL test shown above).

    Perhaps the middle-of-the-road approach is to ask whether the user intends to use Google Voice during the initial install. If the answer is yes, then we leave the system the way it is now. If the answer is no, then we substitute an altered version of amportal that can handle the gtalk activation and deactivation automatically.

    Of course, we'd be doing all of this to avoid a 30-second fix (more like 2 seconds with the scripts above) mostly by gurus that already know how to do it manually themselves. :crazy:
  6. darmock PIAF Developer

    I tend to agree with Ward. Personally I can just imagine the endless whining "I installed PIAF but google broke" then "fix". As for running it during initial install...we have thought about this from a human engineering standpoint. Newbs tend to NOT understand the ramifications of enabling/disabling things. Also they "FORGET"

    I suspect the only way to do it is some form of autonomy like running a daily cron that checks to see if GV is enabled and NO phone number then email root. This all depends on humans again. Of course we could always place a screen that displays each time the user logs in if google is enabled WITHOUT a phone number and suggest they disable it. I like nagware better,

  7. dad311 Guru

    How about a simple check box in the FreePBX GV setup? Check the box, modules are loaded, unchecked the box modules are unloaded.

    Also, send an email if GV is having issues connecting. Last week I changed the GV password, and two days later my phones stop rinnging and all call went to VM, Memory usage was at 85%.
  8. Hyksos Guru

    Of course it is splitting hairs!
    But piaf is so nice making it better often means splitting hairs no? ;)

    About changing amportal just for some install:
    I think the system would become more unpredictable since some people would get a "somehow" fundamentally different system depending on their initial answer to the question during the install. I think it would actually be worst then right now, some would be on the manual system (like right now) and some would have the automatic system in amportal. And people would change their minds and people in both those groups would end up starting and stopping to use gvoice... worst then now...

    If amportal is to be modified, it should be for all, and if you're right that it breaks the stock freepbx install and it's a big no-no then amportal should not be modified at all.

    Where am I wrong thinking it could be handled in the gvoice module? Ward's enabling/disabling code could be added there with logic that would enable on first creation of a gvoice trunk and disable upon deletion of the last gvoice trunk. Maybe that is not doable? But do you agree that it would be perfect or I'm mistaken.

    About the fact I'm obvously splitting hairs for two "no". I'm surprised only one other person agreed that right now the system, even considering Ward's article is not clear about the fact that the system's health is dependant on those modules being in the right state: reflecting the presence or absence of gvoice trunk and we could add "with valid password" but i'm pushing it ;)

    The reality is: piaf need me to make sure that each time I stop using gvoice I go and disable the modules and then I want to start gvoicing again I reload them. Failure to be anal about it will result in a broken down system.

    It's ok if the system does not handle it perfectly by itself (this thread is about doing that) but then the article should not only mention how to disable it but declare that the system will break if it's kept enabled and no gvoice trunk are created in the following (hours)days. It's not that specific and it does not warn people about that right now.

    And maybe the simple thing to do is not handling it at all if it's too complicated like my idea of the gvoice module doing it but simply nagware like Tom said. But instead of reporting the status of the modules alone I would report the "sanity" of gvoice.

    gtalk and jabber are loaded AND you have at least one gvoice trunk OK
    gtalk and jabber are loaded AND you have no gvoice trunk: actions needed
    (kinda, see what I mean?, EDIT: I realize it's like Tom email thing, you get what I mean by "combination" of factors)

    Because it's not their status itself that is important but the combination of their status AND the presence of at least one valid trunk.

    Sorry for all this passion and words...
  9. wardmundy Nerd Uno

    Pioneers Only!!


    UPDATE: One-click script is now available on the next page.

    PURPOSE: The purpose of this patch is to automatically enable and disable the Jabber and Gtalk modules in Asterisk based upon whether Google Voice DIDs have been enabled using the FreePBX Google Voice module.

    INSTALLATION: If you want to test this, make a backup copy of /usr/local/sbin/amportal first: cp /usr/local/sbin/amportal /usr/local/sbin/amportal2

    Then edit /usr/local/sbin/amportal and insert this patch immediately below (i.e. under) the group of lines that read:

    Here is the code to insert below the fi line:

    gvtest=`mysql --column-names=0 asterisk -uroot -ppassw0rd <<< "SELECT phonenum FROM googlevoice"`
    if [ -z $gvtest ]; then
     echo "No Google Voice DIDs configured. Disabling Gtalk and Jabber..."
     sed -i 's|noload => res_jabber.so|load => res_jabber.so|' /etc/asterisk/modules.conf
     sed -i 's|noload => chan_gtalk.so|load => chan_gtalk.so|' /etc/asterisk/modules.conf
     sed -i 's|load => res_jabber.so|noload => res_jabber.so|' /etc/asterisk/modules.conf
     sed -i 's|load => chan_gtalk.so|noload => chan_gtalk.so|' /etc/asterisk/modules.conf
     echo "Google Voice DIDs are configured. Enabling GTalk and Jabber..."
     sed -i 's|noload => res_jabber.so|load => res_jabber.so|' /etc/asterisk/modules.conf
     sed -i 's|noload => chan_gtalk.so|load => chan_gtalk.so|' /etc/asterisk/modules.conf

    OPERATION: Whenever you make a change to your Google Voice setup using the FreePBX GoogleVoice module, simply issue amportal restart while logged into the Linux CLI as root... just as you do now.

    Let me know how it goes.
  10. wardmundy Nerd Uno

    Because of multiple versions of amportal depending upon your setup and whether you're running PIAF2 in a virtual machine, the location to insert the patch has been changed! See the previous post for the current code and location.
  11. Hyksos Guru

    Good show Ward!

    It works like a charm and the way it's designed it works even if I mess with modules.conf by hand. So far I'm not able to break it.

    Of course just by looking at it we can easily see it's hard to break ;)

    Is it a toy for me? Or do you consider using it in piaf someday? It's exactly what I was referring to, the system is now autosensing whether those module should be loaded or not to remain sane even if the user couldn't care less about gvoice and do not check the related documentation and posts about it.

    I think Piaf would be hardened by something like that. But I see that you don't discuss in details the pitfalls about different versions of amportal and the fact that you did not want to depart from the stock freepbx.

    I guess you want to see it age a bit while people think about it but WOW! This is nice and you guys know your stuff!
  12. tm1000 Schmoozecom INC/FreePBX

    Why can't we just do:

    asterisk -rx 'load res_jabber.so'
    asterisk -rx 'load chan_gtalk.so'
    asterisk -rx 'restart gracefully'

    Apache is allowed to modify /etc/asterisk/modules.conf. Is it not? If so then change the google voice module to just restart asterisk with the above command? no?
  13. wardmundy Nerd Uno

    tm1000: You're the FreePBX whiz kid. Never have been able to use the GV FreePBX GUI independently without subsequent amportal restarts from Linux CLI. Problem is that the FreePBX reload would occur after the Asterisk restart if it were embedded in the GV code. I don't know whether that's a deal breaker or not. But... would love to see it work this way. :D
  14. wardmundy Nerd Uno

    One-Click Install Script

    Here's a new one-click install script to apply the amportal patch on PIAF2 systems only:

    cd /root
    wget http://pbxinaflash.com/amportal-patch
    chmod +x amportal-patch

    After applying the patch, whenever you make changes to your Google Voice setup using the module in FreePBX, simply log into your server's Linux CLI as root and issue the command: amportal restart

Share This Page