]> pd.if.org Git - startuptools/blob - scripts/rc.sysinit
added startup scripts
[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 # try to mount them directly if they fail from fstab?                                        
24 # TODO bail to emergency shell if these fail?                                                
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 -p /dev/{pts,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 #status_begin mounting virtual filesystems
43 #mount /proc &&
44 #mount /sys &&
45 #mount /dev
46 #status_check
47
48 # * set the host name
49 status_begin Setting hostname
50 hostname ${HOSTNAME:=$(uname -s)}
51 status_check
52
53 # TODO should probably bail out if the /sys mount fails
54
55 # TODO decide if the loopback network interface should be done here or later
56 # I think later, it's not actually necessary
57
58 # * sysctl
59
60 status_begin loading sysctl.conf
61 sysctl -q -p
62 status_check
63
64 # * set up /dev (via udev on modern linux systems)
65
66 ##
67 ## begin voodoo scripting from lfs-initscripts
68 ##
69
70 # udev will handle hotplugs
71 echo > /proc/sys/kernel/hotplug
72
73 # start udev
74 # this should probably be moved to inittab or started via
75 # something that could monitor it
76 status_starting udevd daemon
77 /lib/udev/udevd --daemon
78 status_check
79
80 # Now traverse /sys in order to "coldplug" devices that have
81 # already been discovered
82 # this is going to fail if sys isn't mounted
83 status_begin populating udevadm triggers
84 udevadm trigger --action=add    --type=subsystems &&
85 udevadm trigger --action=add    --type=devices &&
86 udevadm trigger --action=change --type=devices
87 status_check
88
89 # Now wait for udevd to process the uevents we triggered
90 #      if ! is_true "$OMIT_UDEV_SETTLE"; then
91 status_begin waiting for udevadm to settle
92 udevadm settle
93 status_check
94 #      fi
95
96 # If any LVM based partitions are on the system, ensure they
97 # are activated so they can be used.
98 #      if [ -x /sbin/vgchange ]; then /sbin/vgchange -a y >/dev/null; fi 
99
100 #      log_success_msg2 
101
102 ##
103 ## end voodoo scripting
104 ##
105
106 # * set up swap
107
108 swapon -a
109
110 # * fsck and mount filesystems
111
112 status_starting fsck of /
113 mount -o remount,ro /
114 fsck -AT
115 # TODO actually check the return value
116 mount -o remount,rw /
117 status_check
118
119 # mount any remaining filesystems
120 status_begin mounting remaining filesystems
121 mount -a -t noproc,sysfs,devtmpfs,devpts
122 status_check
123
124 rm -f /etc/mtab
125 mount -af
126
127 # * do any boot time /tmp cleanup or similar
128
129 # * do any utmp/wtmp initialization needed
130
131 touch /var/run/utmp
132 touch /var/log/wtmp
133
134 # * configure the console
135
136 # * set timezone and clock
137
138 status_begin setting system clock from hardware clock
139 hwclock -s
140 status_check