I resurrect this old thread just to add some more info for future reference. I came across this topic multiple times while searching the best way to turn on an Iot-relay, such as the one @DougA mentioned above. (My original way was to use a USB plugged into the Pi, with - & + going to the relay)
I am using an ADAfruit arcade bonnet, so some gpio pins were causing conflict with the controls.
To test I used:
sudo su
cd /sys/class/gpio
echo 8 > export
cd gpio8
echo out > direction
echo 1 > value
To set a specific pin to turn high/low (on/off), add one of these options in /boot/config.txt
xx is the BCM number of the GPIO you want to use
dtoverlay=gpio-poweroff,gpiopin=xx
for the default where GPIOxx will go low on boot and high after shutdown
dtoverlay=gpio-poweroff,gpiopin=xx,active_low
to make the GPIO go high while the system is up
Adding to the /boot/config.txt allowed my Iot-relay to power on the switched outlets within 1-2 seconds of boot
references
https://www.raspberrypi.org/forums/viewtopic.php?t=154824