Hi there. I'm attempting to have a procd service restart if it detects that a WireGuard configuration occurs. I'm able to determine the trigger for the service. Here's how I configure WireGuard:
ip netns delete container || true
ip netns add container
ip link delete wg0 || true
ip link add wg0 type wireguard
ip link set wg0 netns container
ip -n container addr add $VPN_CLIENT_IP/32 dev wg0
ip netns exec container \
wg set wg0 \
listen-port 51820 \
private-key $VPN_CLIENT_KEY_PATH \
peer $VPN_SERVER_PUB_KEY \
persistent-keepalive 25 \
allowed-ips 0.0.0.0/0 \
endpoint $VPN_SERVER_HOST
ip -n container link set wg0 up
ip -n container route add default dev wg0
i.e. a container is created having moved the wg0 interface into it.
I had thought that if I change the contents of some file then that might cause procd to reload my service, but it looks as though an explicit reload of the service is required.
The twist to this is that my configuring WireGuard is oblivious of what services depend on it. Therefore, an explicit reload is to be avoided as I'd have to maintain a list of those dependent services.
Here's my (incorrect) procd config so far:
#!/bin/sh /etc/rc.common
USE_PROCD=1
START=95
STOP=01
start_service() {
procd_open_instance
procd_set_param command /sbin/ip
procd_append_param command netns
procd_append_param command exec
procd_append_param command container
procd_append_param command /tmp/a
procd_set_param netdev wg0
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param file /var/run/test
procd_set_param respawn
procd_close_instance
}
service_triggers()
{
procd_add_reload_interface_trigger wg0
}
reload_service()
{
echo "Config changed"
stop
start
}
Thanks for any help.