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.

69 lines
1.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/idunn/initramfs/init.sh
  6. # Copyright (C) 2008 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
  16. LOG=/var/log/init.log
  17. # catch some signals
  18. #
  19. shutoff_handler() {
  20. local x=
  21. # just once!
  22. ln -s / /var/run/init.lock || return
  23. # stop services
  24. /etc/rc.d/rc.shutdown
  25. # unmount stuff
  26. grep '^/' /proc/mounts | cut -d' ' -f2 | tac | while read x; do
  27. umount -r "$x"
  28. done
  29. # kill anyone else
  30. killall5 -s TERM
  31. sleep 2
  32. killall5 -s KILL
  33. # an umount the rest
  34. umount -ar
  35. case "$1" in
  36. USR1) halt -f ;;
  37. USR2) poweroff -f ;;
  38. *) reboot -f ;;
  39. esac
  40. }
  41. for x in USR1 USR2 TERM INT; do
  42. trap "shutoff_handler $x" $x
  43. done
  44. cat > /etc/conf/idunn <<EOT
  45. root="$root"
  46. init="${init:-/sbin/init}"
  47. initopt="$*"
  48. EOT
  49. # start the world
  50. /etc/rc.d/rc.sysinit 2>&1 | tee -a $LOG
  51. # attach a console
  52. ln -s /etc/console /var/service/
  53. while true; do
  54. sleep 1;
  55. done