Create and control start up scripts in BusyBox
For buildroot all your scripts must be placed in $path_to_buildroot/output/target/etc/init.d
before build image.
In my case this directory contains rcS
and few scripts named S[0-99]script_name. So you can create your own start\stop script.
rcS:
#!/bin/sh
# Start all init scripts in /etc/init.d
# executing them in numerical order.
#
for i in /etc/init.d/S??* ;do
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i start
;;
esac
done
and for example S40network:
#!/bin/sh
#
# Start the network....
#
case "$1" in
start)
echo "Starting network..."
/sbin/ifup -a
;;
stop)
echo -n "Stopping network..."
/sbin/ifdown -a
;;
restart|reload)
"$0" stop
"$0" start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
It's bad idea to change your fs in "target" folder. This is because changes in output/target/
do not survive the make clean
command.
In buildroot manual decribed how to do it correctly
You should create dir somewhere which partly overlay file system. For example you can create dir "your-overlay" in buildroot dir where you create this struct
your-overlay/etc/init.d/<any_file>
Then you should set path to this overlay in defconfig
System configuration > Root filesystem overlay directories
(or, find BR2_ROOTFS_OVERLAY)
Also, the recommended path for this overlay is
board/<company>/<boardname>/rootfs-overlay