OpenSDE Framework (without history before r20070)
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.

107 lines
2.3 KiB

  1. #!/bin/sh
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: target/early/initrd/init.exec
  6. # Copyright (C) 2007 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. export PATH=/usr/bin:/usr/sbin:/bin:/sbin
  16. modules=
  17. root=
  18. mode=
  19. initrd=/sbin/init
  20. NOCOLOR=
  21. initargs="$*"
  22. # read kernel arguments
  23. [ -e /proc/cmdline ] || mount -n -t proc none /proc
  24. set -- $( cat /proc/cmdline )
  25. for x; do
  26. v="${x#*=}"
  27. case "$x" in
  28. root=*) root="$v" ;;
  29. init=*) init="$v" ;;
  30. rw|ro) mode="$x" ;;
  31. modules=*) modules=$( echo "$v" | tr ',' ' ' ) ;;
  32. nocolor) export NOCOLOR=yes ;;
  33. esac
  34. done
  35. . /etc/rc.d/functions.in
  36. banner "Starting Early User Space environment"
  37. title "Mounting /proc and /sys"
  38. check mount -n -t usbfs none /proc/bus/usb
  39. check mount -n -t sysfs none /sys
  40. status
  41. [ -x /bin/dmesg ] && /bin/dmesg -n 3
  42. title "Starting udev daemon"
  43. echo "" > /sys/kernel/uevent_helper
  44. check udevd --daemon
  45. status
  46. if [ -x /sbin/modprobe -a -n "$modules" ]; then
  47. title "Preloading requested kernel modules"
  48. for x in $modules; do
  49. echo -n " $x"
  50. check modprobe -q $x
  51. done
  52. status
  53. fi
  54. title "Triggering coldplug"
  55. check udevtrigger
  56. check udevsettle
  57. status
  58. sleep 2
  59. if [ -z "$root" ]; then
  60. echo "No root device defined, mount it on /rootfs and exit to continue."
  61. elif [ ! -e "$root" ]; then
  62. start-raid
  63. start-lvm
  64. fi
  65. if [ -n "$root" ]; then
  66. for x in $( seq 1 10 ); do
  67. [ ! -e "$root" ] || break
  68. sleep 1
  69. done
  70. if [ -e "$root" ]; then
  71. title "Mounting $root"
  72. check mount ${mode:+-o $mode} "$root" /rootfs
  73. status
  74. else
  75. echo "root device ($root) not found on time."
  76. fi
  77. fi
  78. # wait for /sbin/init
  79. while [ ! -x "/rootfs$initrd" ]; do
  80. echo "Please mount root device on /rootfs and exit to continue"
  81. setsid /bin/sh < /dev/vc/1 > /dev/vc/1 2> /dev/vc1
  82. done
  83. title "Cleaning up"
  84. check killall udevd
  85. check umount /sys
  86. check umount /proc/bus/usb
  87. check umount /proc
  88. status
  89. exec switch_root /rootfs "$initrd" "$initargs"