Weiter Zurück Inhalt

5. Ihre Applikation

5.1 Wohin gehört die Applikation

Im Kapitel Directory Struktur finden Sie im Directory /home/heimo die Applikationen die gestartet werden sollen. Im Beispiel der Directory Struktur wird der Start aller für die Applikation wichtigen Funktionen durch das Script /home/heimo/gme-start durchgeführt. /home/heimo/gme-start erzeugt ein File im /dev Directory mit Hilfe des Scripts /home/heimo/mkdev, lädt den Kerneldriver der für das Lesen der Handshakeleitungen von der seriellen Schnittstelle dient und startet die Applikation gme-read.

5.2 Wie startet die Applikation

Damit bleibt nun die Frage, wie wird nach dem erfolgreichen Start des Kernels und aller Dämonen, Ihr Applikationsstartscript (im Beispiel /home/heimo/gme-start) gestartet? Dies erfolgt durch das Startscript /etc/init.d/rc.S . Das Script rc.S ist zuständig für den Start aller Dämonen (syslogd, sshd, smbd, nmbd, usw.), für das Mounten aller Dateisysteme, aktivieren der seriellen Schnittstellen, und startet das Script /etc/init.d/rc.net das für das Aktivieren des Netzwerks verantworltlich ist.

Nachfolend das Script rcS:

#! /bin/sh

#
# (C) 2002 by Heimo Schön / http://heimo.co.at / heimo.schoen@gmx.at
#
# Bootscript for the GME - Geschwindikeitsmeßeinrichtung
#

mkdir /dev/pts
/bin/mount -t devpts devpts /dev/pts
/bin/mount -t tmpfs none /tmp
/sbin/syslogd

/bin/echo "Mounting filesystems..."
/bin/mount /proc
/bin/mount -a
###mount /dev/proc /proc/ -t proc

###echo "Mounting the flashdisk ..."
###mount -o sync /dev/hda1 /flashdisk 2>&1 > /dev/null

echo "Activating Serial 2 and 3 ..."
# Devices onboard of the MSM586
/bin/setserial    /dev/ttyS0 irq  4 port 0x3F8 uart 16550A
/bin/setserial    /dev/ttyS1 irq  3 port 0x2F8 uart 16550A
/bin/setserial    /dev/ttyS2 irq  5 port 0x3E8 uart 16550A
/bin/setserial    /dev/ttyS3 irq  7 port 0x2E8 uart 16550A
# port C,D on the AIM104-4-port-serialdevice (if present)
/bin/setserial    /dev/ttyS4 irq 10 port 0x330 uart 16550A
/bin/setserial    /dev/ttyS5 irq 11 port 0x338 uart 16550A
echo ""
echo "Serial ports on this machine:"
/bin/setserial -g /dev/ttyS?
echo ""

/bin/echo "Sourcing the Config-Script ..."
. /etc/init.d/rc.config

# set up motd and issue (and show which kernel we use today)
/bin/echo " [*] $(uname -a) [*]"  >> /etc/nanobox.dpy
/bin/cp /etc/nanobox.dpy /etc/motd 
/bin/cp /etc/nanobox.dpy /etc/issue

/bin/echo
/bin/echo "Setting hostname to gme..."
echo $GME_HOSTNAME > /etc/HOSTNAME
/bin/hostname $GME_HOSTNAME

/bin/echo "Starting network configuration..."
/etc/init.d/rc.net

echo "sending bootmessage to ttyS0 ..."
/bin/cat /etc/nanobox.dpy > /dev/ttyS0

/bin/cat /etc/nanobox.dpy

### We moved this stuff to inittab!!!
###/bin/echo "Starting GME Application ..."
###/home/heimo/gme-start &
    

Nachfolend das Script rc.net:

#!/bin/ash

#
# (C) 2002 by Heimo Schön / http://heimo.co.at / heimo.schoen@gmx.at
#
# Bootscript for the GME - Geschwindikeitsmeßeinrichtung
#
# abstract:
#    this script brings up the network
#

echo "Bringing up loopback interface"
/sbin/ifconfig lo 127.0.0.1 up

#echo
#echo Starting interactive network setup...
#echo


#for dev in `/bin/cat /proc/net/dev | /bin/grep eth | /bin/sed  's/^[ \t]*//;s/:/ / ' | /usr/bin/cut -d\  -f1`
#do
#  echo "Use network interface $dev? [y/N] "
#  read  ans
#  if [ "$ans" = "y" -o "$ans" = "Y" ]
#  then
#    echo "Configure $dev using DHCP? "
#    read ans
#    if [ "$ans" = "y" -o "$ans" = "Y" ] 
#    then
#      /sbin/udhcpc -n -i $dev -s /etc/udhcpc.script
#    else
#      echo "Please enter the IP address for $dev: "
#      read  ip
#      echo "Please enter the subnet mask for $dev: "
#      read  netmask
#      echo "Configuring eth0...  "
#      /sbin/ifconfig $dev inet $ip netmask $netmask up
#    fi
#    ip=`/sbin/ifconfig $dev | /bin/grep inet | /usr/bin/cut -d: -f2 | /usr/bin/cut -d" " -f1` 
#    ifaces="$ifaces $ip/24" 
#  fi
#done

ip=$GME_IPADR
echo "Setting up eth0 to $ip"
/sbin/ifconfig eth0 inet $ip netmask $GME_MASK up

#set interfaces line in smb.conf
#####ifaces="$ip/16" 
#####echo "interfaces = $ifaces" >> /etc/smb.conf


