-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asterisk: improve init.d script and fix #681 #701
Conversation
Remove redundant empty lines and refactor the logging. It now uses the 'daemon' facility where it belongs and can be used for any level. Signed-off-by: Andre Heider <a.heider@gmail.com>
asterisk reloads its config upon SIGHUP, use it. Signed-off-by: Andre Heider <a.heider@gmail.com>
Seems to work so far (asterisk-19.0.0). Can we do anything with that procd message of "/etc/init.d/asterisk stop" ?
|
Sometimes after a
But in logread I see asterisk starting/stopping normal. Maybe we could also use the green:telefon LED with Asterisk if all is "ok", flash on "error" for example? |
Nice, thanks for testing it. Dunno about the LED idea, that's likely a can of worms ;) For a reliable solution you'd have to integrate it in your dialplan I guess (switch the LED status on a trunk registration event) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this flies, definitely not as default as the next commit makes it out to be. This is expecting that pjsip is used for outbound connections. But users may use all sorts of channels, iax2, dahdi, chan-sip and whatnot.
If made optional and into some sort of template that'd be fine.
Where is this coming from, then? Is this in any way related to this pull request? Do you see this when issuing a stop or restart while procd has an asterisk instance up and running? |
The message "Command failed: Not found" seems to come directly from asterisk when issuing a stop or restart while asterisk is not running.
Let's do the restart simpler without using the asterisk internal pjsip command. Let's always do a fresh full start of asterisk. |
After reboot we could let the asterisk start wait for the interface up if an interface is set in /etc/config/asterisk. |
I'd leave it at pjsip only for now, that'll cover most if not all asterisk users on OpenWrt I guess. It's already optional in the sense that it'll only do anything if you use the |
I don't think that's the way to go. Connecting to asterisk without it itself being able to connect to upstreams is still valid, and it'll lose its runtime stats that way too, like used in the prometheus module which I'm using |
`/etc/init.d/asterisk reregister` will re-register all outbound registrations. Currently only pjsip is supported, but, if required, this can be easily extended in the future. Signed-off-by: Andre Heider <a.heider@gmail.com>
If set this now automatically re-registers all outbound registrations when the interface is becoming available. This ensures that no stale IPs are registered at the SIP trunk. Fixes openwrt#681 Signed-off-by: Andre Heider <a.heider@gmail.com>
How about this? The |
I got an idea. You know OpenWrt has this file /etc/firewall.user. You add a file like that, maybe call it /etc/asterisk-if-trigger.user. Make it a "#!/bin/sh" script. Not sure if procd_add_interface_trigger cares about exit code, so maybe add "exit 0" at the end of the script. You add your pjsip commands in there, but commented out, as an example. Add the file to conffiles, too, so user changes won't get overwritten. Then you setup the trigger in the init script, pointing the trigger to this .user script. And in /etc/config/asterisk you add a comment to your new option that points users to the file. I think the option should have a more pointy name than "interface". Maybe "interface-trigger" or "if-trigger". This way there's no change of behavior, it's not hacky and users can add any command they like to run to the file that already contains an example for pjsip. |
But we can already do that now with a script in I agree that Do you believe this is hacky? I mean the fact that it's now parsing the output of |
But we can already do that now with a script in `/etc/hotplug.d/iface`
without any changes whatsoever :)
I don't think we can, for the same reason mentioned yesterday: We don't
know what kind of outbound channels the user has in use.
I agree that `interface-trigger` is more appropriate and self
explanatory for this use case. But I also think that providing an easy
solution for this problem is more user friendly without having users
fiddle around with scripts.
Do you believe this is hacky? I mean the fact that it's now parsing
the output of `module show` isn't as nice and tidy as I'd like, but
it's not so bad either and with this all the user has to do is set a
uci config knob. Maybe even someday with a luci app?
Yes, I do believe it's hacky and I wouldn't merge this as is.
|
Alright, I would still prefer this over custom scripts though. So let's not then :\ |
Yeah, those 2 are independent of the fix for #681 and are still worth having imho. The branch is still there if anyone cares |
This facility was suggested in pull request openwrt#701. Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
I cherry-picked the sighup commit. With the other one I have some doubts. Like, the level is not checked in the function and you'd need to remember to put the log level before the log message. This seems to be a bit of an overkill, because we're only using the logger just a single time right now. I added a commit to change the facility to deamon anyway, to smooth things over. :) |
A few small and (hopefully) self-explanatory patches.
@jospezial: Does that work for you?