The script file

The second section of the buildfile starts with the [+script] attribute — this tells mkifs that the specified file is a script file, a sequence of commands that you want procnto to execute when it's completed its own startup.

Note: Script files look just like regular shell scripts, except that:

In order to run a command, its executable must be available when the script is executed. You can add the executable to the image or get it from a filesystem that's started before the executable is required. The latter approach results in a smaller image.

In this case, the script file is an inline file (again indicated by the open brace). The file (which happens to be called ".script") contains the following:

procmgr_symlink ../../proc/boot/libc.so.3 /usr/lib/ldqnx.so.2

devc-ser8250-abc123 -F -e -c14745600  -b115200 0xc8000000 ^2,15 &
reopen
    
display_msg Serial Driver Started

This script file begins by creating a symbolic link to ../../proc/boot/libc.so.3 called /usr/lib/ldqnx.so.2.

Note: For MIPS targets, you need to name this link ldqnx.so.3 instead of ldqnx.so.2.

Next the script starts a serial driver (the fictional devc-ser8250-abc123) in edited mode with hardware flow control disabled at a baud rate of 115200 bps at a particular physical memory address. The script then does a reopen to redirect standard input, output, and error. The last line simply displays a message.

As mentioned above, the bootstrap file can set the _CS_PATH and _CS_LIBPATH configuration strings. You can set PATH, LD_LIBRARY_PATH, and other environment variables if the programs in your script need them.

Note: Startup scripts support foreground and background processes. Just as in the shell, specify an ampersand (&) on the command line to make the program run in the background. If you run a program in the foreground, and it doesn't exit, then the rest of the script is never executed, and the system might not become fully operational.