3 # The installer of Dragora GNU/Linux-Libre
5 # Copyright (c) 2019-2023 Matias Fonzo, <selk@dragora.org>.
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # Exit immediately on any error
24 TMPDIR
="${TMPDIR:-$HOME}"
25 TMPFILE
="${TMPDIR}/${PROGRAM}.${RANDOM-0}$$"
26 LOCKFILE
=/tmp
/dragora-installer.lockfile
28 # Override locale settings
36 /media
/dragora-root
/sys \
37 /media
/dragora-root
/proc \
38 /media
/dragora-root
/dev \
40 /media
/dragora-packages
; \
42 if mountpoint
-q "$filesystem"
46 echo "Unmounting $(findmnt -n -o SOURCE $filesystem) from $filesystem ..."
47 if ! umount
-v -R "$filesystem"
49 echo " ^ Doing a lazy unmount for \`${filesystem}' ..."
50 umount
-v -l "$filesystem"
61 # Clean up temporary files
62 rm -f -- "$TMPFILE" "$LOCKFILE"
64 # Clean up temporary subdirectory if 'PRESERVE' is unset or null
65 test -z "$PRESERVE" && rm -rf -- "$SUBTMPDIR"
67 # Unmount possible (previously) mounted file systems
72 printf '%s\n' "" "^ Return status = $status" 1>&2
81 if test ! -d "$TMPDIR"
83 echo "${PROGRAM}: \`${TMPDIR}' is not a qualified temporary directory" 1>&2
86 if test ! -w "$TMPDIR"
88 echo "${PROGRAM}: \`${TMPDIR}' is not a writable temporary directory" 1>&2
92 trap 'chkstatus_or_exit' EXIT HUP INT QUIT ABRT TERM
94 umask 077; # Remove access for all but user.
96 # Set a lock to allow only one instance of the installer
98 if ( set -C ; echo ": $PROGRAM - locked" > $LOCKFILE ) 2> /dev
/null
102 if test -e "$LOCKFILE"
104 echo "Only one instance of \`${PROGRAM}' is allowed." 1>&2
107 echo "${PROGRAM}: \`${LOCKFILE}' lock failed." 1>&2
112 # Remove write permission for group and other
115 # Create subdirectory to store the files produced by the installer
117 # Default sets to "${HOME}/.dragora-installer"
118 SUBTMPDIR
="${TMPDIR}/.${PROGRAM}"
119 mkdir
-p -- "$SUBTMPDIR"
120 chmod 700 -- "$SUBTMPDIR"
122 # Detect and prepare initial list of Linux partition(s)
124 if fdisk
-l |
sed -e 's|Linux filesystem|Linux|g' |
grep -E -q -m 1 'Linux$'
126 fdisk
-l |
sed -e 's|Linux filesystem|Linux|g' |
grep -E 'Linux$' | \
127 sort > "${SUBTMPDIR}/partitions"
130 Linux partitions were not detected.
132 A Linux partition is required to continue the installation. You can
133 use utilities such as fdisk(8), cfdisk(8) or parted(8) to create at
134 least one Linux partition. Then run \`${PROGRAM}' again.
139 # Determine the maximum size of the terminal to be used on the dialogues
141 echo "Checking terminal size ..."
142 LINES
="${LINES:-$(tput lines)}"
143 COLUMNS
="${COLUMNS:-$(tput cols)}"
145 export SUBTMPDIR LINES COLUMNS
148 --backtitle "\\ZbThe installer of Dragora GNU/Linux-Libre 3.0" \
149 --title "INSTALLER INFORMATION" \
151 "Welcome to \\Z3${PROGRAM}\\Zn.
153 This program will help you install Dragora 3.0 on your computer.
155 Use the cursor keys to move around in the installer's menus.
157 Press \\Z3[Tab]\\Zn to jump to the next option and \
158 \\Z3[Shift]\\Zn\\Zb\\Z7+\\Zn\\Z3[Tab]\\Zn to jump to the previous one.
160 Use \\Z3[Space]\\Zn to select or unselect an item, \\Z3[Enter]\\Zn to \
161 confirm or proceed to the next menu.
163 You can use \\Z3[Ctrl]\\Zn\\Zb\\Z7+\\Zn\\Z3[C]\\Zn to abort the \
164 installation at any time.
166 To quit a dialog (such as the one you are in), press \\Z3[Esc]\\Zn.
168 " $
((LINES
- 4)) $
((COLUMNS
- 8))
170 # Try to detect and mount the hybrid ISO image, there may be a USB memory
171 # stick already inserted. If not, the media menu will be displayed.
173 mkdir
-p -- /media
/dragora-packages
175 if ! blkid
-t LABEL
="Dragora Packages" > /dev
/null
178 --backtitle "\\ZbInstallation Medium" \
179 --title "Pendrive/SDCard/CDROM" \
182 Please insert the medium labeled \"Dragora Packages\" and
183 press \\Z3[Enter]\\Zn to continue. Otherwise, a media selection
184 menu will be displayed.
186 if blkid
-t LABEL
="Dragora Packages" > /dev
/null
188 if ! mountpoint
-q /media
/dragora-packages
190 mount
-v -t iso9660 LABEL
="Dragora Packages" \
191 /media
/dragora-packages
192 echo '/media/dragora-packages/packages' \
193 > "${SUBTMPDIR}/MediumFound"
200 if ! mountpoint
-q /media
/dragora-packages
202 mount
-v -t iso9660 LABEL
="Dragora Packages" /media
/dragora-packages
205 echo '/media/dragora-packages/packages' > "${SUBTMPDIR}/MediumFound"
208 # Attempt to unmount possible pre-mounted filesystem(s)
209 mountpoint
-q /media
/dragora-root
/sys
&& umount
/media
/dragora-root
/sys
210 mountpoint
-q /media
/dragora-root
/proc
&& umount
/media
/dragora-root
/proc
211 mountpoint
-q /media
/dragora-root
/dev
&& umount
/media
/dragora-root
/dev
213 # Clean up possible empty mount-directories
214 rmdir -- /media
/dragora-packages
/media
/dragora-root
2> /dev
/null || true
216 # Double-check to see the installation directory
217 if test ! -f "${SUBTMPDIR}/MediumFound"
220 --backtitle "\\ZbInstallation Medium" \
221 --title "MEDIUM NOT FOUND" \
222 --sleep 5 --cr-wrap --infobox \
224 No means of installation was found to proceed
225 with the installation of Dragora.
227 Please check your drives and the directory
228 containing the software packages...
233 . @PARTS@MakeSwap
; # Swap devices.
234 . @PARTS@MakeFS
; # Linux partitions.
235 . @PARTS@FstabEdit
; # File system table edition (fstab).
236 . @PARTS@MountRoot
; # Mount root partition for installation.
237 . @PARTS@FstabMounts
; # Mount rest of file systems from fstab.
238 . @PARTS@ShowSeries
; # Software series.
239 . @PARTS@InstallPackages
; # Package installation.
240 . @PARTS@PostInstall
; # Post-installation.
241 . @PARTS@SetPassword
; # Password for root.
242 . @PARTS@MenuBootloader
; # Boot loader installation.
243 . @PARTS@ConfServices
; # Running services.
245 if test -e /media
/dragora-root
/etc
/fstab
247 if mountpoint
-q /media
/dragora-packages
249 umount
/media
/dragora-packages
251 if test -s "${SUBTMPDIR}/SeTCDdev"
254 dialog
--clear --colors \
255 --title "The Setup for Dragora has been completed" \
258 If you are ready, press \\Z3[Enter]\\Zn to eject
259 the installation disc...
262 if test $_status -eq 0
264 cdrom_device
="$(cat -- "${SUBTMPDIR}/CDDevice
")"
266 # Try to eject using SCSI commands, fallback on CDROM eject command
267 eject
--scsi "$cdrom_device" || eject
--cdrom "$cdrom_device"
270 --title "The Setup for Dragora has been completed" \
271 --msgbox "\\nPlease remove the installation disc.\\n" 7 44 || true
273 # Attempt to use the tray close command
274 eject
-t "$cdrom_device" > /dev
/null
2>&1 || true
276 unset -v _status cdrom_device
284 dialog
--clear --colors \
285 --backtitle "\\ZbSystem restart" \
286 --title "The Setup for Dragora has been completed." \
289 Would you like to reboot the system now?
305 echo "Going out to the shell ..."