i know this post is old but i was looking for this to run my LED buttons when PI is booting. Finally i managed to get it working

I copy the script file in "/recalbox/share/system" then i fallow Substring recommendation

my custom scrypt is looking like this:

#################################################

#!/bin/sh
#/recalbox/share/system/custom.sh
cd /recalbox/share/system/
python relay1.py&

################################################