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.

74 lines
1.5 KiB

  1. #!/bin/bash
  2. scan_for_lvp() {
  3. unset lvp_drives
  4. num_found=0
  5. for x in /dev/cdroms/* ; do
  6. if mount -n ${x} /mnt >/dev/null 2>&1 ; then
  7. if grep -q LVP /mnt/etc/VERSION ; then
  8. lvp_drives="${lvp_drives} ${x}"
  9. num_found=$(( ${num_found} + 1 ))
  10. fi
  11. umount /mnt
  12. fi
  13. done
  14. }
  15. if [ ! -e /dev/cdroms/cdrom0 ] ; then
  16. echo "EEP! I have not found any cdroms!"
  17. echo "Can't continue."
  18. echo
  19. echo "Press -<enter>- to shut down"
  20. read
  21. echo -n o >/proc/sysrq-trigger
  22. fi
  23. first_pass=1
  24. while : ; do
  25. scan_for_lvp
  26. if [ ${num_found} -ne 1 -o ${first_pass} -eq 0 ] ; then
  27. echo "Found ${num_found} LVP Disks. Please choose one:"
  28. choice=0
  29. for x in ${lvp_drives} ; do
  30. choice=$(( ${choice} + 1 ))
  31. echo "${choice} ${x}"
  32. eval "choice_${choice}=${x}"
  33. done
  34. echo
  35. echo "r rescan devices"
  36. echo "0 shut down"
  37. read -p "> " s
  38. if [ "${s}" == "0" ] ; then
  39. echo "Ejecting LVP Disks"
  40. for x in ${lvp_drives} ; do
  41. eject -p ${x}
  42. done
  43. echo
  44. echo "Press -<enter>- to turn off the machine."
  45. read
  46. echo -n o >/proc/sysrq-trigger
  47. while : ; do echo -n ; done
  48. fi
  49. else
  50. s=1
  51. choice_1=${lvp_drives}
  52. echo "Found LVP Disk in ${choice_1}. Starting ..."
  53. fi
  54. first_pass=0
  55. exec 2>/dev/null
  56. if [ ${s} -gt 0 -a ${s} -le ${num_found} ] ; then
  57. eval "x=\${choice_${s}}"
  58. mount -n ${x} /mnt
  59. chroot /mnt /linuxrc
  60. # man, this sucks
  61. # sometimes the livesystem's linuxrc seems to be unable to umount everything...
  62. for x in 1 2 3 4 5 6 7 8 9 0 ; do
  63. umount /mnt/* >/dev/null 2>&1
  64. done
  65. umount /mnt
  66. eject ${x}
  67. fi
  68. exec 2>&1
  69. done