]> pd.if.org Git - startuptools/blobdiff - scripts/rc.sysinit
added startup scripts
[startuptools] / scripts / rc.sysinit
diff --git a/scripts/rc.sysinit b/scripts/rc.sysinit
new file mode 100644 (file)
index 0000000..52ddc70
--- /dev/null
@@ -0,0 +1,140 @@
+#!/bin/sh
+
+# fstab: lists filesystems, this file is not changed from it's usual
+# format, and is used as such
+# 
+# rc.sysinit: done once at start time.  responsible for performing any
+# necessary early system initialization.  This reads rc.conf for some
+# of its actions
+
+#PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+. /etc/rc.d/functions.rc
+. /etc/rc.conf
+
+# * load any kernel modules needed
+
+# TODO check for /etc/fstab
+# write one if missing?
+
+# need to mount sys because fsck might use it
+# try to mount them directly if they fail from fstab?
+# TODO bail to emergency shell if these fail?
+# try to mount them directly if they fail from fstab?                                        
+# TODO bail to emergency shell if these fail?                                                
+status_begin mounting virtual filesystems
+mountpoint -q /proc    || mount -t proc proc /proc -o nosuid,noexec,nodev
+mountpoint -q /sys     || mount -t sysfs sys /sys -o nosuid,noexec,nodev
+mountpoint -q /var/run     || mount -t tmpfs run /var/run -o mode=0755,nosuid,nodev
+mountpoint -q /dev     || mount -t devtmpfs dev /dev -o mode=0755,nosuid
+mkdir -p /dev/{pts,shm}                                                                      
+mountpoint -q /dev/pts || mount -t devpts devpts /dev/pts -o mode=0620,gid=5,nosuid,noexec
+mountpoint -q /dev/shm || mount -t tmpfs shm /dev/shm -o mode=1777,nosuid,nodev
+# and make sure they all passed
+mountpoint -q /proc &&
+mountpoint -q /sys &&
+mountpoint -q /var/run &&
+mountpoint -q /dev &&
+mountpoint -q /dev/pts &&
+mountpoint -q /dev/shm
+status_check
+
+#status_begin mounting virtual filesystems
+#mount /proc &&
+#mount /sys &&
+#mount /dev
+#status_check
+
+# * set the host name
+status_begin Setting hostname
+hostname ${HOSTNAME:=$(uname -s)}
+status_check
+
+# TODO should probably bail out if the /sys mount fails
+
+# TODO decide if the loopback network interface should be done here or later
+# I think later, it's not actually necessary
+
+# * sysctl
+
+status_begin loading sysctl.conf
+sysctl -q -p
+status_check
+
+# * set up /dev (via udev on modern linux systems)
+
+##
+## begin voodoo scripting from lfs-initscripts
+##
+
+# udev will handle hotplugs
+echo > /proc/sys/kernel/hotplug
+
+# start udev
+# this should probably be moved to inittab or started via
+# something that could monitor it
+status_starting udevd daemon
+/lib/udev/udevd --daemon
+status_check
+
+# Now traverse /sys in order to "coldplug" devices that have
+# already been discovered
+# this is going to fail if sys isn't mounted
+status_begin populating udevadm triggers
+udevadm trigger --action=add    --type=subsystems &&
+udevadm trigger --action=add    --type=devices &&
+udevadm trigger --action=change --type=devices
+status_check
+
+# Now wait for udevd to process the uevents we triggered
+#      if ! is_true "$OMIT_UDEV_SETTLE"; then
+status_begin waiting for udevadm to settle
+udevadm settle
+status_check
+#      fi
+
+# If any LVM based partitions are on the system, ensure they
+# are activated so they can be used.
+#      if [ -x /sbin/vgchange ]; then /sbin/vgchange -a y >/dev/null; fi 
+
+#      log_success_msg2 
+
+##
+## end voodoo scripting
+##
+
+# * set up swap
+
+swapon -a
+
+# * fsck and mount filesystems
+
+status_starting fsck of /
+mount -o remount,ro /
+fsck -AT
+# TODO actually check the return value
+mount -o remount,rw /
+status_check
+
+# mount any remaining filesystems
+status_begin mounting remaining filesystems
+mount -a -t noproc,sysfs,devtmpfs,devpts
+status_check
+
+rm -f /etc/mtab
+mount -af
+
+# * do any boot time /tmp cleanup or similar
+
+# * do any utmp/wtmp initialization needed
+
+touch /var/run/utmp
+touch /var/log/wtmp
+
+# * configure the console
+
+# * set timezone and clock
+
+status_begin setting system clock from hardware clock
+hwclock -s
+status_check