Recreating Extensions.conf From Live Dialplan ?
with the slip of a finger, i destroyed by extensions.conf (grep -i >
extensions.conf)
I have a backup that is dozens of hours of code old.
is there a way i can use the asterisk cli (or some other asterisky method) to recreate that extensions.conf ?
11 thoughts on - Recreating Extensions.conf From Live Dialplan ?
Will ‘dialplan save’ help?
I just tried this one. It writes the dialplan, but without the application arguements. Worthless.
You could try
*CLI> dialplan show The output from this is not the same format as an extensions.conf file, but it will have all the relevant information in it; and it seems to include all the relevant infiormation. So it could be made to look like an extensions.conf file, if you really have nothing else — desperate situations call for desperate remedies, and all that …..
sudo asterisk -r -x ‘dialplan show’ >extensions.wip
And then start cobbling up a script to parse and re-write into a usable format.
right, was a good shot. in my case I have writeprotect=yes in general, so that would have been the first hurdle. but asterisk does have my latest-and-greatest code in memory and active in it’s dialplan. hoping for something similar…
Between my older backup and dialplan show, I guess that’s my best shot.
Thanks 😀
Aside from just a great way to eff up your day, does ‘dialplan save’ have any value?
This should get you close:
sudo asterisk -r -x ‘dialplan show’ >extensions.wip
and then feed extensions.wip through:
#!/usr/bin/env php
(I’m not all that hot of a PHP programmer, so if anybody has some constructive criticism, please jump it.)
Damn. Missed a line of code.
Should be:
// label
if (‘[‘ == substr($line, 5, 1))
{
$line = str_replace(‘]’, ‘[‘, $line);
$tokens = explode(‘[‘, $line);
$line = substr($line, strpos($line, ‘ ‘, 20) + 1, 255);
printf(“\tsame = n(%s),\t\t\t%s”, $tokens[1], $line);
continue;
}
Ya, that’s pretty good! besides the fact that I’ve never used “same” (i understand where it’s coming from) and a few contexts confuzzled
(missing general/globals and extra parkedcalls – but again I get it) –
it seems to be perfect.
One for a wiki, somewhere.
thanks,
I’ll have a go this lunchtime at knocking up a Perl script {for that is my language of choice} to try to recreate an extensions.conf file from the
`dialplan show` CLI output. All the necessary stuff seems to be there, even labels for GoTo statements …..