flavors rev 81

core: add tmp rcS init script
author Christophe Lincoln <pankso@slitaz.org>
date Sun Jan 23 13:43:33 2011 +0100 (2011-01-23)
parents 242a1354b3ce
children 36efc35c6c42
files core/rootfs/etc/init.d/rcS
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/core/rootfs/etc/init.d/rcS	Sun Jan 23 13:43:33 2011 +0100
     1.3 @@ -0,0 +1,257 @@
     1.4 +#!/bin/sh
     1.5 +# /etc/init.d/rcS - Initial boot script for SliTaz GNU/Linux. 
     1.6 +# Config file is : /etc/rcS.conf
     1.7 +#
     1.8 +# rcS is the main initialization script used to check fs, mount, clean,
     1.9 +# run scripts and start daemons.
    1.10 +#
    1.11 +. /etc/init.d/rc.functions
    1.12 +. /etc/rcS.conf
    1.13 +
    1.14 +# Boot time.
    1.15 +bootdate=`date +%s`
    1.16 +
    1.17 +if [ "$1" != "logged" ]; then # logged
    1.18 +
    1.19 +echo "Processing /etc/init.d/rcS..."
    1.20 +
    1.21 +# Mount /proc.
    1.22 +echo -n "Mounting proc filesystem..."
    1.23 +/bin/mount proc
    1.24 +status
    1.25 +
    1.26 +# Parse cmdline args for earlier boot options. All other boot options
    1.27 +# are in /etc/init./bootopts.sh.
    1.28 +echo -n "Searching for early boot options..."
    1.29 +for opt in `cat /proc/cmdline`
    1.30 +do
    1.31 +	case $opt in
    1.32 +		fastbootx|fbx)
    1.33 +			export FAST_BOOT_X="yes" ;;
    1.34 +		cdrom=*)
    1.35 +			export CDROM=${opt#cdrom=} ;;
    1.36 +		modprobe=*)
    1.37 +			export MODPROBE="yes" ;;
    1.38 +		config=*)
    1.39 +			export CONFIG=${opt#config=} ;;
    1.40 +		*)
    1.41 +			continue ;;
    1.42 +	esac
    1.43 +done
    1.44 +status
    1.45 +
    1.46 +# Start Udev to populate /dev and handle hotplug events
    1.47 +if [ "$UDEV" = "yes" ]; then
    1.48 +	#echo -n "Starting udev daemon..."
    1.49 +	#/sbin/udevd --daemon
    1.50 +	#status
    1.51 +	#echo -n "Udevadm requesting events from the Kernel..."
    1.52 +	#udevadm trigger
    1.53 +	#status
    1.54 +	#echo -n "Udevadm waiting for the event queue to finish..."
    1.55 +	#udevadm settle
    1.56 +	#status
    1.57 +	echo -n "Using udev daemon for hotplug..."
    1.58 +	echo "/sbin/udevd" > /proc/sys/kernel/hotplug
    1.59 +	status
    1.60 +fi
    1.61 +
    1.62 +# Before mounting filesystems we check fs specified in the file
    1.63 +# /etc/rcS.conf and variable $CHECK_FS.
    1.64 +if [ -n "$CHECK_FS" ]; then
    1.65 +	mount -o remount,ro /
    1.66 +	for i in $CHECK_FS
    1.67 +	do
    1.68 +		echo "Checking filesystem on : $i"
    1.69 +		/sbin/e2fsck -p $i
    1.70 +	done
    1.71 +fi
    1.72 +
    1.73 +# Remount rootfs rw.
    1.74 +echo "Remounting rootfs read/write..."
    1.75 +/bin/mount -o remount,rw /
    1.76 +
    1.77 +# Mount filesystems in /etc/fstab.
    1.78 +echo "Mounting filesystems in fstab..."
    1.79 +/bin/mount -a
    1.80 +
    1.81 +# Store boot messages to log files.
    1.82 +/bin/dmesg > /var/log/dmesg.log &
    1.83 +conspy -d | sed 's/ *$//;/^$/d;/^Processi\|^.witchi/,$!d' > /var/log/boot.log
    1.84 +script -a -q -c '/etc/init.d/rcS logged' /var/log/boot.log
    1.85 +
    1.86 +else # logged
    1.87 +
    1.88 +# Clean up the system.
    1.89 +if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then
    1.90 +	echo -n "Cleaning up the system..."
    1.91 +	find /var/run -name "*.pid" -type f | xargs /bin/rm -f
    1.92 +	/bin/rm -rf /tmp /var/run/dbus/* /var/run/hald/pid /var/lock/*
    1.93 +	/bin/mkdir -p /tmp && /bin/chmod 1777 /tmp
    1.94 +	status
    1.95 +else
    1.96 +	echo "System clean up is disabled in /etc/rcS.conf..."
    1.97 +	echo -n "Keeping all tmp and pid files..."
    1.98 +	status
    1.99 +fi
   1.100 +
   1.101 +# Set up tmp X11 and ICE dir.
   1.102 +echo -n "Setting up tmp X11 and ICE unix dir..."
   1.103 +/bin/mkdir -p /tmp/.X11-unix /tmp/.ICE-unix
   1.104 +/bin/chmod 1777 /tmp/.X11-unix /tmp/.ICE-unix
   1.105 +status
   1.106 +
   1.107 +# Fast boot into X for HD install or custom Live system. We need 
   1.108 +# keymap settings since Xvesa dumps the console mapping and a correct
   1.109 +# slim configuration for screen resolution. DBUS and HAL must also start
   1.110 +# before X session (manual login or autologin) to have devices in PCmanFM.
   1.111 +if [ "$FAST_BOOT_X" = "yes" ]; then
   1.112 +	/etc/init.d/i18n.sh
   1.113 +	/etc/init.d/dbus start
   1.114 +	/etc/init.d/hald start
   1.115 +	/etc/init.d/slim start &
   1.116 +fi
   1.117 +
   1.118 +# Create /dev/cdrom if needed (symlink does not exist on LiveCD).
   1.119 +# Also add /dev/cdrom to fstab if entry does not exist.
   1.120 +if [ -n "$CDROM" ]; then
   1.121 +	DRIVE_NAME=${CDROM#/dev/}
   1.122 +else
   1.123 +	DRIVE_NAME=`grep -s "drive name" /proc/sys/dev/cdrom/info | cut -f 3`
   1.124 +fi
   1.125 +if [ -n "$DRIVE_NAME" -a ! "`readlink /dev/cdrom`" ]; then
   1.126 +	echo -n "Creating symlink : /dev/cdrom..."
   1.127 +	ln -s /dev/$DRIVE_NAME /dev/cdrom
   1.128 +	ln -s /dev/$DRIVE_NAME /dev/dvd
   1.129 +	status
   1.130 +fi
   1.131 +if ! grep -q "/dev/cdrom" /etc/fstab; then
   1.132 +	echo -n "Adding /dev/cdrom  to fstab..."
   1.133 +	echo '/dev/cdrom      /media/cdrom iso9660 user,ro,noauto       0       0' \
   1.134 +		>> /etc/fstab
   1.135 +	status
   1.136 +fi
   1.137 +# Chmod hack on each boot for Asunder and burnbox. Allowing all users
   1.138 +# to burn/rip CD/DVD.
   1.139 +if [ -n "$DRIVE_NAME" -a "`readlink /dev/cdrom`" ]; then
   1.140 +	echo -n "Chmoding cdrom device..."
   1.141 +	chmod 0666 /dev/cdrom
   1.142 +	chmod 0666 /dev/dvd
   1.143 +	chmod 0666 /dev/$DRIVE_NAME
   1.144 +	status
   1.145 +fi
   1.146 +
   1.147 +# Handle kernel cmdline parameter modprobe=<module_list> 
   1.148 +if [ -n "$MODPROBE" ]; then
   1.149 +	MODULES=`sed -e 's/.* modprobe=\([^ ]*\).*/\1/' -e 's/,/\n/g' < /proc/cmdline`
   1.150 +	for i in $MODULES; do
   1.151 +		echo -n "Loading kernel module $i"
   1.152 +		/sbin/modprobe $i
   1.153 +		status 
   1.154 +	done
   1.155 +fi
   1.156 +
   1.157 +# Handle kernel cmdline parameter config=<device>,<path> to source a 
   1.158 +# disk init script
   1.159 +if [ -n "$CONFIG" ]; then
   1.160 +	DEVICE=${CONFIG%,*}
   1.161 +	SCRIPT=${CONFIG#*,}
   1.162 +	echo "Probing $DEVICE... "
   1.163 +	if ! /bin/mount -r $DEVICE /mnt; then
   1.164 +		if echo $DEVICE | grep -Eq "/dev/sd|UUID=|LABEL="; then
   1.165 +			USBDELAY=`cat /sys/module/usb_storage/parameters/delay_use`
   1.166 +			USBDELAY=$((1+$USBDELAY))
   1.167 +			echo "$DEVICE is potentially a USB device: sleep for $USBDELAY seconds"
   1.168 +			sleep $USBDELAY
   1.169 +		fi
   1.170 +		if ! /bin/mount -r $DEVICE /mnt; then
   1.171 +			CONFIG=""
   1.172 +		fi
   1.173 +	fi
   1.174 +	echo -n "Source $SCRIPT from $DEVICE..."
   1.175 +	if [ -n "$CONFIG" ]; then
   1.176 +		. /mnt/$SCRIPT
   1.177 +		/bin/umount /mnt 2> /dev/null || true
   1.178 +	fi
   1.179 +	status 
   1.180 +fi
   1.181 +
   1.182 +# Mount /proc/bus/usb.
   1.183 +if [ -d /proc/bus/usb ]; then
   1.184 +	echo -n "Mounting /proc/bus/usb filesystem..."
   1.185 +	/bin/mount -t usbfs usbfs /proc/bus/usb
   1.186 +	status
   1.187 +fi
   1.188 +
   1.189 +# Start syslogd and klogd.
   1.190 +if [ "$KERNEL_LOG_DAEMONS" = "yes" ]; then
   1.191 +	echo -n "Starting system log deamon: syslogd..."
   1.192 +	/sbin/syslogd -s $SYSLOGD_ROTATED_SIZE && status
   1.193 +	echo -n "Starting kernel log daemon: klogd..."
   1.194 +	/sbin/klogd && status
   1.195 +else
   1.196 +	echo "Kernel log daemons are disabled in /etc/rc.conf..."
   1.197 +fi
   1.198 +
   1.199 +# Load all modules listed in config file.
   1.200 +if [ -n "$LOAD_MODULES" ]; then
   1.201 +	for mod in $LOAD_MODULES
   1.202 +	do
   1.203 +		modprobe $mod
   1.204 +	done
   1.205 +fi
   1.206 +
   1.207 +# Be quiet on configuration to avoid messages overwriting ncurses dialog
   1.208 +echo "0 0 0 0" > /proc/sys/kernel/printk
   1.209 +
   1.210 +# Detect PCI and USB devices with Tazhw from slitaz-tools. We load
   1.211 +# kernel modules only at first boot or in LiveCD mode.
   1.212 +if [ ! -s /var/lib/detected-modules ]; then
   1.213 +	/sbin/tazhw init
   1.214 +fi
   1.215 +
   1.216 +# Call udevadm trigger to ensure /dev is fully populate now that all 
   1.217 +# modules are loaded.
   1.218 +if [ "$UDEV" = "yes" ]; then
   1.219 +	echo -n "Requesting events from the Kernel..."
   1.220 +	udevadm trigger
   1.221 +	status
   1.222 +fi
   1.223 +
   1.224 +# Start all scripts specified with $RUN_SCRIPTS.
   1.225 +echo "Executing all initialization scripts..."
   1.226 +for script in $RUN_SCRIPTS
   1.227 +do
   1.228 +	if [ -x /etc/init.d/$script ]; then
   1.229 +		/etc/init.d/$script
   1.230 +	fi
   1.231 +done
   1.232 +
   1.233 +# Re-source main config file. In Live mode, daemons list can be modified 
   1.234 +# by boot options (screen=text will remove slim).
   1.235 +. /etc/rcS.conf
   1.236 +
   1.237 +# Start all daemons specified with $RUN_DAEMONS.
   1.238 +echo "Starting all daemons specified in /etc/rcS.conf..."
   1.239 +for daemon in $RUN_DAEMONS
   1.240 +do
   1.241 +	if [ -x /etc/init.d/$daemon ]; then
   1.242 +		/etc/init.d/$daemon start
   1.243 +	fi
   1.244 +done
   1.245 +
   1.246 +# Back to a verbose mode.
   1.247 +echo "7 4 1 7" > /proc/sys/kernel/printk
   1.248 +
   1.249 +# Reset screen and display a bold message.
   1.250 +if [ -n "$MESSAGE" ]; then
   1.251 +	/usr/bin/reset
   1.252 +	echo -e "\033[1m$MESSAGE\033[0m"
   1.253 +fi
   1.254 +
   1.255 +# Display and log boot time.
   1.256 +time=$((`date +%s` - $bootdate))
   1.257 +echo $time > /var/log/boot-time
   1.258 +echo "SliTaz boot time: ${time}s"
   1.259 +
   1.260 +fi # logged