Книга: Embedded Linux Primer: A Practical, Real-World Approach

11.3.2. Example rcS Initialization Script

11.3.2. Example rcS Initialization Script

Before BusyBox spawns an interactive shell, it tries to execute commands from a script called /etc/init.d/rcS, as shown in Listing 11-7. It is here where your applications come to life in a BusyBox system. A simple rcS initialization script is provided in Listing 11-8.

Listing 11-8. Simple rcS BusyBox Startup Script

#!/bin/sh
echo "Mounting proc"
mount -t proc /proc /proc
echo "Starting system loggers"
syslogd
klogd
echo "Configuring loopback interface"
ifconfig lo 127.0.0.1
echo "Starting inetd"
xinetd
# start a shell
busybox sh

This simple script is mostly self-explanatory. First, it is important to mount the /proc file system on its reserved mount point, /proc. This is because many utilities get their information from the /proc file system. This is explained more fully in Chapter 9. Next we launch the system loggers as early as possible, to capture any startup problems. Following the system log daemons, we configure the local loopback interface for the system. Again, a number of traditional Linux facilities assume that a loopback interface is present, and if your system has support for sockets configured, you should enable this pseudo interface. The last thing we do before starting a shell is launch the Internet superserver xinetd. This program sits in the background listening for network requests on any configured network interfaces. For example, to initiate a telnet session to the board, xinetd intercepts the request for telnet connection and spawns a telnet server to handle the session.

Instead of starting a shell, your own applications can be launched from this rcS initialization script. Listing 11-8 is a simple example of a Telnet-enabled target board running basic services such as system and kernel loggers.

Оглавление книги


Генерация: 0.064. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз