Fix dialplan never rebuilding after web admin device/room changes
The web admin's device functions (add_device, delete_device,
rename_device, change_device_category) only ever called
"asterisk -rx pjsip reload" — they never regenerated
extensions.conf's [intercom] context, so newly added SIP endpoints
could register but could never call each other or dial into rooms
("extension not found in context 'intercom'").
The room functions (create_room, delete_room, rename_room,
update_room_members) already tried to fix this correctly by shelling
out to `easy-asterisk --rebuild-dialplan`, but that flag was never
actually wired up — main() at the bottom of the script ignores all
arguments and always launches the interactive menu, so every one of
those calls was a silent no-op too.
Fixed both: added real --rebuild-dialplan argument handling that
calls the existing rebuild_dialplan() bash function non-interactively,
and added the same subprocess call to the four device functions that
were missing it entirely.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015X1jRGHwrvovz2qkhKfDZi
This commit is contained in:
+14
@@ -4340,6 +4340,7 @@ def delete_device(extension):
|
||||
with open(PJSIP_CONF, 'w') as f:
|
||||
f.writelines(new_lines)
|
||||
subprocess.run(['asterisk', '-rx', 'pjsip reload'], capture_output=True)
|
||||
subprocess.run(['/usr/local/bin/easy-asterisk', '--rebuild-dialplan'], capture_output=True)
|
||||
return True, "Device deleted"
|
||||
return False, "Device not found"
|
||||
|
||||
@@ -4413,6 +4414,7 @@ def rename_device(extension, new_name):
|
||||
with open(PJSIP_CONF, 'w') as f:
|
||||
f.writelines(new_lines)
|
||||
subprocess.run(['asterisk', '-rx', 'pjsip reload'], capture_output=True)
|
||||
subprocess.run(['/usr/local/bin/easy-asterisk', '--rebuild-dialplan'], capture_output=True)
|
||||
return True, "Device renamed"
|
||||
return False, "Device not found"
|
||||
|
||||
@@ -4525,6 +4527,7 @@ def change_device_category(extension, new_category):
|
||||
with open(PJSIP_CONF, 'w') as f:
|
||||
f.writelines(new_lines)
|
||||
subprocess.run(['asterisk', '-rx', 'pjsip reload'], capture_output=True)
|
||||
subprocess.run(['/usr/local/bin/easy-asterisk', '--rebuild-dialplan'], capture_output=True)
|
||||
return True, "Category changed"
|
||||
return False, "Device not found"
|
||||
|
||||
@@ -4774,6 +4777,7 @@ qualify_frequency=30
|
||||
|
||||
subprocess.run(['asterisk', '-rx', 'pjsip reload'], capture_output=True)
|
||||
subprocess.run(['chown', 'asterisk:asterisk', PJSIP_CONF], capture_output=True)
|
||||
subprocess.run(['/usr/local/bin/easy-asterisk', '--rebuild-dialplan'], capture_output=True)
|
||||
|
||||
return True, {'extension': extension, 'password': password, 'name': name}
|
||||
|
||||
@@ -6926,4 +6930,14 @@ main() {
|
||||
show_main_menu
|
||||
}
|
||||
|
||||
# Non-interactive entry point used by the web admin (Python) after any
|
||||
# device/room change — regenerates extensions.conf's [intercom] context
|
||||
# and reloads it. Without this, PJSIP endpoints register fine but calls
|
||||
# between them fail with "extension not found" since nothing else ever
|
||||
# rebuilds the dialplan after the initial container boot.
|
||||
if [[ "${1:-}" == "--rebuild-dialplan" ]]; then
|
||||
rebuild_dialplan quiet
|
||||
exit 0
|
||||
fi
|
||||
|
||||
main "$@"
|
||||
|
||||
Reference in New Issue
Block a user