How to autostart Wireguard (wg-quick) on boot on Alpine Linux

If you have a Wireguard config file such as /etc/wireguard/wghome.conf, which you can start manually using wg-quick up wghome, this is how you autostart it on boot. Thanks to Justin Ludwig on Serverfault for the template for that init script

Create /etc/init.d/wg-quick-wghome:

description="wg-quick wghome"

depend() {
    need net
    need localmount

start() {
    wg-quick up schlaftier

stop() {
    wg-quick down schlaftier

Then make it executable:

chmod a+x /etc/init.d/wg-quick-wghome

and enable it to start on boot:

rc-update add wg-quick-wghome default

and start it right now if desired:

/etc/init.d/wg-quick-wghome start

Of course you can add multiple scripts like this. Just ensure to name them differently and perform all the steps required to enable startup on boot.