Stop Freepbx from resetting configurations file

I have some configuration that need to be carried from which i create custom config files via the Config Edit feature of trixbox. I have though upgraded FreePBX to 2.4 and no when i try to create some of the extras when I make additional trunks and so on the changes i have made are removed and returned to previous configuration.

I do not make any changes to existing configuration I only add custom configuration.

An example


include => macro-outbound-callerid-custom
exten => s,3,GotoIf($["${REALCALLERIDNUM:1:2}" != “”]?start)
exten => s,n,Set(REALCALLERIDNUM=${CALLERID(number)})
exten => s,n(start),Noop(REALCALLERIDNUM is ${REALCALLERIDNUM})
exten => s,n,GotoIf($["${KEEPCID}" != “TRUE”]?normcid)
exten => s,n,GotoIf($[“x${OUTKEEPCID_${ARG1}}” = “xon”]?normcid)
exten => s,n,GotoIf($[“foo${REALCALLERIDNUM}” = “foo”]?normcid)
exten => s,n,GotoIf($[“foo${DB(AMPUSER/${REALCALLERIDNUM}/device)}” = “foo”]?bypass:normcid)
exten => s,n(normcid),Set(USEROUTCID=${DB(AMPUSER/${REALCALLERIDNUM}/outboundcid)})
exten => s,n(bypass),Set(EMERGENCYCID=${DB(DEVICE/${REALCALLERIDNUM}/emergency_cid)})
exten => s,n,Set(TRUNKOUTCID=${OUTCID_${ARG1}})
exten => s,n,GotoIf($["${EMERGENCYROUTE:1:2}" = “”]?trunkcid)
exten => s,n,GotoIf($["${EMERGENCYCID:1:2}" = “”]?trunkcid)
exten => s,n,Set(CALLERID(all)=${EMERGENCYCID})
exten => s,n,Goto(report)
exten => s,n(trunkcid),GotoIf($["${TRUNKOUTCID:1:2}" = “”]?usercid)
exten => s,n,Set(CALLERID(all)=${TRUNKOUTCID})
exten => s,n(usercid),GotoIf($["${USEROUTCID:1:2}" = “”]?report)
exten => s,n,Set(CALLERID(all)=${USEROUTCID})
exten => s,n,GotoIf($[“x${CALLERID(name)}”!=“xhidden”]?report:hidecid)
exten => s,n(hidecid),SetCallerPres(prohib_passed_screen)
exten => s,n(report),Noop(CallerID set to ${CALLERID(all)})

; end of [macro-outbound-callerid]

I then add directly underneath


exten => s,1,Set(headerinfo=${SIP_HEADER(from)})
exten => s,2,Set(pseudodid=${CUT(headerinfo,",-2)})

; end of [macro-outbound-callerid-custom]

click update and the updates are updated.

When i add a trunk for example and the click submit and then apply, all of the modifications have disappeared.
Is this normal? and how can I stop the resetting?
By the way, i know the above configuration does not reset on FreePBX 2.3

extensions_additional.conf should have been replaced in FreeePBX 2.3 and 2.2 every single time there was a change in the dialplan unless you write protected the file so that the system could not write the change.

The general rule with FreePBX is that if the file does not end in *_custom.conf it can and will get overwritten as those are system generated files. if you needto edit, replace or override something then put it in a *_custom.conf file and it will get loaded.

So you can put your changes in extensions_custom.conf by placing the whole macro as you have pasted it here into that file and it will be used instead of the one in extensions_additional.conf.

I do believe that you ment to say extension.conf instead of extension_additional.conf as that is where that macro is located by default. But the above notes still apply.

Actually in my system 2.4 it is written in extensions_additional.conf, unfortunately write protecting this file would prohibit trunk files to be modified as well.

Maybe it needs to be removed and relocated to the extension.conf file but I can imagine if changes are made then it will be reset again and re-added.

Not sure if i can win on this one.

don’t ever plan on editing extensions_additional.conf. If you need to override something, then redeclare the entire context in extensions_override_freepbx.conf.

Nevermind, i am learning this, unfortunately FreePBX has some limitations that can only be resolved modifying the Extension.conf and extension_additional.conf. If I was to add configuration in a seperate file which i have done, they seem to conflict.

I think i have no choice but to revert back to 2.3.x.

Can anyone tell me where i can download 2.3.x?

BTW I also modify the statement below as well, but did not show it in the first post.

exten => s,n(normcid),Set(USEROUTCID=${DB(AMPUSER/${REALCALLERIDNUM}/outboundcid)})
Changed to
exten => s,n(normcid),Set(USEROUTCID=${psuedoid})

It works for me OK.

you can override anything in the way I described. If you are running into conflicts then you need to dig deeper into your understanding of how Asterisk parses dialplans and what takes priority. There is nothing you would be able to do with 2.3 that you could not do with 2.4.

Yes I understand what you mean, although it would take time to fully understand asterisk flows.

I always wondered why a flow chart was never made describing how asterisk carried out its flow, it would make following the flow a lot easier. The software I am connecting to has a Flowchart admin feature it make understanding operations so much easier.

I will try my best, The only thing I can think of is to create the same script again in a custom section then modify it and maybe (if it works) bypass the script designed in FreePBX. I will have to look at it more closely.

This will help with a lot of general background info.

Asterisk: The Future of Telephony 2nd Edition (ISBN 0-596-51048-9) — Order yours at — Downloadable PDF

The flow is actually determined by asterisk not FreePBX.

The one thing they don’t cover is the #include command. This is a file based include and will load the file named after it as a part of the existing file as it is loaded into memory.

If a context is declared more then once the only the first occurance of the context in a dialplan is used not the second. SO knowing that if you take a quick peek at the extensions.conf file you will see that it does the file (extensions_override_freepbx.conf) first then the automatic generated extensions_additional.conf, then the extensions_custom.conf.

Hope that helps

Actually, was looking for the link to the books, I knew they existed. Thanks

I understand how 2.4 then works in relation to the #include command, fairly simple basically means that i can write any code in extensions_override_freepbx.conf and could bypass the the rest of the script if I wanted it.

Basically I can copy the entire code to extensions_override_freepbx.conf and tweak it to suit my needs.