mirror of the now-defunct rocklinux.org
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.

97 lines
2.5 KiB

  1. #!/bin/bash
  2. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  3. #
  4. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  5. # Please add additional copyright information _after_ the line containing
  6. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  7. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  8. #
  9. # ROCK Linux: rock-src/target/lvp/x86/initrd/linuxrc2
  10. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  11. #
  12. # This program is free software; you can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation; either version 2 of the License, or
  15. # (at your option) any later version. A copy of the GNU General Public
  16. # License can be found at Documentation/COPYING.
  17. #
  18. # Many people helped and are helping developing ROCK Linux. Please
  19. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  20. # file for details.
  21. #
  22. # --- ROCK-COPYRIGHT-NOTE-END ---
  23. scan_for_lvp() {
  24. unset lvp_drives
  25. num_found=0
  26. for x in /dev/cdroms/* ; do
  27. if mount -n ${x} /mnt >/dev/null 2>&1 ; then
  28. if grep -q LVP /mnt/etc/VERSION ; then
  29. lvp_drives="${lvp_drives} ${x}"
  30. num_found=$(( ${num_found} + 1 ))
  31. fi
  32. umount /mnt
  33. fi
  34. done
  35. }
  36. if [ ! -e /dev/cdroms/cdrom0 ] ; then
  37. echo "EEP! I have not found any cdroms!"
  38. echo "Can't continue."
  39. echo
  40. echo "Press -<enter>- to shut down"
  41. read
  42. echo -n o >/proc/sysrq-trigger
  43. fi
  44. first_pass=1
  45. while : ; do
  46. scan_for_lvp
  47. if [ ${num_found} -ne 1 -o ${first_pass} -eq 0 ] ; then
  48. echo "Found ${num_found} LVP Disks. Please choose one:"
  49. choice=0
  50. for x in ${lvp_drives} ; do
  51. choice=$(( ${choice} + 1 ))
  52. echo "${choice} ${x}"
  53. eval "choice_${choice}=${x}"
  54. done
  55. echo
  56. echo "r rescan devices"
  57. echo "0 shut down"
  58. read -p "> " s
  59. if [ "${s}" == "0" ] ; then
  60. echo "Ejecting LVP Disks"
  61. for x in ${lvp_drives} ; do
  62. eject -p ${x}
  63. done
  64. echo
  65. echo "Press -<enter>- to turn off the machine."
  66. read
  67. echo -n o >/proc/sysrq-trigger
  68. while : ; do echo -n ; done
  69. fi
  70. else
  71. s=1
  72. choice_1=${lvp_drives}
  73. echo "Found LVP Disk in ${choice_1}. Starting ..."
  74. fi
  75. first_pass=0
  76. exec 2>/dev/null
  77. if [ ${s} -gt 0 -a ${s} -le ${num_found} ] ; then
  78. eval "x=\${choice_${s}}"
  79. mount -n ${x} /mnt
  80. mount --bind /dev /mnt/dev
  81. chroot /mnt /linuxrc
  82. umount /mnt/dev
  83. # man, this sucks
  84. # sometimes the livesystem's linuxrc seems to be unable to umount everything...
  85. for x in 1 2 3 4 5 6 7 8 9 0 ; do
  86. umount /mnt/* >/dev/null 2>&1
  87. done
  88. umount /mnt
  89. eject ${x}
  90. fi
  91. exec 2>&1
  92. done