dntpd: Fix typo.
[dragonfly.git] / share / initrd / etc / rc
blobfddf4adbac73ed8659067fc768a2d8feeb65c2db
1 #!/bin/sh
3 # echo "Starting shell from md boot"
4 # exec sh
6 export HOME=/root
8 /sbin/mount_tmpfs tmpfs /tmp
9 /sbin/mount_tmpfs tmpfs /var
10 mkdir /var/tmp
11 mkdir /var/run
12 # / is mounted ro by default
13 /sbin/mount_ufs -w /dev/md0s0 /
15 rescue_shell() {
16 cat /etc/motd
17 echo "Starting recovery shell!"
18 exec sh
19 exit 0
22 # Start udevd
23 /sbin/udevd
25 for rcs in /etc/rc.*; do
26 if [ -x $rcs ]; then
27 . $rcs
29 done
31 echo "Mounting new root"
33 IFS=':'
34 REAL_ROOT=`sysctl -n vfs.real_root`
35 if [ "$?" -ne "0" ]; then
36 echo "Kernel does not have vfs.real_root sysctl. Please update your" \
37 "kernel if you intend to use initrd"
38 rescue_shell
40 if [ -z "${REAL_ROOT}" ]; then
41 echo "vfs.real_root sysctl not set. Dropping to a rescue shell."
42 rescue_shell
44 set -- $REAL_ROOT
45 TYPE=$1
46 unset IFS
48 if [ "$TYPE" = "local" ]; then
49 FSTYPE=$2
50 MOUNTFROM=$3
52 # Make sure MOUNTFROM begins with /dev/
53 substr="${MOUNTFROM##/dev/}"
54 if [ "$substr" = "$MOUNTFROM" ]; then
55 MOUNTFROM="/dev/$MOUNTFROM"
58 echo "executing /sbin/mount -t $FSTYPE $4 $MOUNTFROM /new_root"
59 /sbin/mount -o ro -t $FSTYPE $4 $MOUNTFROM /new_root
60 if [ "$?" -ne "0" ]; then
61 rescue_shell
63 else
64 if [ -x "/etc/rcmount_${TYPE}" ]; then
65 . /etc/rcmount_${TYPE} $@
66 if [ "$?" -ne "0" ]; then
67 rescue_shell
69 else
70 rescue_shell
74 # Stop udevd
75 read UDEVD_PID < /var/run/udevd.pid
76 kill $UDEVD_PID
78 # Clean up
79 rm -rf /var/*
80 rm -rf /tmp/*
81 /sbin/umount /var
82 /sbin/umount /tmp
84 echo "Mounting devfs on new root"
85 #/sbin/mount_devfs /new_root/dev
86 /sbin/mount_null /dev /new_root/dev