5 # Copyright (c) 2019 Matias Fonzo, <selk@dragora.org>.
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
19 # Exit immediately on any error
23 TMPDIR
="${TMPDIR:-/tmp}"
24 TMPFILE
="${TMPDIR}/${PROGRAM}.${RANDOM-0}$$"
25 LOCKFILE
="${TMPDIR}/dragora-installer.lockfile"
32 # Clean up temporary files
33 rm -f -- "$TMPFILE" "$LOCKFILE"
35 # Clean up temporary subdirectory related to the installer
36 test -d "$SUBTMPDIR" && rm -rf -- "$SUBTMPDIR"
40 printf "%s\n" "" "Return status = $status" 1>&2
49 if test ! -d "$TMPDIR"
51 echo "${PROGRAM}: \`${TMPDIR}' is not a qualified temporary directory" 1>&2
54 if test ! -w "$TMPDIR"
56 echo "${PROGRAM}: \`${TMPDIR}' is not a writable temporary directory" 1>&2
60 trap 'chkstatus_or_exit' EXIT HUP INT QUIT ABRT TERM
62 umask 077; # Remove access for all but user.
64 # Set a lock to allow only one instance of the installer
66 if ( set -C ; echo ": $PROGRAM - locked" > $LOCKFILE ) 2> /dev
/null
70 if test -e "$LOCKFILE"
72 echo "Only one instance of \`${PROGRAM}' is allowed." 1>&2
75 echo "${PROGRAM}: \`${LOCKFILE}' lock failed." 1>&2
80 # Create subdirectory to store the files produced by the installer
82 SUBTMPDIR
="${TMPDIR}/${PROGRAM}" # By default "/tmp/dragora-installer"
83 mkdir
-p -m 700 -- $SUBTMPDIR
86 # Detect and prepare list of Linux partition(s)
88 if fdisk
-l |
grep -q -m 1 Linux
90 fdisk
-l |
grep Linux | LC_COLLATE
=C
sort > ${SUBTMPDIR}/partitions
93 " Linux partitions were not detected." \
95 "A Linux partition is required to continue the installation. You can" \
96 "use utilities such as fdisk(8), cfdisk(8) or parted(8) to create at" \
97 "least one Linux partition. Then run \`${PROGRAM}' again." \
102 umask 022; # Remove write permission for group and other.
105 --backtitle "\ZbDragora 3.0 Installer" \
107 --title "INSTALLER INFORMATION" \
109 "Welcome to \Z3${PROGRAM}\Zn.\n\n\
110 This program prepares Dragora 3.0 to run on your computer.\n\n\
111 - To set up Dragora now, press \Zb\Z7ENTER\Zn.\n\n\
112 - To quit, press \Zb\Z7ESC\Zn.\n\n\
113 Please read the installer's help before proceeding (\Zb\Z7F1\Zn)." 14 63
115 # Try to detect and mount the hybrid ISO image, there may be a USB memory
116 # stick already inserted. If not, the media menu will be displayed.
118 if ! blkid
-t LABEL
="Dragora Packages" 2> /dev
/null
121 --backtitle "\ZbInstallation Medium" \
122 --title "Pendrive/SDCard/CDROM" \
124 "Please insert the media labeled as \"Dragora Packages\" and\n\
125 press \Zb\Z7ENTER\Zn to continue. Otherwise a media selection menu\n\
126 will be displayed." 7 63
127 if blkid
-t LABEL
="Dragora Packages" 2> /dev
/null
129 mkdir
-p -- /media
/dragora-mount
130 mount
-t iso9660 LABEL
="Dragora Packages" /media
/dragora-mount
2> /dev
/null
131 echo "/media/dragora-mount/packages" > ${SUBTMPDIR}/MediumFound
137 # Double-check to see the installation directory
138 if test ! -f "${SUBTMPDIR}/MediumFound"
141 --backtitle "\ZbInstallation Medium" \
142 --title "MEDIUM NOT FOUND" \
143 --sleep 7 --infobox \
144 "\nNo means of installation was found to proceed with\n\
145 the installation of Dragora. Please check your\n\
146 drives and the directory containing the software\n\