Recalbox automatically runs a file of your own at startup and at shutdown: custom.sh. It is the simplest way to add a mount, a service, a hardware tweak or a small personal fix, without ever modifying the system partition.
Create a file named exactly custom.sh and put it in /recalbox/share/system/ — the system folder of the network share.
The script runs as root, with bash, and receives one argument:
start when the Recalbox boots;stop when it shuts down.It is up to you to handle that argument:
#!/bin/bash
case "$1" in
start)
# Your startup commands
echo "Starting" > /tmp/custom.log
;;
stop)
# Your shutdown commands
echo "Stopping" >> /tmp/custom.log
;;
esac
The file does not need to be made executable: it is invoked through bash. It can contain any shell command and launch other programs — a Python script, for instance.
Make sure your editor saves with Unix line endings (LF). A file saved in Windows format (CRLF) causes mysterious
command not founderrors.
From an SSH session:
/etc/init.d/S99custom start
and for the shutdown part:
/etc/init.d/S99custom stop
A script that blocks (infinite loop, unbounded network wait) will delay the Recalbox boot, or even prevent it. Always push long-running tasks to the background with
&.
Recalbox offers three ways to run your own scripts — do not mix them up:
| Need | Mechanism |
|---|---|
| At machine startup and shutdown | custom.sh — this page |
On demand, from the interface (ADVANCED SETTINGS → USER SCRIPTS) |
User scripts |
| On an event (game launch, system change, sleep…) | Scripts on EmulationStation events |
#!/bin/bash
case "$1" in
start)
mkdir -p /recalbox/share/externals/nas
mount -t cifs //192.168.1.10/medias /recalbox/share/externals/nas -o guest,vers=3.0
;;
stop)
umount /recalbox/share/externals/nas
;;
esac
For a network mount meant to host your roms, prefer the
sharenetwork_*directives inrecalbox-boot.conf: they run before the interface starts, so the games are seen on the very first scan. See Editing the boot configuration files.