#echo "Please enter the address of your default gateway [none]: "
#read defaultgw
#if [ "defaultgw" != "" ]
#               then
#               /sbin/route add default gw $defaultgw
#fi
/sbin/route add default gw $GME_GATEWAY


#echo "Please enter your workgroup: "
#read  workgrp
#echo "workgroup = $workgrp" >> /etc/smb.conf
#####echo "workgroup = ARBEITSGRUPPE" >> /etc/smb.conf

echo "Configuring DNS..."

#echo "Please enter your DNS domain [$workgrp]: "
#read domain
#if [ "$domain" != "" ]
#then
#  echo "search $domain" >> /etc/resolv.conf
#else
#  echo "search $workgrp" >> /etc/resolv.conf
#fi
#echo "search ternitz" >> /etc/resolv.conf

#echo "Please enter the address of your primary DNS server [none]: "
#read dns0
#if [ "$dns0" != "" ] 
#then
#  echo "nameserver $dns0" >> /etc/resolv.conf
#fi
#echo "nameserver $GME_GATEWAY" >> /etc/resolv.conf

#echo "Please enter the address of your secondary DNS server [none]: "
#read  dns1
#if [ "$dns1" != "" ]
#then
#  echo "nameserver $dns1" >> /etc/resolv.conf
#fi
#echo "nameserver $GME_GATEWAY" >> /etc/resolv.conf


echo "starting portmapper ..."
/sbin/portmap

#echo "name service cache daemon ..."
#/sbin/nscd

echo "starting sshd ..."
/sbin/sshd

#echo "starting telnetd ..."
#/sbin/tcpd in.telnetd

echo "starting the Samba-Server ..."
/sbin/nmbd
/sbin/smbd

echo 
    

5.3 Startup mit init

/etc/init.d/rcS ist also für den Startup des Systems verantwortlich. rcS wird gestartet durch das Programm init. Init wiederum wird gesteuert durch die Init-Tabelle im File /etc/inittab:

# /etc/inittab init(8) configuration for BusyBox
#
# Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
#
#
# Note, BusyBox init doesn't support runlevels.  The runlevels field is
# completely ignored by BusyBox init. If you want runlevels, use sysvinit.
#
#
# Format for each entry: <id>:<runlevels>:<action>:<process>
#
# <id>: WARNING: This field has a non-traditional meaning for BusyBox init!
#
#       The id field is used by BusyBox init to specify the controlling tty for
#       the specified process to run on.  The contents of this field are
#       appended to "/dev/" and used as-is.  There is no need for this field to
#       be unique, although if it isn't you may have strange results.  If this
#       field is left blank, it is completely ignored.  Also note that if
#       BusyBox detects that a serial console is in use, then all entries
#       containing non-empty id fields will _not_ be run.  BusyBox init does
#       nothing with utmp.  We don't need no stinkin' utmp.
#
# <runlevels>: The runlevels field is completely ignored.
#
# <action>: Valid actions include: sysinit, respawn, askfirst, wait, once, 
#                                  ctrlaltdel, and shutdown.
#
#       Note: askfirst acts just like respawn, but before running the specified
#       process it displays the line "Please press Enter to activate this
#       console." and then waits for the user to press enter before starting
#       the specified process.
#
#       Note: unrecognised actions (like initdefault) will cause init to emit
#       an error message, and then go along with its business.
#
# <process>: Specifies the process to be executed and it's command line.
#
# Note: BusyBox init works just fine without an inittab. If no inittab is
# found, it has the following default behavior:
#         ::sysinit:/etc/init.d/rcS
#         ::askfirst:/bin/sh
#         ::ctrlaltdel:/sbin/reboot
#         ::shutdown:/sbin/swapoff -a
#         ::shutdown:/bin/umount -a -r
# if it detects that /dev/console is _not_ a serial console, it will
# also run:
#         tty2::askfirst:/bin/sh
#         tty3::askfirst:/bin/sh
#         tty4::askfirst:/bin/sh
#
# Boot-time system configuration/initialization script.
# This is run first except when booting in single-user mode.
#
::sysinit:/etc/init.d/rcS

# /bin/sh invocations on selected ttys
#
# Note below that we prefix the shell commands with a "-" to indicate to the
# shell that it is supposed to be a login shell.  Normally this is handled by
# login, but since we are bypassing login in this case, BusyBox lets you do
# this yourself...
#
# Start an "askfirst" shell on the console (whatever that may be)
::respawn:-/bin/sh
# Start an "askfirst" shell on /dev/tty2-4
tty2::askfirst:-/bin/sh
tty3::askfirst:-/bin/sh
tty4::askfirst:-/bin/sh

# /sbin/getty invocations for selected ttys
#tty4::respawn:/sbin/getty 38400 tty5
#tty5::respawn:/sbin/getty 38400 tty6

# Example of how to put a getty on a serial line (for a terminal)
#::respawn:/sbin/getty -L ttyS0 9600 vt100
#::respawn:/sbin/getty -L ttyS1 9600 vt100
#
# Example how to put a getty on a modem line.
#::respawn:/sbin/getty 57600 ttyS2

### We moved this stuff to init.d/rcS!!!
#### Start the gme-application
::respawn:/home/heimo/gme-start

# Start the GSM-Connection Utility
#::respawn:/bin/sleep 10 \; /home/heimo/gsm-uplink
::respawn:/home/heimo/gsm-uplink

# Stuff to do before rebooting
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
#::shutdown:/sbin/swapoff -a
    

rc.config ist ein Applikationsspezifisches Startscript, das für die Aufgabe meiner Applikation Environmentvariablen setzt, die beim Starten der Applikation benötigt werden.


Weiter Zurück Inhalt