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

clean all lock files at boot time
author Christophe Lincoln <pankso@slitaz.org>
date Mon Feb 25 17:04:17 2008 +0100 (2008-02-25)
parents 8d77d0bba811
children 15b59bbf70c4
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 # Start by sleeping a bit.
12 echo "Processing /etc/init.d/rcS... "
13 sleep 1
15 # Mount /proc.
16 echo -n "Mounting proc filesystem... "
17 /bin/mount proc
18 status && sleep 1
20 # Before mounting filesystems we check fs specified in the file
21 # /etc/rcS.conf and variable $CHECK_FS.
22 if [ ! "$CHECK_FS" = "" ]; then
23 mount -o remount,ro /
24 for i in $CHECK_FS
25 do
26 echo "Checking filesystem on : $i"
27 /sbin/e2fsck -p $i
28 sleep 2
29 done
30 fi
32 # Remount rootfs rw.
33 echo "Remounting rootfs read/write... "
34 /bin/mount -o remount,rw /
36 # Mount all stuff from /etc/fstab.
37 echo "Mounting all staff from fstab... "
38 /bin/mount -a
40 # Start Udev to populate /dev and handle hotplug events
41 if [ "$UDEV" = "yes" ]; then
42 echo -n "Starting udev daemon..."
43 /sbin/udevd --daemon
44 status
45 echo -n "Executing : udevstart..."
46 /sbin/udevstart
47 status
48 echo "/sbin/udevd" > /proc/sys/kernel/hotplug
49 fi
51 # Creat /dev/cdrom if needed (symlink does not exist on LiveCD). Chmod
52 # hack for Asunder and burnbox allowing all users to burn/rip CD/DVD.
53 # Add also /dev/cdrom to fstab if entry dos not exist.
54 #
55 DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
56 if [ ! "`readlink /dev/cdrom`" ]; then
57 echo -n "Creating symlink : /dev/cdrom..."
58 ln -s /dev/$DRIVE_NAME /dev/cdrom
59 chmod 0666 /dev/cdrom
60 status
61 fi
62 if ! grep -q "/dev/cdrom" /etc/fstab; then
63 echo -n "Adding /dev/cdrom to fstab..."
64 echo '/dev/cdrom /media/cdrom iso9660 user,noauto 0 0' \
65 >> /etc/fstab
66 status
67 fi
68 chmod 0666 /dev/$DRIVE_NAME
70 # Handle kernel cmdline parameter modprobe=<module_list>
71 if grep -q " modprobe=" /proc/cmdline; then
72 MODULES=`sed -e 's/.* modprobe=\([^ ]*\).*/\1/' -e 's/,/\n/g' < /proc/cmdline`
73 for i in $MODULES; do
74 echo -n "Loading kernel module $i"
75 /sbin/modprobe $i
76 status
77 done
78 fi
80 # Handle kernel cmdline parameter config=<device>,<path> to source a
81 # disk init script
82 if grep -q " config=" /proc/cmdline; then
83 CONFIG=`cat /proc/cmdline | sed 's/.* config=\([^ ]*\).*/\1/'`
84 DEVICE=${CONFIG%,*}
85 SCRIPT=${CONFIG#*,}
86 echo -n "Source $SCRIPT from $DEVICE... "
87 if /bin/mount -r $DEVICE /mnt; then
88 . /mnt/$SCRIPT
89 /bin/umount /mnt
90 fi
91 status
92 fi
94 # Start syslogd and klogd.
95 if [ "$KERNEL_LOG_DAEMONS" = "yes" ]; then
96 echo -n "Starting system log deamon: syslogd... "
97 /sbin/syslogd -s $SYSLOGD_ROTATED_SIZE && status
98 echo -n "Starting kernel log daemon: klogd... "
99 /sbin/klogd && status
100 else
101 echo "Kernel log daemons are disabled in /etc/rc.conf... "
102 fi
104 # Clean up the system.
105 if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then
106 echo -n "Cleaning up the system... "
107 rm -rf /tmp/*
108 rm -f /var/run/*.pid
109 rm -f /var/lock/*
110 status
111 else
112 echo "System clean up is disabled in /etc/rcS.conf... "
113 echo "Keeping all tmp and pid files... "
114 status
115 fi
117 # Set up tmp X11 and ICE dir.
118 echo -n "Setting up tmp X11 and ICE unix dir... "
119 /bin/mkdir -p /tmp/.X11-unix
120 /bin/mkdir -p /tmp/.ICE-unix
121 /bin/chmod 1777 /tmp/.X11-unix
122 /bin/chmod 1777 /tmp/.ICE-unix
123 status
125 # Load all modules listed in config file.
126 if [ ! "$LOAD_MODULES" = "" ]; then
127 for mod in $LOAD_MODULES
128 do
129 modprobe $mod
130 done
131 fi
133 # Start all scripts specified with $RUN_SCRIPTS.
134 echo "Executing all initialisation scripts..."
135 for script in $RUN_SCRIPTS
136 do
137 if [ -x /etc/init.d/$daemon ]; then
138 /etc/init.d/$script
139 fi
140 done
142 # Re-source main config file, in Live mode daemons list ca be modified
143 # by boot options.
144 . /etc/rcS.conf
146 # Start all daemons specified with $RUN_DAEMONS.
147 echo "Starting all daemons specified in /etc/rcS.conf..."
148 for daemon in $RUN_DAEMONS
149 do
150 if [ -x /etc/init.d/$daemon ]; then
151 /etc/init.d/$daemon start
152 fi
153 done
155 # Reset screen and display a bold message.
156 if [ -n "$MESSAGE" ]; then
157 /usr/bin/reset
158 echo -e "\033[1m$MESSAGE\033[0m"
159 fi