archive: dragora-installer/parts: add header to explain script purposes
[dragora.git] / archive / dragora-installer / parts / MenuMedia
blob13070d87b8e7098658cc0806bea50869f474988f
1 # This file is part of the 'dragora-installer'.
3 # Purpose: Medium selector (CD/DVD/SD/Pendrive/Hard disk).
5 # Show media menu
7 while true
8 do
9     dialog --colors \
10      --backtitle "\ZbSelecting the installation medium" \
11      --title "INSTALLATION ORIGIN" \
12      --menu \
13 "Please select the installation medium containing the software packages \
14 to install Dragora:" 10 54 2 \
15      "0" "CDROM" \
16      "1" "Local or mounted directory" \
17      2> ${SUBTMPDIR}/return-MenuMedia
19     # Check for selected options
20     case "$(cat ${SUBTMPDIR}/return-MenuMedia)" in
21     0) ## CDROM
23         # Try to detect the device name via /proc
24         list="$(awk '/drive name:/{sub(/drive name:/,""); for (i=1; i<=NF; i++) print $i}' /proc/sys/dev/cdrom/info 2> /dev/null)" || true
26         # Scan device name(s) containing the packages for Dragora
27         for name in $list cdrom dvd hda hdb hdc hdd hde hdf hdh sr0 sr1 \
28                           sr2 sr3 pcd0 pcd1 pcd2 pcd3 aztcd cdu535 gscd0 \
29                           sonycd optcd sjcd mcdx0 mcdx1 sbpcd cm205cd \
30                           cm206cd mcd ; \
31         do
32             test -n "$name" || continue
34             dialog --colors \
35              --backtitle "\ZbCDROM: Discovering drive name" \
36              --title "Searching CDROM drive" --sleep 1 \
37              --infobox "Checking device: /dev/${name}" 3 34
39             test -b "$name" || continue
41             dialog --colors \
42              --backtitle "\ZbCDROM: /dev/${name}" \
43              --title "Checking device content" --sleep 1 \
44              --infobox "Mounting /dev/${name} under /media/dragora-mount" 3 52
46             if mountpoint -q /media/dragora-mount
47             then
48                 umount /media/dragora-mount
49             fi
51             if mount -t iso9660 /dev/${name} /media/dragora-mount > /dev/null 2>&1
52             then
53                 if test -d /media/dragora-mount/packages
54                 then
55                     echo "/media/dragora-mount/packages" > ${SUBTMPDIR}/MediumFound
56                     break 2;
57                 else
58                     dialog --colors \
59                      --backtitle "\ZbCDROM: Dragora packages" \
60                      --title "CD/DVD content" \
61                      --msgbox \
62 "The /dev/${name} device was successfully mounted under the\n\
63 /media/dragora-mount directory.  However, the contents\n\
64 for the Dragora packages were not found.  They are\n\
65 searched through /media/dragora-mount/packages.\n\
66 \n\
67 Next, the installer will proceed with another device\n\
68 looking for the package directory to install Dragora.\n\
69 (Let's say, if you inserted the CD/DVD containing the\n\
70 Dragora packages in a second CDROM drive)." 14 63
71                 fi
72             fi
73             continue
74         done
75         unset name list
77         dialog --colors \
78          --backtitle "\ZbSelecting the installation medium: CDROM (medium not found)" \
79          --title "CDROM detection" \
80          --ok-label "Return" \
81          --msgbox \
82 "It was not possible to detect the device name for your CDROM drive.\n\n\
83 Please return to the previous menu by pressing \Zb\Z7ENTER\Zn in order to\n\
84 try by other means..." 9 71
85         ;;
86     1) ## Local or mounted directory
87         while true
88         do
89             dialog --colors \
90              --backtitle "\ZbSelecting the installation medium: Local or mounted directory" \
91              --title "Define valid directory" \
92              --inputbox \
93 "Please enter a directory path containing the packages to\n\
94 install Dragora.  Note: the package directory search is\n\
95 relative to the specified directory.  For example, if you\n\
96 enter \"/media/harddisk\" the installer will complete the\n\
97 path by adding \"/media/harddisk/packages\"." 12 62 \
98              2> ${SUBTMPDIR}/return-MenuMedia_case1
99             answer="$(cat ${SUBTMPDIR}/return-MenuMedia_case1)"
101             test -n "$answer" || continue
103             if test ! -d "/${answer}/packages"
104             then
105                 dialog --colors \
106                  --backtitle "\ZbSelecting the installation medium: Local or mounted directory" \
107                  --title "Directory not found" \
108                  --ok-label "Return" --msgbox \
109 "The \"packages\" subdirectory does not exist\n\
110 under the specified directory:\n\
111 /${answer#/*}" 8 47
112                 continue
113             fi
115             echo "/${answer}/packages" > ${SUBTMPDIR}/MediumFound
116             unset answer
117             break 2;
118         done
119         ;;
120     esac
121 done