slitaz-boot-scripts rev 5

Add the main init script : /etc/init.d/rcS
author Christophe Lincoln <pankso@slitaz.org>
date Fri Nov 30 12:29:35 2007 +0100 (2007-11-30)
parents c8e1e2cba56a
children 5ef45b38e0e5
files etc/init.d/rcS
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/etc/init.d/rcS	Fri Nov 30 12:29:35 2007 +0100
     1.3 @@ -0,0 +1,130 @@
     1.4 +#!/bin/sh
     1.5 +# /etc/init.d/rcS - Initial boot script for SliTaz GNU/Linux. rcS is the main
     1.6 +# initialisation script used to check fs, mount, clean, run scripts and start
     1.7 +# daemons.
     1.8 +#
     1.9 +# Config file is : /etc/rcS.conf
    1.10 +#
    1.11 +. /etc/init.d/rc.functions
    1.12 +. /etc/rcS.conf
    1.13 +
    1.14 +# Start by sleeping a bit.
    1.15 +echo "Processing /etc/init.d/rcS... "
    1.16 +sleep 1
    1.17 +
    1.18 +# Mount /proc.
    1.19 +echo -n "Mounting proc filesystem... "
    1.20 +/bin/mount proc
    1.21 +status && sleep 1
    1.22 +
    1.23 +# Before mounting filesystems we check fs specified in the file
    1.24 +# /etc/rcS.conf and variable $CHECK_FS.
    1.25 +if [ ! "$CHECK_FS" = "" ]; then
    1.26 +	mount -o remount,ro /
    1.27 +	for i in $CHECK_FS
    1.28 +	do
    1.29 +		echo "Checking filesystem on : $i"
    1.30 +		/sbin/e2fsck -p $i
    1.31 +		sleep 2
    1.32 +	done
    1.33 +fi
    1.34 +
    1.35 +# Remount rootfs rw.
    1.36 +echo "Remounting rootfs read/write... "
    1.37 +/bin/mount -o remount,rw /
    1.38 +
    1.39 +# Mount all stuff from /etc/fstab.
    1.40 +echo "Mounting all staff from fstab... "
    1.41 +/bin/mount -a
    1.42 +
    1.43 +# Start Udev to populate /dev and handle hotplug events
    1.44 +if [ "$UDEV" = "yes" ]; then
    1.45 +	echo -n "Starting udev daemon..."
    1.46 +	/sbin/udevd --daemon
    1.47 +	status
    1.48 +	echo -n "Executing : udevstart..."
    1.49 +	/sbin/udevstart
    1.50 +	status
    1.51 +	echo "/sbin/udevd" > /proc/sys/kernel/hotplug
    1.52 +fi
    1.53 +
    1.54 +# Handle kernel cmdline parameter config=<device>,<path> to source a 
    1.55 +# disk init script
    1.56 +if grep -q " config=" /proc/cmdline; then
    1.57 +	CONFIG=`cat /proc/cmdline | sed 's/.* config=\([^ ]*\).*/\1/'`
    1.58 +	DEVICE=${CONFIG%,*}
    1.59 +	SCRIPT=${CONFIG#*,}
    1.60 +	echo -n "Source $SCRIPT from $DEVICE... "
    1.61 +	if /bin/mount -r $DEVICE /mnt; then
    1.62 +		. /mnt/$SCRIPT
    1.63 +		/bin/umount /mnt
    1.64 +	fi
    1.65 +	status 
    1.66 +fi
    1.67 +
    1.68 +# Start syslogd and klogd.
    1.69 +if [ "$KERNEL_LOG_DAEMONS" = "yes" ]; then
    1.70 +	echo -n "Starting system log deamon: syslogd... "
    1.71 +	/sbin/syslogd -s $SYSLOGD_ROTATED_SIZE && status
    1.72 +	echo -n "Starting kernel log daemon: klogd... "
    1.73 +	/sbin/klogd && status
    1.74 +else
    1.75 +	echo "Kernel log daemons are disabled in /etc/rc.conf... "
    1.76 +fi
    1.77 +
    1.78 +# Creat /dev/cdrom if needed.
    1.79 +if [ ! "`readlink /dev/cdrom`" ]; then
    1.80 +	DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
    1.81 +	echo -n "Creating symlink : /dev/cdrom..."
    1.82 +	ln -s /dev/$DRIVE_NAME /dev/cdrom
    1.83 +	status
    1.84 +fi
    1.85 +
    1.86 +# Clean up the system.
    1.87 +if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then
    1.88 +	echo -n "Cleaning up the system... "
    1.89 +	rm -rf /tmp/*
    1.90 +	rm -f /var/run/*.pid
    1.91 +	status
    1.92 +else
    1.93 +	echo "System clean up is disabled in /etc/rcS.conf... "
    1.94 +	echo "Keeping all tmp and pid files... "
    1.95 +	status
    1.96 +fi
    1.97 +
    1.98 +# Set up tmp X11 and ICE dir.
    1.99 +echo -n "Setting up tmp X11 and ICE unix dir... "
   1.100 +/bin/mkdir -p /tmp/.X11-unix
   1.101 +/bin/mkdir -p /tmp/.ICE-unix
   1.102 +/bin/chmod 1777 /tmp/.X11-unix
   1.103 +/bin/chmod 1777 /tmp/.ICE-unix
   1.104 +status
   1.105 +
   1.106 +# Load all modules listed in config file.
   1.107 +if [ ! "$LOAD_MODULES" = "" ]; then
   1.108 +	for mod in $LOAD_MODULES
   1.109 +	do
   1.110 +		modprobe $mod
   1.111 +	done
   1.112 +fi
   1.113 +
   1.114 +# Start all scripts specified with $RUN_SCRIPTS.
   1.115 +echo "Executing all initialisation scripts..."
   1.116 +for script in $RUN_SCRIPTS
   1.117 +do
   1.118 +	/etc/init.d/$script
   1.119 +done
   1.120 +
   1.121 +# Start all daemons specified with $RUN_DAEMONS.
   1.122 +echo "Starting all daemons specified in /etc/rcS.conf..."
   1.123 +for daemon in $RUN_DAEMONS
   1.124 +do
   1.125 +	/etc/init.d/$daemon start
   1.126 +done
   1.127 +
   1.128 +# Reset screen and display a bold message.
   1.129 +if [ -n "$MESSAGE" ]; then
   1.130 +	/usr/bin/reset
   1.131 +	echo -e "\033[1m$MESSAGE\033[0m"
   1.132 +fi
   1.133 +