]> pd.if.org Git - startuptools/blob - scripts/rc.sysinit
fix empty module list handling
[startuptools] / scripts / rc.sysinit
1 #!/bin/sh
2
3 # fstab: lists filesystems, this file is not changed from it's usual
4 # format, and is used as such
5
6 # rc.sysinit: done once at start time.  responsible for performing any
7 # necessary early system initialization.  This reads rc.conf for some
8 # of its actions
9
10 #PATH=/sbin:/usr/sbin:/bin:/usr/bin
11
12 . /etc/rc.d/functions.rc
13 . /etc/rc.conf
14
15 # * load any kernel modules needed
16
17 # TODO check for /etc/fstab
18 # write one if missing?
19
20 # need to mount sys because fsck might use it
21 # try to mount them directly if they fail from fstab?
22 # TODO bail to emergency shell if these fail?
23 # TODO set NOVIRTFS='/var/run' and the like to skip some of these?
24
25 status_begin mounting virtual filesystems
26 mountpoint -q /proc    || mount -t proc proc /proc -o nosuid,noexec,nodev
27 mountpoint -q /sys     || mount -t sysfs sys /sys -o nosuid,noexec,nodev
28 mountpoint -q /var/run     || mount -t tmpfs run /var/run -o mode=0755,nosuid,nodev
29 mountpoint -q /dev     || mount -t devtmpfs dev /dev -o mode=0755,nosuid
30 mkdir /dev/pts /dev/shm
31 mountpoint -q /dev/pts || mount -t devpts devpts /dev/pts -o mode=0620,gid=5,nosuid,noexec
32 mountpoint -q /dev/shm || mount -t tmpfs shm /dev/shm -o mode=1777,nosuid,nodev
33 # and make sure they all passed
34 mountpoint -q /proc &&
35 mountpoint -q /sys &&
36 mountpoint -q /var/run &&
37 mountpoint -q /dev &&
38 mountpoint -q /dev/pts &&
39 mountpoint -q /dev/shm
40 status_check
41
42 # bash seems to rely on this
43 ln -s /proc/self/fd /dev/fd
44
45 # * set the host name
46 status_begin Setting hostname
47 hostname ${HOSTNAME:=$(uname -s)}
48 status_check
49
50 # TODO should probably bail out if the /sys mount fails
51
52 # TODO decide if the loopback network interface should be done here or later
53 # I think later, it's not actually necessary
54
55 # * sysctl
56
57 status_begin loading sysctl.conf
58 sysctl -q -p
59 status_check
60
61 # * fsck and mount filesystems
62
63 #status_starting fsck of /
64 #mount -o remount,ro /
65 #fsck -A -T
66 # TODO actually check the return value
67 status_begin remounting root filesystem rw
68 mount -o remount,rw /
69 status_check
70
71 # need to run depmod here, just in case
72 # it should be done at kernel install time, but this can avoid
73 # errors if that goes wrong or there are new or removed modules
74 status_begin running depmod
75 depmod
76 status_check
77
78 # load any kernel modules
79 # there's probably a better way to do this
80 # this could also be done in the initial ram-disk, but
81 # this covers the case where there isn't one, but we still want
82 # to load more hardware
83 if ! is_true "$NOPROBEHW" ; then
84         status_begin "loading kernel modules"
85         modlist=$(lspci -k|grep 'Kernel modules:' | awk '{print $3}'| sort -u)
86         if [ -n "$modlist" ]; then
87                 modprobe $modlist
88         fi
89         status_check
90 fi
91
92 # set up /dev
93
94 if [ -x /sbin/mdev ] && ! is_true "$USE_UDEV" ; then
95         status_begin setting up mdev
96         echo > /dev/mdev.seq
97         echo /sbin/mdev > /proc/sys/kernel/hotplug
98         /sbin/mdev -s
99         status_check
100 elif [ -x /sbin/udevd ]; then
101         ##
102         ## begin voodoo scripting from lfs-initscripts
103         ##
104
105         # udev will handle hotplugs
106         echo > /proc/sys/kernel/hotplug
107
108         # start udev
109         # this should probably be moved to inittab or started via
110         # something that could monitor it
111         status_starting udevd daemon
112         /sbin/udevd --daemon
113         status_check
114
115         # Now traverse /sys in order to "coldplug" devices that have
116         # already been discovered
117         # this is going to fail if sys isn't mounted
118         status_begin populating udevadm triggers
119         udevadm trigger --action=add    --type=subsystems &&
120         udevadm trigger --action=add    --type=devices &&
121         udevadm trigger --action=change --type=devices
122         status_check
123
124         # Now wait for udevd to process the uevents we triggered
125         #      if ! is_true "$OMIT_UDEV_SETTLE"; then
126
127         # quoted here so 'for' doesn't confuse syntax highlighting
128         status_begin 'waiting for udevadm to settle'
129         udevadm settle
130         status_check
131         # fi
132
133         # If any LVM based partitions are on the system, ensure they
134         # are activated so they can be used.
135         #      if [ -x /sbin/vgchange ]; then /sbin/vgchange -a y >/dev/null; fi 
136         ##
137         ## end voodoo scripting
138         ##
139 fi
140
141 # * set up swap
142
143 swapon -a
144
145 # mount any remaining filesystems
146 status_begin mounting remaining filesystems
147 mount -a -t noproc,sysfs,devtmpfs,devpts,tmpfs
148 status_check
149
150 # force mtab symlink
151 rm -f /etc/mtab
152 ln -s /proc/mounts /etc/mtab
153
154 # * do any boot time /tmp cleanup or similar
155
156 # * do any utmp/wtmp initialization needed
157
158 touch /var/run/utmp
159 touch /var/log/wtmp
160
161 # * configure the console
162
163 # * set timezone and clock
164
165 status_begin setting system clock from hardware clock
166 hwclock -s
167 status_check