Is there any way to run scripts like in "custom-cont-init.d" but AFTER the service?

Hi!!!

Please, is there any way to run commands/scripts AFTER the /init, like “custom-cont-init.d”.

I’m running the “linuxserver/wireguard” container and need to run firewal rules based on the “wg0” vpn interfase, but as the “custom-cont-init.d” runs as PRE-STEP… thew wg0 interfase is still missing then the script try to execute but…:
###############
| [custom-init] files found in /config/custom-cont-init.d executing
| [custom-init] 99-reglas.sh: executing…
| Device “wg0” does not exist. << because the script runs before the vpn is UP
| iptables v1.6.1: option “–to-source” requires an argument
| Try iptables -h' or 'iptables --help' for more information. | iptables v1.6.1: option "--to-source" requires an argument | Try iptables -h’ or ‘iptables --help’ for more information.
###############

I’m thinking in run the script with “nohup and sleep”… but maybe there is a more intelligent way.

Thank you very mutch!!!

PD: the script I’m trying to run to NAT other container using the VPN SERVER IP:

#!/bin/bash
sleep 15; 
vpnlan=10.66.66.0/24
kumaIP=$(getent hosts uptime-kuma-meg  | awk '{ print $1 }')
ipVpnWireguard=$(ip a l dev wg0 | grep inet | grep -v inet6| awk '{print $2}' | cut -d\/ -f1)
iptables -t nat -D  POSTROUTING -s $kumaIP -d $vpnlan -j SNAT --to-source $ipVpnWireguard
iptables -t nat -A  POSTROUTING -s $kumaIP -d $vpnlan -j SNAT --to-source $ipVpnWireguard

Have you tried PostUp in your wirefuard config?

https://man7.org/linux/man-pages/man8/wg-quick.8.html