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.
  4. Critical FreePBX vulnerability! Update your server immediately. Details here.

FYI Change Extension Number

Discussion in 'Help' started by krzykat, Jun 26, 2013.

  1. krzykat Guru

    Is there an easy way to change an extension number? I have an several extensions labeled 5615551212, 5615551213, etc. and want to change them to be 15615551212, etc.

    Can I just go into the SQL database and change the extension name there and then make another mod in FreePBX, then do apply and will it push the change to all the proper places?
  2. wardmundy Nerd Uno

    I wouldn't try it if I were you. The problem is that FreePBX uses the extension number as a key in numerous cross-linked tables. That's probably why you can't even do it within FreePBX. Here's an example from just one table...

    [IMG]
  3. krzykat Guru

    Yeah :( ... I was thinking the same, but wasn't sure which was the "KEY" and thought that maybe just changing that one and then forcing an "apply" that it would rebuild ... but this is a live system with 100 extensions+ so ... I'll just do it the long way of adding the new one, changing their device, then deleting the old one.

    Stick to standards on the front side and I wouldn't have had this problem :crazy:
  4. Clone the system or rig up a test system and try it!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! We love a good success story or even better a total mega-wreck crash and burn story..... :oops:
    krzykat likes this.
  5. lgaetz Pundit

    If there are a large number of extensions you could try a bulk export, bulk delete, edit the csv and then bulk import. If only a few then a manual delete and recreate is prob easiest.
  6. wardmundy Nerd Uno

    Just added a 90210 extension on a clean FreePBX 2.10 system and here's what you get in the MySQL tables:

    asterisk.devices: [IMG]


    asterisk.users: [IMG]


    asterisk.sip: [IMG]


    All of the above gets populated in /etc/asterisk like this:
    Code:
    extensions_additional.conf:exten => *8490210,1,Goto(app-campon-toggle,*84,1)
    extensions_additional.conf:exten => *8490210,hint,ccss:SIP/90210
    extensions_additional.conf:exten => *90210,1,Macro(vm,90210,DIRECTDIAL,${IVR_RETVM})
    extensions_additional.conf:exten => *90210,n,Goto(vmret,1)
    extensions_additional.conf:exten => 90210,1,Set(__RINGTIMER=${IF($[${DB(AMPUSER/90210/ringtimer)} > 0]?${DB(AMPUSER/90210/ringtimer)}:${RINGTIMER_DEFAULT})})
    extensions_additional.conf:exten => 90210,n,Macro(exten-vm,90210,90210,0,0,0)
    extensions_additional.conf:exten => 90210,n(dest),Set(__PICKUPMARK=)
    extensions_additional.conf:exten => 90210,n,Macro(vm,90210,${DIALSTATUS},${IVR_RETVM})
    extensions_additional.conf:exten => 90210,n,Goto(vmret,1)
    extensions_additional.conf:exten => 90210,hint,SIP/90210&Custom:DND90210
    extensions_additional.conf:exten => vmb90210,1,Macro(vm,90210,BUSY,${IVR_RETVM})
    extensions_additional.conf:exten => vmb90210,n,Goto(vmret,1)
    extensions_additional.conf:exten => vmu90210,1,Macro(vm,90210,NOANSWER,${IVR_RETVM})
    extensions_additional.conf:exten => vmu90210,n,Goto(vmret,1)
    extensions_additional.conf:exten => vms90210,1,Macro(vm,90210,NOMESSAGE,${IVR_RETVM})
    extensions_additional.conf:exten => vms90210,n,Goto(vmret,1)
    extensions_additional.conf:exten => *7690210,1,Goto(app-dnd-toggle,*76,1)
    extensions_additional.conf:exten => *7690210,hint,Custom:DEVDND90210
    extensions_additional.conf:exten => *74090210,1,Goto(app-cf-toggle,*740,1)
    extensions_additional.conf:exten => *74090210,hint,Custom:DEVCF90210
    extensions_additional.conf:exten => _*74090210.,1,Set(toext=${EXTEN:9})
    extensions_additional.conf:exten => _*74090210.,n,Goto(app-cf-toggle,*740,setdirect)
    extensions_additional.conf:exten => *2190210,1,Goto(app-fmf-toggle,*21,1)
    extensions_additional.conf:exten => *2190210,hint,Custom:FOLLOWME90210
    extensions_additional.conf:exten => *8090210,1,Goto(ext-intercom,${EXTEN},1)
    extensions_additional.conf:exten => *90210,1,Macro(blkvm-clr,)
    extensions_additional.conf:exten => *90210,n,Set(__NODEST=)
    extensions_additional.conf:exten => *90210,n,Macro(vm,90210,DIRECTDIAL,${IVR_RETVM})
    extensions_additional.conf:exten => *90210,n,GotoIf($["${IVR_RETVM}" = "RETURN" & "${IVR_CONTEXT}" != ""]?ext-local,vmret,playret)
    extensions_additional.conf:exten => 90210,1,Macro(blkvm-clr,)
    extensions_additional.conf:exten => 90210,n,Set(__NODEST=)
    extensions_additional.conf:exten => 90210,n,Goto(from-did-direct,90210,1)
    sip_additional.conf:[90210]
    sip_additional.conf:dial=SIP/90210
    sip_additional.conf:mailbox=90210@default
    sip_additional.conf:callerid=Test <90210>
    voicemail.conf:90210 => 1234,Test,joeschmo@hotmail.com,,attach=no|saycid=no|envelope=no|delete=no
    
    And then there's AstDB which shows the following entries for 90210:
    Code:
    /AMPUSER/90210/answermode                        : disabled           
    /AMPUSER/90210/ccss/cc_agent_policy              : generic             
    /AMPUSER/90210/ccss/cc_offer_timer                : 30                 
    /AMPUSER/90210/cfringtimer                        : 0                   
    /AMPUSER/90210/cidname                            : Test               
    /AMPUSER/90210/cidnum                            : 90210               
    /AMPUSER/90210/concurrency_limit                  : 0                   
    /AMPUSER/90210/device                            : 90210               
    /AMPUSER/90210/dialopts                          :                     
    /AMPUSER/90210/noanswer                          :                     
    /AMPUSER/90210/outboundcid                        :                     
    /AMPUSER/90210/password                          :                     
    /AMPUSER/90210/queues/qnostate                    : usestate           
    /AMPUSER/90210/recording                          :                     
    /AMPUSER/90210/recording/in/external              : dontcare           
    /AMPUSER/90210/recording/in/internal              : dontcare           
    /AMPUSER/90210/recording/ondemand                : disabled           
    /AMPUSER/90210/recording/out/external            : dontcare           
    /AMPUSER/90210/recording/out/internal            : dontcare           
    /AMPUSER/90210/recording/priority                : 10                 
    /AMPUSER/90210/ringtimer                          : 0                   
    /AMPUSER/90210/voicemail                          : default             
    /CW/90210                                        : ENABLED             
    /DEVICE/90210/default_user                        : 90210               
    /DEVICE/90210/dial                                : SIP/90210           
    /DEVICE/90210/type                                : fixed               
    /DEVICE/90210/user                                : 90210               
    
    So... you might could change it. But it would be hairy. :death:
    Last edited by wardmundy, Jun 26, 2013
  7. PBX@Home Active Member


    :yikes:
  8. wardmundy Nerd Uno

    Just for fun, I then shut down Asterisk and went into MySQL and replaced every occurrence of 90210 with 98199. I then restarted Asterisk, edited the new 98199 extension and saved it to force a reload of FreePBX. And here's what I got in the Asterisk DB, i.e. a mess:
    Code:
    /AMPUSER/90210/answermode                        : disabled   
    /AMPUSER/90210/ccss/cc_agent_policy              : generic     
    /AMPUSER/90210/ccss/cc_offer_timer                : 30         
    /AMPUSER/90210/cfringtimer                        : 0           
    /AMPUSER/90210/cidname                            : Test       
    /AMPUSER/90210/cidnum                            : 90210       
    /AMPUSER/90210/concurrency_limit                  : 0           
    /AMPUSER/90210/device                            : 90210       
    /AMPUSER/90210/dialopts                          :             
    /AMPUSER/90210/noanswer                          :             
    /AMPUSER/90210/outboundcid                        :             
    /AMPUSER/90210/password                          :             
    /AMPUSER/90210/queues/qnostate                    : usestate   
    /AMPUSER/90210/recording                          :             
    /AMPUSER/90210/recording/in/external              : dontcare   
    /AMPUSER/90210/recording/in/internal              : dontcare   
    /AMPUSER/90210/recording/ondemand                : disabled   
    /AMPUSER/90210/recording/out/external            : dontcare   
    /AMPUSER/90210/recording/out/internal            : dontcare   
    /AMPUSER/90210/recording/priority                : 10         
    /AMPUSER/90210/ringtimer                          : 0           
    /AMPUSER/90210/voicemail                          : default     
    /AMPUSER/98199/answermode                        : disabled   
    /AMPUSER/98199/ccss/cc_agent_policy              : generic     
    /AMPUSER/98199/ccss/cc_offer_timer                : 30         
    /AMPUSER/98199/cfringtimer                        : 0           
    /AMPUSER/98199/cidname                            : Test       
    /AMPUSER/98199/cidnum                            : 98199       
    /AMPUSER/98199/concurrency_limit                  : 0           
    /AMPUSER/98199/device                            : 98199       
    /AMPUSER/98199/noanswer                          :             
    /AMPUSER/98199/outboundcid                        :             
    /AMPUSER/98199/password                          :             
    /AMPUSER/98199/queues/qnostate                    : usestate   
    /AMPUSER/98199/recording                          :             
    /AMPUSER/98199/recording/in/external              : dontcare   
    /AMPUSER/98199/recording/in/internal              : dontcare   
    /AMPUSER/98199/recording/ondemand                : disabled   
    /AMPUSER/98199/recording/out/external            : dontcare   
    /AMPUSER/98199/recording/out/internal            : dontcare   
    /AMPUSER/98199/recording/priority                : 0           
    /AMPUSER/98199/ringtimer                          : 0           
    /AMPUSER/98199/voicemail                          : novm       
    /CW/90210                                        : ENABLED     
    /DEVICE/90210/default_user                        : 90210       
    /DEVICE/90210/dial                                : SIP/90210   
    /DEVICE/90210/type                                : fixed       
    /DEVICE/90210/user                                : 90210       
    /DEVICE/98199/default_user                        : 98199       
    /DEVICE/98199/dial                                : SIP/98199   
    /DEVICE/98199/type                                : fixed       
    /DEVICE/98199/user                                : 98199       
    
    So... using the Asterisk CLI, I issued the following commands:
    Code:
    database deltree DEVICE/90210
    database deltree AMPUSER/90210
    database deltree DEVICE/98199
    database deltree AMPUSER/98199
    database deltree CW/90210
    On our particular testbed, this basically left the AstDB with nothing other than the dundi entries. I then restarted Asterisk and went back into FreePBX and resaved extension 98199. Then here's what I got in the Asterisk DB which looks clean to me:
    Code:
    /AMPUSER/98199/answermode                        : disabled     
    /AMPUSER/98199/ccss/cc_agent_policy              : generic       
    /AMPUSER/98199/ccss/cc_offer_timer                : 30           
    /AMPUSER/98199/cfringtimer                        : 0             
    /AMPUSER/98199/cidname                            : Test         
    /AMPUSER/98199/cidnum                            : 98199         
    /AMPUSER/98199/concurrency_limit                  : 0             
    /AMPUSER/98199/device                            : 98199         
    /AMPUSER/98199/noanswer                          :               
    /AMPUSER/98199/outboundcid                        :               
    /AMPUSER/98199/password                          :               
    /AMPUSER/98199/queues/qnostate                    : usestate     
    /AMPUSER/98199/recording                          :               
    /AMPUSER/98199/recording/in/external              : dontcare     
    /AMPUSER/98199/recording/in/internal              : dontcare     
    /AMPUSER/98199/recording/ondemand                : disabled     
    /AMPUSER/98199/recording/out/external            : dontcare     
    /AMPUSER/98199/recording/out/internal            : dontcare     
    /AMPUSER/98199/recording/priority                : 0             
    /AMPUSER/98199/ringtimer                          : 0             
    /AMPUSER/98199/voicemail                          : novm         
    /DEVICE/98199/default_user                        : 98199         
    /DEVICE/98199/dial                                : SIP/98199     
    /DEVICE/98199/type                                : fixed         
    /DEVICE/98199/user                                : 98199
    
    This left everything looking OK except for CW entry which was gone and would need to be manually reentered (or you could adjust the existing entry rather than deleting the CW tree)
    Code:
    /CW/98199                                        : ENABLED
    AND the /etc/asterisk/voicemail.conf entry was unchanged:
    Code:
    voicemail.conf:90210 => 1234,Test,joeschmo@hotmail.com,,attach=no|saycid=no|envelope=no|delete=no
    AND the voicemail directory structure was still a mess:
    1. /var/spool/asterisk/voicemail/device now had a dangling symlink to 90210
    2. /var/spool/asterisk/voicemail/default had blown away the 90210 directory tree and not added 98199

    This could all be manually fixed (maybe) and Asterisk restarted once again, and all should might be well. Didn't try actually making a call in or out. Thought I'd save that until after I've had a few beers. :gunsmilie:
    Last edited by wardmundy, Jun 26, 2013
  9. krzykat Guru

    Thanks Ward ... that answers it. Don't do it :)
  10. jeff.h Guru

    So... this very question was posed to me today. One of my sites got a new concurrent range of DIDs (previously just had one inbound number) and now they want all their extensions to match the last 4 of each person's DID. No problem, I can create new extensions and reprogram all the phones, but no one wants to re-record their VM greetings.

    Is there a way to move the VM greeting and saved messages from one extension to another? Without ending up :banghead:
  11. randy7376 Guru

    @jeff.h

    Sure. You can rsync the voicemail from the old extension to the new one and it should be fine. The only thing to note is that the message information file (msgxxxx.txt) will contain the original mailbox you copied from (see originalmailbox=X in the file) and that all of the copied messages will show up as new messages.

    I haven't encountered any issues doing this, but you may want to test it out before doing it en-mass just to be sure.
  12. jeff.h Guru



    Will that bring the greeting over as well?
  13. randy7376 Guru

    @jeff.h

    I'm not sure how familiar you are with rsync, but yes, it will bring the greeting over. Essentially, you can do something like this for each extension:

    Code:
     rsync -av --progress /var/spool/asterisk/voicemail/default/123/ /var/spool/asterisk/voicemail/default/12345
    Where 123 would be the old extension and 12345 would be the new extension. This will copy everything from the top of 123 on down over to 12345 with the same filenames and directory structure.
  14. jeff.h Guru

    OK. Thanks for that! I've never used rsync before. I will give that a try.

Share This Page