Custom Boot Scripts

Prev Next

As FMADIO OS is effectively a ROM based distribution, where by default everything runs off RAM disk. The ability to customize the boot startup process can be helpful.

There is a lua boot script located in

/opt/fmadio/etc/boot.lua

This script gets once on system startup during the booting process, and can be used for multiple things such as

  • custom TLS certificates

  • persistent SSH tunnels

  • customizing file locations

And many other things, one approach is to use this file to execute typical bash scripts that sysadmins are more familiar with (than the Lua language).


Custom Directory

First example is creating a specific directory path on the RAM based file system, in this case it creates the directory

/opt/my_application/bin/

Step 1) Create boot.lua

The example boot.lua file is shown below

os.execute("mkdir -p /opt/my_application/bin/")
os.execute("touch /opt/my_application/bin/example")

Step 2) Validate the Syntax

After editing the file recommended to check the syntax of the boot.lua using

fmadiolua /opt/fmadio/etc/boot/lua

Example output looks like the following

fmadio@fmadio200v4-636:~$ fmadiolua /opt/fmadio/etc/boot.lua
fmad fmadlua Nov 21 2024 (fmadiolua /opt/fmadio/etc/boot.lua )
Cycles/Sec 2750017930.0000 Std:       0 cycle std(  0.00000000) Target:2.75 Ghz
failed to open self? [fmadiolua]
done 0.001534Sec 0.000026Min
fmadio@fmadio200v4-636:~$

Any syntax errors will be printed out

Step 3) Reboot the system

Reboot the system using

sudo reboot

Step 4) Check path exists

After the system has rebooted check the directory and path create in step 1) exists

fmadio@fmadio100v2-228U:~$ ls -al /opt/my_application/bin
total 0
drwxr-xr-x    2 root     root            60 Nov 21 22:29 ./
drwxr-xr-x    3 root     root            60 Nov 21 22:29 ../
-rw-r--r--    1 root     root             0 Nov 21 22:29 example
fmadio@fmadio100v2-228U:~$

Step 5) Finish

Completed