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

Clean /tmp and pid file in cas of brutal poweroff
author Christophe Lincoln <pankso@slitaz.org>
date Fri Jun 06 23:26:27 2008 +0200 (2008-06-06)
parents 066907ea77fe
children b8357bb683ae
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 "/sbin/udevd" > /proc/sys/kernel/hotplug
48 fi
50 /bin/dmesg > /var/log/dmesg.log
51 vcsa2txt < /dev/vcsa1 | awk 'BEGIN {s=0} /^Processing/ {s=1} { if (s) print }' >/var/log/boot.log
52 script -a -q -c '/etc/init.d/rcS logged' /var/log/boot.log
54 else #logged
56 # Creat /dev/cdrom if needed (symlink does not exist on LiveCD).
57 # Add also /dev/cdrom to fstab if entry dos not exist.
58 #
59 DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
60 if grep -q " cdrom=" /proc/cmdline; then
61 DRIVE_NAME=`cat /proc/cmdline | sed 's/.* cdrom=\([^ ]*\).*/\1/'`
62 fi
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 ln -s /dev/$DRIVE_NAME /dev/dvd
67 status
68 fi
69 if ! grep -q "/dev/cdrom" /etc/fstab; then
70 echo -n "Adding /dev/cdrom to fstab..."
71 echo '/dev/cdrom /media/cdrom iso9660 user,ro,noauto 0 0' \
72 >> /etc/fstab
73 status
74 fi
75 # Chmod hack on each boot for Asunder and burnbox. Allowing all users
76 # to burn/rip CD/DVD.
77 if [ -n "$DRIVE_NAME" -a "`readlink /dev/cdrom`" ]; then
78 echo -n "Chmoding cdrom device..."
79 chmod 0666 /dev/cdrom
80 chmod 0666 /dev/dvd
81 chmod 0666 /dev/$DRIVE_NAME
82 status
83 fi
85 # Handle kernel cmdline parameter modprobe=<module_list>
86 if grep -q " modprobe=" /proc/cmdline; then
87 MODULES=`sed -e 's/.* modprobe=\([^ ]*\).*/\1/' -e 's/,/\n/g' < /proc/cmdline`
88 for i in $MODULES; do
89 echo -n "Loading kernel module $i"
90 /sbin/modprobe $i
91 status
92 done
93 fi
95 # Handle kernel cmdline parameter config=<device>,<path> to source a
96 # disk init script
97 if grep -q " config=" /proc/cmdline; then
98 CONFIG=`cat /proc/cmdline | sed 's/.* config=\([^ ]*\).*/\1/'`
99 DEVICE=${CONFIG%,*}
100 SCRIPT=${CONFIG#*,}
101 echo -n "Source $SCRIPT from $DEVICE... "
102 if /bin/mount -r $DEVICE /mnt; then
103 . /mnt/$SCRIPT
104 /bin/umount /mnt
105 fi
106 status
107 fi
109 # Eject option
110 if grep -q -w "eject" /proc/cmdline; then
111 eject /dev/cdrom
112 fi
114 # Start syslogd and klogd.
115 if [ "$KERNEL_LOG_DAEMONS" = "yes" ]; then
116 echo -n "Starting system log deamon: syslogd... "
117 /sbin/syslogd -s $SYSLOGD_ROTATED_SIZE && status
118 echo -n "Starting kernel log daemon: klogd... "
119 /sbin/klogd && status
120 else
121 echo "Kernel log daemons are disabled in /etc/rc.conf... "
122 fi
124 # Clean up the system.
125 if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then
126 echo -n "Cleaning up the system... "
127 rm -rf /tmp/* /tmp/.*
128 rm -f /var/run/*.pid /var/run/dbus/* /var/run/hald/pid
129 rm -f /var/lock/*
130 status
131 else
132 echo "System clean up is disabled in /etc/rcS.conf... "
133 echo "Keeping all tmp and pid files... "
134 status
135 fi
137 # Set up tmp X11 and ICE dir.
138 echo -n "Setting up tmp X11 and ICE unix dir... "
139 /bin/mkdir -p /tmp/.X11-unix
140 /bin/mkdir -p /tmp/.ICE-unix
141 /bin/chmod 1777 /tmp/.X11-unix
142 /bin/chmod 1777 /tmp/.ICE-unix
143 status
145 # Load all modules listed in config file.
146 if [ ! "$LOAD_MODULES" = "" ]; then
147 for mod in $LOAD_MODULES
148 do
149 modprobe $mod
150 done
151 fi
153 # Start all scripts specified with $RUN_SCRIPTS.
154 echo "Executing all initialisation scripts..."
155 for script in $RUN_SCRIPTS
156 do
157 if [ -x /etc/init.d/$script ]; then
158 /etc/init.d/$script
159 fi
160 done
162 # Re-source main config file, in Live mode daemons list ca be modified
163 # by boot options.
164 . /etc/rcS.conf
166 # Start all daemons specified with $RUN_DAEMONS.
167 echo "Starting all daemons specified in /etc/rcS.conf..."
168 for daemon in $RUN_DAEMONS
169 do
170 if [ -x /etc/init.d/$daemon ]; then
171 /etc/init.d/$daemon start
172 fi
173 done
175 # Reset screen and display a bold message.
176 if [ -n "$MESSAGE" ]; then
177 /usr/bin/reset
178 echo -e "\033[1m$MESSAGE\033[0m"
179 fi
181 fi #logged