I myself didn't manage to make it work with the solution that pabo provided.
I ended up running it in the crontab:
env EDITOR=nano crontab -e
add the script line:
@reboot sh /path/to/your/script.sh
make sure that if you need sudo rights, you would need to disable password for sudo use for your script. More info here:
https://apple.stackexchange.com/questions/264663/shutdown-no-tty-present-and-no-askpass-program-specified
Additionally, if you are using some build in commands in mac, like for example route
you need to specify full path of the binary file. Here is example of script.sh
file:
sudo /sbin/route add 192.168.64.0/16 192.168.100.1