slitaz-boot-scripts view etc/init.d/rcS @ rev 55

Opts eject in rcS
author Christophe Lincoln <pankso@slitaz.org>
date Thu Mar 13 17:34:58 2008 +0100 (2008-03-13)
parents 5535068053f4
children 31837608fcdf
line source
1 #!/bin/sh
2 # /etc/init.d/rcS - Initial boot script for SliTaz GNU/Linux. rcS is the main
3 # initialisation script used to check fs, mount, clean, run scripts and start
4 # daemons.
5 #
6 # Config file is : /etc/rcS.conf
7 #
8 . /etc/init.d/rc.functions
9 . /etc/rcS.conf
11 if [ "$1" != "logged" ]; then #logged
13 # Start by sleeping a bit.
14 echo "Processing /etc/init.d/rcS... "
15 sleep 1
17 # Mount /proc.
18 echo -n "Mounting proc filesystem... "
19 /bin/mount proc
20 status && sleep 1
22 # Before mounting filesystems we check fs specified in the file
23 # /etc/rcS.conf and variable $CHECK_FS.
24 if [ ! "$CHECK_FS" = "" ]; then
25 mount -o remount,ro /
26 for i in $CHECK_FS
27 do
28 echo "Checking filesystem on : $i"
29 /sbin/e2fsck -p $i
30 sleep 2
31 done
32 fi
34 # Remount rootfs rw.
35 echo "Remounting rootfs read/write... "
36 /bin/mount -o remount,rw /
38 # Mount all stuff from /etc/fstab.
39 echo "Mounting all staff from fstab... "
40 /bin/mount -a
42 # Start Udev to populate /dev and handle hotplug events
43 if [ "$UDEV" = "yes" ]; then
44 echo -n "Starting udev daemon..."
45 /sbin/udevd --daemon
46 status
47 echo -n "Executing : udevstart..."
48 /sbin/udevstart
49 status
50 echo "/sbin/udevd" > /proc/sys/kernel/hotplug
51 fi
53 /bin/dmesg > /var/log/dmesg.log
54 vcsa2txt < /dev/vcsa1 | awk 'BEGIN {s=0} /^Processing/ {s=1} { if (s) print }' >/var/log/boot.log
55 script -a -q -c '/etc/init.d/rcS logged' /var/log/boot.log
57 else #logged
59 # Creat /dev/cdrom if needed (symlink does not exist on LiveCD).
60 # Add also /dev/cdrom to fstab if entry dos not exist.
61 #
62 DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
63 if [ -n "$DRIVE_NAME" -a ! "`readlink /dev/cdrom`" ]; then
64 echo -n "Creating symlink : /dev/cdrom..."
65 ln -s /dev/$DRIVE_NAME /dev/cdrom
66 status
67 fi
68 if ! grep -q "/dev/cdrom" /etc/fstab; then
69 echo -n "Adding /dev/cdrom to fstab..."
70 echo '/dev/cdrom /media/cdrom iso9660 user,noauto 0 0' \
71 >> /etc/fstab
72 status
73 fi
74 # Chmod hack on each boot for Asunder and burnbox. Allowing all users
75 # to burn/rip CD/DVD.
76 if [ -n "$DRIVE_NAME" -a "`readlink /dev/cdrom`" ]; then
77 echo -n "Chmoding cdrom device..."
78 chmod 0666 /dev/cdrom
79 chmod 0666 /dev/$DRIVE_NAME
80 status
81 fi
83 # Handle kernel cmdline parameter modprobe=<module_list>
84 if grep -q " modprobe=" /proc/cmdline; then
85 MODULES=`sed -e 's/.* modprobe=\([^ ]*\).*/\1/' -e 's/,/\n/g' < /proc/cmdline`
86 for i in $MODULES; do
87 echo -n "Loading kernel module $i"
88 /sbin/modprobe $i
89 status
90 done
91 fi
93 # Handle kernel cmdline parameter config=<device>,<path> to source a
94 # disk init script
95 if grep -q " config=" /proc/cmdline; then
96 CONFIG=`cat /proc/cmdline | sed 's/.* config=\([^ ]*\).*/\1/'`
97 DEVICE=${CONFIG%,*}
98 SCRIPT=${CONFIG#*,}
99 echo -n "Source $SCRIPT from $DEVICE... "
100 if /bin/mount -r $DEVICE /mnt; then
101 . /mnt/$SCRIPT
102 /bin/umount /mnt
103 fi
104 status
105 fi
107 # Eject option
108 if grep -q -w "eject" /proc/cmdline; then
109 eject /dev/cdrom
110 fi
112 # Start syslogd and klogd.
113 if [ "$KERNEL_LOG_DAEMONS" = "yes" ]; then
114 echo -n "Starting system log deamon: syslogd... "
115 /sbin/syslogd -s $SYSLOGD_ROTATED_SIZE && status
116 echo -n "Starting kernel log daemon: klogd... "
117 /sbin/klogd && status
118 else
119 echo "Kernel log daemons are disabled in /etc/rc.conf... "
120 fi
122 # Clean up the system.
123 if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then
124 echo -n "Cleaning up the system... "
125 rm -rf /tmp/*
126 rm -f /var/run/*.pid
127 rm -f /var/lock/*
128 status
129 else
130 echo "System clean up is disabled in /etc/rcS.conf... "
131 echo "Keeping all tmp and pid files... "
132 status
133 fi
135 # Set up tmp X11 and ICE dir.
136 echo -n "Setting up tmp X11 and ICE unix dir... "
137 /bin/mkdir -p /tmp/.X11-unix
138 /bin/mkdir -p /tmp/.ICE-unix
139 /bin/chmod 1777 /tmp/.X11-unix
140 /bin/chmod 1777 /tmp/.ICE-unix
141 status
143 # Load all modules listed in config file.
144 if [ ! "$LOAD_MODULES" = "" ]; then
145 for mod in $LOAD_MODULES
146 do
147 modprobe $mod
148 done
149 fi
151 # Start all scripts specified with $RUN_SCRIPTS.
152 echo "Executing all initialisation scripts..."
153 for script in $RUN_SCRIPTS
154 do
155 if [ -x /etc/init.d/$script ]; then
156 /etc/init.d/$script
157 fi
158 done
160 # Re-source main config file, in Live mode daemons list ca be modified
161 # by boot options.
162 . /etc/rcS.conf
164 # Start all daemons specified with $RUN_DAEMONS.
165 echo "Starting all daemons specified in /etc/rcS.conf..."
166 for daemon in $RUN_DAEMONS
167 do
168 if [ -x /etc/init.d/$daemon ]; then
169 /etc/init.d/$daemon start
170 fi
171 done
173 # Reset screen and display a bold message.
174 if [ -n "$MESSAGE" ]; then
175 /usr/bin/reset
176 echo -e "\033[1m$MESSAGE\033[0m"
177 fi
179 fi #logged