Idunn is an small system aiming to give an early rescue/install environment with ssh support, making life easier when one doesn't have physical access to machine.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
3.4 KiB

  1. #!/bin/sh
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: target/idunn/initramfs/etc_rc.d_rc.sysinit.sh
  6. # Copyright (C) 2008 - 2009 The OpenSDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- SDE-COPYRIGHT-NOTE-END ---
  15. . /etc/rc.d/functions.in
  16. banner "I am Idunn, take an apple and live forever."
  17. # keep the console clean
  18. if [ -x /bin/dmesg ]; then
  19. dmesg -n 3
  20. dmesg > /var/log/boot.log
  21. fi
  22. title "Mounting special filesystems"
  23. check mount -n -t proc proc /proc
  24. check mount -n -t sysfs sysfs /sys
  25. check mount -n -t tmpfs tmp /tmp
  26. status
  27. # Parse command line
  28. init=
  29. root=
  30. rootdelay=
  31. root_mode=
  32. for x in $(cat /proc/cmdline | tr -d ";\"'"); do
  33. case "$x" in
  34. ro|rw) root_mode=$x ;;
  35. root=*|init=*|rootdelay=*)
  36. eval "$x" ;;
  37. esac
  38. done
  39. root_method=device
  40. case "$root" in
  41. nfs:*) root="${root#nfs:}"
  42. root_method=nfs
  43. ;;
  44. UUID=*|LABEL=*)
  45. root_method=find
  46. ;;
  47. /dev/*)
  48. ;;
  49. *)
  50. [ -z "$root" ] || root="/dev/$root"
  51. ;;
  52. esac
  53. cat > /etc/conf/idunn <<EOT
  54. rootfs="/rootfs"
  55. root="$root"
  56. root_method="$root_method"
  57. root_mode="${root_mode:-ro}"
  58. init="${init:-/sbin/init}"
  59. initopt="$*"
  60. EOT
  61. title "Preparing /dev"
  62. check mount -n -t tmpfs udev /dev
  63. check mkdir /dev/pts
  64. check mount -n -t devpts devpts /dev/pts
  65. check cp -a /lib/udev/devices/* /dev
  66. status
  67. title "Starting supervisor"
  68. check start-stop-daemon -S -b -x /usr/bin/runsvdir -- /var/service/
  69. status
  70. # wait for udev
  71. while [ ! -d /dev/.udev/ ]; do
  72. sleep 1;
  73. done
  74. # load/blacklist modules
  75. if [ -x /sbin/modprobe -a -n "$modules" ]; then
  76. title "Preloading requested kernel modules"
  77. for x in $(echo "$modules" | tr ':' ' '); do
  78. if expr "$x" : - > /dev/null; then
  79. echo "blacklist ${x#-}" >> /etc/modprobe.conf
  80. else
  81. check modprobe $(echo "$x" | tr ',' ' ')
  82. fi
  83. done
  84. status
  85. fi
  86. force_shell=
  87. use_lvm=
  88. use_mdadm=
  89. if [ -n "$idunn" ]; then
  90. for x in $(echo "$idunn" | tr ':' ' '); do
  91. case "$x" in
  92. *=*) y="${x#*=}"
  93. x="${x%%=*}"
  94. ;;
  95. no*) x="${x#no}"
  96. y="no"
  97. ;;
  98. *) y="yes"
  99. ;;
  100. esac
  101. case "$x" in
  102. shell|stop) eval "force_shell=$y" ;;
  103. lvm|mdadm) eval "use_${x}=$y" ;;
  104. esac
  105. done
  106. fi
  107. # assuming the network module is built-in or preloaded, start it earlier
  108. for x in $(unet pending); do
  109. title "Starting network (interface:$x)"
  110. check unet $x up
  111. status
  112. done
  113. title "Triggering coldplug"
  114. check udevadm trigger
  115. check udevadm settle
  116. status
  117. # and for those which appeared after udevtrigger
  118. for x in $(unet pending); do
  119. title "Starting network (interface:$x)"
  120. check unet $x up
  121. status
  122. done
  123. if [ "${rootdelay:-0}" != "0" ]; then
  124. title "Waiting ${rootdelay}s for the device(s) to settle."
  125. check sleep "$rootdelay"
  126. status
  127. fi
  128. if [ "$use_mdadm" = "yes" ]; then
  129. title "Detecting RAID volumes"
  130. check mdadm -Esv > /etc/mdadm.conf
  131. status
  132. fi
  133. if [ -s /etc/mdadm.conf -o -s /etc/mdadm/mdadm.conf ]; then
  134. title "Starting RAID volumes"
  135. check mdadm -As
  136. sleep 1
  137. status
  138. fi
  139. if [ "$use_lvm" = "yes" ]; then
  140. title "Detecting LVM volumes"
  141. check vgscan
  142. status
  143. fi
  144. if [ -n "$(ls -1 /etc/lvm/archive/*.vg 2> /dev/null)" ]; then
  145. title "Starting LVM volumes"
  146. modprobe dm-mod
  147. check vgchange -ay
  148. status
  149. fi
  150. if [ "$force_shell" = 'yes' ]; then
  151. touch /var/run/.idunn-stop
  152. fi