MenuMedia 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. # This file is part of the 'dragora-installer'.
  2. #
  3. # Purpose: Medium selector (CD-DVD/Pendrive/SD/Hard disk).
  4. # Show media menu
  5. while true
  6. do
  7. dialog --colors \
  8. --backtitle "\\ZbSelecting the installation medium" \
  9. --title "INSTALLATION ORIGIN" \
  10. --menu \
  11. "Please select the installation medium containing the software packages \
  12. to install Dragora:" 10 54 2 \
  13. "0" "CDROM" \
  14. "1" "Local or mounted directory" \
  15. 2> "${SUBTMPDIR}/return-MenuMedia"
  16. # Check for selected options
  17. case "$(cat -- "${SUBTMPDIR}"/return-MenuMedia)" in
  18. 0) ## CDROM
  19. # Scan device name(s) containing the packages to install Dragora
  20. for name in hda hdb hdc hdd hde hdf hdh sr0 sr1 sr2 sr3 \
  21. pcd0 pcd1 pcd2 pcd3 aztcd cdu535 gscd0 \
  22. sonycd optcd sjcd mcdx0 mcdx1 sbpcd \
  23. cm205cd cm206cd mcd dvd cdrom ; \
  24. do
  25. # Prepend path for device files
  26. name=/dev/${name}
  27. dialog --colors \
  28. --backtitle "\\ZbCDROM: Discovering drive name" \
  29. --title "Searching CDROM drive" --sleep 1 \
  30. --infobox "Checking device: $name" 3 33
  31. test -b "$name" || continue
  32. # Prepare to mount and check the package directory
  33. if mountpoint -q /media/dragora-packages
  34. then
  35. umount /media/dragora-packages
  36. fi
  37. echo "Mounting ${name} under /media/dragora-packages ..."
  38. sleep 3
  39. if mount -t iso9660 $name /media/dragora-packages > /dev/null 2>&1
  40. then
  41. if test ! -e /media/dragora-packages/packages
  42. then
  43. dialog --colors \
  44. --backtitle "\\ZbCDROM: Dragora packages" \
  45. --title "CD/DVD Content" \
  46. --msgbox \
  47. "The ${name} device was successfully mounted under the\\n\
  48. /media/dragora-packages directory. However, the contents\\n\
  49. for the Dragora packages were not found. They are\\n\
  50. searched through /media/dragora-packages/packages.\\n\
  51. \\n\
  52. The installer can check for another device name (such as\\n\
  53. a secondary CDROM drive) looking for the package directory\\n\
  54. in order to install Dragora.\\n\
  55. \\n\
  56. Press \\Z3[Enter]\Zn to proceed..." 14 63
  57. continue
  58. else
  59. # Save reference directory
  60. echo "/media/dragora-packages/packages" \
  61. > "${SUBTMPDIR}/MediumFound"
  62. # Save device name to eject later
  63. echo "$name" > "${SUBTMPDIR}/CDDevice"
  64. break 2;
  65. fi
  66. fi
  67. done
  68. unset -v name
  69. dialog --colors \
  70. --backtitle "\\ZbSelecting the installation medium: CDROM (medium not found)" \
  71. --title "CDROM detection" \
  72. --ok-label "Return" \
  73. --msgbox \
  74. "It was not possible to detect the device name for your CDROM drive.\\n\\n\
  75. Please return to the previous menu by pressing \\Z3[Enter]\Zn in order to\\n\
  76. try by other means..." 9 71
  77. ;;
  78. 1) ## Local or mounted directory
  79. while true
  80. do
  81. dialog --colors \
  82. --backtitle "\\ZbSelecting the installation medium: Local or mounted directory" \
  83. --title "Define valid directory" \
  84. --cancel-label "- Back" --inputbox \
  85. "Please enter a directory path containing the packages to\\n\
  86. install Dragora. Note: the package directory search is\\n\
  87. relative to the specified directory. For example, if you\\n\
  88. enter \"/media/harddisk\" the installer will complete the\\n\
  89. path by adding \"/media/harddisk/packages\"." 12 62 \
  90. 2> "${SUBTMPDIR}/return-MenuMedia_case1" || continue 2;
  91. answer="$(cat -- "${SUBTMPDIR}"/return-MenuMedia_case1)"
  92. test -n "$answer" || continue
  93. if test ! -d "/${answer}/packages"
  94. then
  95. dialog --colors \
  96. --backtitle "\\ZbSelecting the installation medium: Local or mounted directory" \
  97. --title "Directory not found" \
  98. --ok-label "Return" --msgbox \
  99. "The \"packages\" subdirectory does not exist\\n\
  100. under the specified directory:\\n\
  101. /${answer#/*}" 8 47
  102. continue
  103. fi
  104. echo "/${answer}/packages" > "${SUBTMPDIR}/MediumFound"
  105. unset -v answer
  106. break 2;
  107. done
  108. ;;
  109. esac
  110. done