#!/bin/sh
# Restore only return routes after NM changes the wired interface. Never restart
# Mihomo, erase conntrack, or change established connection selection.
[ "${1:-}" = enp2s0 ] || exit 0
case "${2:-}" in
    up|dhcp4-change|dhcp6-change|reapply)
        systemctl is-active --quiet mihomo.service || exit 0
        [ -f /etc/systemd/system/mihomo.service.d/20-gateway.conf ] || exit 0
        /usr/local/sbin/mihomo-gateway refresh-return
        ;;
esac
