Automatic setup of OpenWRT based gateways with TF/SD card

I’m trying to set up a “foolproof” automatic setup of a gateway without having to interact with SSH or the WebUI. So, just simply plug it in and you’re done.

Of course this would need to allow us to run some code automatically on a gateway:

  1. Since the RAK7249 and RAK7268 have an SD (TF) card, I was wondering if there is a location on the SD card where such a script would be run automatically on the (first) boot.

  2. Another avenue could be to connect to it remotely, but the only method feasible for us is 3G/4G (the devices will not be connected to a LAN/WiFi). Since it seems the configuration of the APN has to be done manually on the device (or through some code), I’m stuck again on approach number 1 above.

  3. And yes, if I were to connect the gateway to a local LAN/WiFi, of course there would be a way to scan the network, detect a new gateway and log in through SSH; but I would prefer not to have to connect the gateway to any other network than 3G/4G.

Do you have any suggestions on number 1?
Did anybody else ever succeed in an approach like I am aiming for?