Open jospezial opened 2 years ago
Can you make this work and send a pull request?
Can you make this work and send a pull request?
I am not so good in this. And I don't want to sign off a PR with real name and e-mail in connection with my nick.
https://github.com/openwrt/telephony/pull/701 was the PR that tried to fix this.
As mentioned in the PR, you can use hotplug events by setting up a file like /etc/hotplug.d/iface/99-asterisk and execute any command you want. I don't have a DSL connection to test, but something like this should work.
[ "$ACTION" = "ifup" -a "$INTERFACE" = "pppoe-wan" ] && {
/etc/init.d/asterisk enabled && {
# this or any other command you want to run
/usr/sbin/asterisk -x 'pjsip send unregister *all' -x 'pjsip send register *all'
}
}
@micmac1 I tested your example. For "pppoe-wan" "$DEVICE" has to used. And for "wan" "$INTERFACE" This is my /etc/hotplug.d/iface/99-asterisk now:
[ "$ACTION" = "ifdown" -a "$INTERFACE" = "wan" ] && {
/etc/init.d/asterisk enabled && {
echo "heartbeat" >/sys/devices/platform/leds/leds/green:telefon/trigger
/usr/bin/logger -p daemon.info -s -t hotplug_asterisk "Unregistering all outbound pjsip registrations because internet down."
/usr/sbin/asterisk -x 'pjsip send unregister *all'
}
}
[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && {
/etc/init.d/asterisk enabled && {
echo "default-on" >/sys/devices/platform/leds/leds/green:telefon/trigger
/usr/bin/logger -p daemon.info -s -t hotplug_asterisk "Re-registering all outbound pjsip registrations because internet up (again)."
/usr/sbin/asterisk -x 'pjsip send register *all'
}
}
Seems to work as I want. The next thing is, how can I signalize if Asterisk has no registrations because of other issues?
Seems to work as I want. The next thing is, how can I signalize if Asterisk has no registrations because of other issues?
Maybe a cron job that checks periodically and then acts accordingly. Asterisk users mailing list is maybe a better place for your question.
@dhewg Do you wanna try out my hotplug script? Or add that LED control in your init script?
I'm still using my init script patch myself. I don't have a use for led control myself, but I think you can control the led state like you are with the standard OpenWrt led options? netdev state wan up something something?
Maintainer: @jslachta Description: I have seen in /etc/init.d/adblock https://github.com/openwrt/packages/blob/19fcff09107ab9b03331e433a1750c826c3747dd/net/adblock/files/adblock.init#L348-L371 you can use
procd_add_interface_trigger
to restart the service by status of network interfaces. Works for me within /etc/config/adblock
Would be nice to have that in /etc/init.d/asterisk and /etc/config/asterisk too. That makes sure asterisk pjsip registrations are up to date and don´t use old IP number. Otherwise it waits until pjsip expiration value is over.