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

Chmod cdrom on each boot...
author Christophe Lincoln <pankso@slitaz.org>
date Mon Mar 10 10:43:27 2008 +0100 (2008-03-10)
parents ab85fe3cdaa9
children 5535068053f4
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 > /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 # Start syslogd and klogd.
108 if [ "$KERNEL_LOG_DAEMONS" = "yes" ]; then
109 echo -n "Starting system log deamon: syslogd... "
110 /sbin/syslogd -s $SYSLOGD_ROTATED_SIZE && status
111 echo -n "Starting kernel log daemon: klogd... "
112 /sbin/klogd && status
113 else
114 echo "Kernel log daemons are disabled in /etc/rc.conf... "
115 fi
117 # Clean up the system.
118 if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then
119 echo -n "Cleaning up the system... "
120 rm -rf /tmp/*
121 rm -f /var/run/*.pid
122 rm -f /var/lock/*
123 status
124 else
125 echo "System clean up is disabled in /etc/rcS.conf... "
126 echo "Keeping all tmp and pid files... "
127 status
128 fi
130 # Set up tmp X11 and ICE dir.
131 echo -n "Setting up tmp X11 and ICE unix dir... "
132 /bin/mkdir -p /tmp/.X11-unix
133 /bin/mkdir -p /tmp/.ICE-unix
134 /bin/chmod 1777 /tmp/.X11-unix
135 /bin/chmod 1777 /tmp/.ICE-unix
136 status
138 # Load all modules listed in config file.
139 if [ ! "$LOAD_MODULES" = "" ]; then
140 for mod in $LOAD_MODULES
141 do
142 modprobe $mod
143 done
144 fi
146 # Start all scripts specified with $RUN_SCRIPTS.
147 echo "Executing all initialisation scripts..."
148 for script in $RUN_SCRIPTS
149 do
150 if [ -x /etc/init.d/$daemon ]; then
151 /etc/init.d/$script
152 fi
153 done
155 # Re-source main config file, in Live mode daemons list ca be modified
156 # by boot options.
157 . /etc/rcS.conf
159 # Start all daemons specified with $RUN_DAEMONS.
160 echo "Starting all daemons specified in /etc/rcS.conf..."
161 for daemon in $RUN_DAEMONS
162 do
163 if [ -x /etc/init.d/$daemon ]; then
164 /etc/init.d/$daemon start
165 fi
166 done
168 # Reset screen and display a bold message.
169 if [ -n "$MESSAGE" ]; then
170 /usr/bin/reset
171 echo -e "\033[1m$MESSAGE\033[0m"
172 fi
174 fi #logged