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

Add the main init script : /etc/init.d/rcS
author Christophe Lincoln <pankso@slitaz.org>
date Fri Nov 30 12:29:35 2007 +0100 (2007-11-30)
parents
children a5e2677812ab
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 # Handle kernel cmdline parameter config=<device>,<path> to source a
52 # disk init script
53 if grep -q " config=" /proc/cmdline; then
54 CONFIG=`cat /proc/cmdline | sed 's/.* config=\([^ ]*\).*/\1/'`
55 DEVICE=${CONFIG%,*}
56 SCRIPT=${CONFIG#*,}
57 echo -n "Source $SCRIPT from $DEVICE... "
58 if /bin/mount -r $DEVICE /mnt; then
59 . /mnt/$SCRIPT
60 /bin/umount /mnt
61 fi
62 status
63 fi
65 # Start syslogd and klogd.
66 if [ "$KERNEL_LOG_DAEMONS" = "yes" ]; then
67 echo -n "Starting system log deamon: syslogd... "
68 /sbin/syslogd -s $SYSLOGD_ROTATED_SIZE && status
69 echo -n "Starting kernel log daemon: klogd... "
70 /sbin/klogd && status
71 else
72 echo "Kernel log daemons are disabled in /etc/rc.conf... "
73 fi
75 # Creat /dev/cdrom if needed.
76 if [ ! "`readlink /dev/cdrom`" ]; then
77 DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
78 echo -n "Creating symlink : /dev/cdrom..."
79 ln -s /dev/$DRIVE_NAME /dev/cdrom
80 status
81 fi
83 # Clean up the system.
84 if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then
85 echo -n "Cleaning up the system... "
86 rm -rf /tmp/*
87 rm -f /var/run/*.pid
88 status
89 else
90 echo "System clean up is disabled in /etc/rcS.conf... "
91 echo "Keeping all tmp and pid files... "
92 status
93 fi
95 # Set up tmp X11 and ICE dir.
96 echo -n "Setting up tmp X11 and ICE unix dir... "
97 /bin/mkdir -p /tmp/.X11-unix
98 /bin/mkdir -p /tmp/.ICE-unix
99 /bin/chmod 1777 /tmp/.X11-unix
100 /bin/chmod 1777 /tmp/.ICE-unix
101 status
103 # Load all modules listed in config file.
104 if [ ! "$LOAD_MODULES" = "" ]; then
105 for mod in $LOAD_MODULES
106 do
107 modprobe $mod
108 done
109 fi
111 # Start all scripts specified with $RUN_SCRIPTS.
112 echo "Executing all initialisation scripts..."
113 for script in $RUN_SCRIPTS
114 do
115 /etc/init.d/$script
116 done
118 # Start all daemons specified with $RUN_DAEMONS.
119 echo "Starting all daemons specified in /etc/rcS.conf..."
120 for daemon in $RUN_DAEMONS
121 do
122 /etc/init.d/$daemon start
123 done
125 # Reset screen and display a bold message.
126 if [ -n "$MESSAGE" ]; then
127 /usr/bin/reset
128 echo -e "\033[1m$MESSAGE\033[0m"
129 fi