Skip to content
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: (re)start asterisk in init script if pppoe-wan up after xDSL break #681

Open
jospezial opened this issue Sep 6, 2021 · 8 comments

Comments

@jospezial
Copy link

jospezial commented Sep 6, 2021

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 with

        option adb_trigger 'wan'

in /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.

@micmac1
Copy link
Collaborator

micmac1 commented Sep 17, 2021

Can you make this work and send a pull request?

@jospezial
Copy link
Author

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.

dhewg added a commit to dhewg/telephony that referenced this issue Nov 4, 2021
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>
dhewg added a commit to dhewg/telephony that referenced this issue Nov 6, 2021
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>
@jospezial
Copy link
Author

#701 was the PR that tried to fix this.

@micmac1
Copy link
Collaborator

micmac1 commented Nov 6, 2021

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'
  }
}

dhewg added a commit to dhewg/telephony that referenced this issue Jan 14, 2022
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>
@jospezial
Copy link
Author

@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?

@micmac1
Copy link
Collaborator

micmac1 commented Jan 29, 2022 via email

@jospezial
Copy link
Author

@dhewg Do you wanna try out my hotplug script? Or add that LED control in your init script?

@dhewg
Copy link
Contributor

dhewg commented Jan 31, 2022

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?

dhewg added a commit to dhewg/telephony that referenced this issue Feb 21, 2022
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>
dhewg added a commit to dhewg/telephony that referenced this issue Mar 25, 2022
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>
dhewg added a commit to dhewg/telephony that referenced this issue Apr 18, 2022
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>
dhewg added a commit to dhewg/telephony that referenced this issue May 4, 2022
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>
dhewg added a commit to dhewg/telephony that referenced this issue May 20, 2022
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>
dhewg added a commit to dhewg/telephony that referenced this issue May 31, 2022
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>
dhewg added a commit to dhewg/telephony that referenced this issue Aug 21, 2022
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>
dhewg added a commit to dhewg/telephony that referenced this issue Oct 20, 2022
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>
dhewg added a commit to dhewg/telephony that referenced this issue Nov 19, 2022
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>
dhewg added a commit to dhewg/telephony that referenced this issue Feb 21, 2023
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>
dhewg added a commit to dhewg/telephony that referenced this issue Mar 7, 2023
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>
dhewg added a commit to dhewg/telephony that referenced this issue Mar 28, 2023
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants