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.

70 lines
1.4 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 o >/proc/sysrq-trigger
  22. fi
  23. while : ; do
  24. scan_for_lvp
  25. echo "Found ${num_found} LVP Disks. Please choose one:"
  26. choice=0
  27. for x in ${lvp_drives} ; do
  28. choice=$(( ${choice} + 1 ))
  29. echo "${choice} ${x}"
  30. done
  31. echo
  32. echo "r rescan devices"
  33. echo "0 shut down"
  34. echo -n "> "
  35. read s
  36. if [ "${s}" == "0" ] ; then
  37. echo "Ejecting LVP Disks"
  38. for x in ${lvp_drives} ; do
  39. eject -p ${x}
  40. done
  41. echo
  42. echo "Press -<enter>- to turn off the machine."
  43. read
  44. echo o >/proc/sysrq-trigger
  45. while : ; do echo -n ; done
  46. fi
  47. exec 2>/dev/null
  48. if [ ${s} -gt 0 -a ${s} -le ${num_found} ] ; then
  49. choice=0
  50. for x in ${lvp_drives} ; do
  51. choice=$(( ${choice} + 1 ))
  52. if [ ${choice} -eq ${s} ] ; then
  53. mount ${x} /mnt
  54. chroot /mnt /linuxrc
  55. # man, this sucks
  56. # sometimes the livesystem's linuxrc seems to be unable to umount everything...
  57. for x in 1 2 3 4 5 6 7 8 9 0 ; do
  58. umount /mnt/*
  59. done
  60. umount /mnt
  61. fi
  62. done
  63. fi
  64. exec 2>&1
  65. done