Version 34, changed by mschnell. 07/23/2008. Show version history
... / BusyBox / Shells --->[*] cat
[*] echo
Now we can just call several shell scripts from rc and have them executed by msh (as usual, this is done by defining the interpreter in the first line of the script:[*] msh
#!/bin/msh
and setting the executable flags for the script file.
In rc, the script is now simply called like a normal executable.
Usually the complex script files will be located in /etc. To have them moved there, they are created in vendor/altera/nios2 and the Makefile in that directory is edited to handle them appropriately.
It makes much sense to use one or more simple script files in a Flash file system that are called (i.e. "sourced") by the rc-file(s) and just do some environment settings that are to be acknowledged by the initialization scripts.
These Flash based files can be changed "online" by an appropriate mechanism. Very easy is doing this with FTP (which is enabled in our uCLinux-dist by default). A much more user-friendly way is to do this with a web browser via boa and cgi. Here using a "haserl" script would be most appropriate, but - curiously right now (July 2008) haserl only works on out dist if a syslog() call is added to the source code and the syslog daemon is running (while it works easily on a PC-Linux installation). Any help on this issue is very much appreciated !
You must have "msh" shell and the apps "echo" and "cat" in busybox enabled (see on top)!
An example of cascaded initialization scripts is provided here. These are used in the current version of the binary NEEK distribution that can be found on the TryOutuClinux page.
/etc/rc is the initial script executed by the init process using /bin/sh (thus sash)
/etc/rc0 is called by rc0 and executed by msh. Here the configuration is read and decisions are made based on the configuration settings. rc0 writes the file /etc/rcc that can be read by any shell using the "source" or "." command to use the preprocessed configuration options.
/etc/rcts does additional system configuration settings
/etc/rca is meant for starting the primary applications (based on configuration settings)
/etc/rcd does the default configuration settings that are used even if the configuration in flash is not (yet) available
/etc/rcc can be read by any shell (sash using the "source", msh using the "." command) to use the preprocessed configuration options. As the environment variables can be e.g. names of additional script files, decisions that are done when rc0 was executed can get effective later.
/mnt/configflash/rc1 is located in the Flash. It does configuration settings and can be edited on the running device.
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t usbfs none /proc/bus/usb
mkdir /var/tmp
mkdir /var/log
mkdir /var/run
mkdir /var/lock
mkdir /var/empty
ifconfig lo 127.0.0.1
route add -net 127.0.0.0 netmask 255.0.0.0 lo
cat /etc/motd
#########################
# FLASH #
#########################
mkdir /mnt/configflash
mount -t jffs2 /dev/mtdblock0 /mnt/configflash
#########################
# Read configuration #
#########################
/etc/rc0
source /etc/rcc
#########################
# APPLICATIONS #
#########################
/etc/rca
#########################
# AFTER STARTING APPS #
#########################
#!/bin/msh
#using the more versatile shell to read the configuration settings
RC=/etc/rcd
if [ -e $RC ]; then
echo reading configuration settings in $RC
. $RC
fi
RC=/mnt/configflash/rc1
if [ -e $RC ]; then
echo reading configuration settings in $RC
. $RC
fi
if [ $NANOX == Y ]; then
RC=/etc/rcts
if [ -e $RC ]; then
echo reading configuration settings in $RC
. $RC
if [ -e $TSLIB_CALIBFILE ]; then
echo touch screen support enabled
export TSLIB_FBDEVICE
export TSLIB_CONSOLEDEVICE
export TSLIB_CALIBFILE
export TSLIB_TSDEVICE
else
export TSLIB_FBDEVICE=none
export TSLIB_CONSOLEDEVICE=none
export TSLIB_CALIBFILE=none
export TSLIB_TSDEVICE=none
fi
fi
fi
RC=/etc/rcc
echo HOSTNAME=$HOSTNAME > $RC
echo DHCP=$DHCP >> $RC
echo IP=$IP >> $RC
echo INETD=$INETD >> $RC
echo BOA=$BOA >> $RC
echo NANOX=$NANOX >> $RC
echo DEMO=$DEMO >> $RC
echo DEMOPIC=$DEMOPIC >> $RC
echo TSLIB_FBDEVICE=$TSLIB_FBDEVICE >> $RC
echo TSLIB_CONSOLEDEVICE=$TSLIB_CONSOLEDEVICE >> $RC
echo TSLIB_CALIBFILE=$TSLIB_CALIBFILE >> $RC
echo TSLIB_TSDEVICE=$TSLIB_TSDEVICE >>$RC
echo =========================
cat $RC
echo =========================
/bin/sh -c hostname $HOSTNAME
if [ $DHCP == Y ]; then
echo starting dhcp client
dhcpcd -p -a -h $HOSTNAME eth0 &
else
echo set IP to $IP
/bin/sh -c ifconfig eth0 $IP
fi
if [ $INETD == Y ]; then
echo starting inetd
inetd &
fi
if [ $BOA == Y ]; then
echo starting boa
boa &
fi
if [ $NANOX == Y ]; then
echo starting nano-X
nano-X &
nanowm &
fi
TSLIB_FBDEVICE=/dev/fb0
TSLIB_CONSOLEDEVICE=none
TSLIB_CALIBFILE=/mnt/configflash/pointercl
TSLIB_TSDEVICE=/dev/input/event0
#!/bin/msh
#using the more versatile shell to start application
. /etc/rcc
if [ $DEMO == Y ]; then
echo starting nano-X demo
nxview $DEMOPIC &
fi
# Default configuration
# used if the flash based configuration files are not available
HOSTNAME=uclinux
DHCP=Y
IP=0.0.0.0
INETD=Y
BOA=Y
NANOX=Y
DEMO=Y
DEMOPIC=/etc/p.jpg
HOSTNAME=uclinux
DHCP=Y
IP=192.168.37.173
INETD=Y
BOA=Y
NANOX=Y
DEMO=Y
DEMOPIC=/mnt/configflash/demo.jpg
TSLIB_FBDEVICE=/dev/fb0
TSLIB_CONSOLEDEVICE=none
TSLIB_CALIBFILE=/mnt/configflash/pointercl
TSLIB_TSDEVICE=/dev/input/event0
HOSTNAME=uclinux
DHCP=Y
IP=192.168.37.173
BOA=Y
DEMO=Y
DEMOPIC=/mnt/configflash/demo.jpg