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:-$HOME}"
24 TMPFILE
="${TMPDIR}/${PROGRAM}.${RANDOM-0}$$"
25 LOCKFILE
=/tmp
/dragora-installer.lockfile
31 # Clean up temporary files
32 rm -f -- "$TMPFILE" "$LOCKFILE"
34 # Clean up temporary subdirectory related to the installer
35 test -d "$SUBTMPDIR" && rm -rf -- "$SUBTMPDIR"
39 printf "%s\n" "" "Return status = $status" 1>&2
48 if test ! -d "$TMPDIR"
50 echo "${PROGRAM}: \`${TMPDIR}' is not a qualified temporary directory" 1>&2
53 if test ! -w "$TMPDIR"
55 echo "${PROGRAM}: \`${TMPDIR}' is not a writable temporary directory" 1>&2
59 trap 'chkstatus_or_exit' EXIT HUP INT QUIT ABRT TERM
61 umask 077; # Remove access for all but user.
63 # Set a lock to allow only one instance of the installer
65 if ( set -C ; echo ": $PROGRAM - locked" > $LOCKFILE ) 2> /dev
/null
69 if test -e "$LOCKFILE"
71 echo "Only one instance of \`${PROGRAM}' is allowed." 1>&2
74 echo "${PROGRAM}: \`${LOCKFILE}' lock failed." 1>&2
79 # Create subdirectory to store the files produced by the installer
81 SUBTMPDIR
="${TMPDIR}/.${PROGRAM}" # Default sets to "${HOME}/.dragora-installer".
82 mkdir
-p -m 700 -- $SUBTMPDIR
85 # Detect and prepare list of Linux partition(s)
87 if fdisk
-l |
grep -q -m 1 Linux
89 fdisk
-l |
grep Linux | LC_COLLATE
=C
sort > ${SUBTMPDIR}/partitions
92 " Linux partitions were not detected." \
94 "A Linux partition is required to continue the installation. You can" \
95 "use utilities such as fdisk(8), cfdisk(8) or parted(8) to create at" \
96 "least one Linux partition. Then run \`${PROGRAM}' again." \
101 umask 022; # Remove write permission for group and other.
104 --backtitle "\ZbDragora 3.0 Installer" \
106 --title "INSTALLER INFORMATION" \
108 "Welcome to \Z3${PROGRAM}\Zn.\n\n\
109 This program prepares Dragora 3.0 to run on your computer.\n\n\
110 - To set up Dragora now, press \Zb\Z7ENTER\Zn.\n\n\
111 - To quit, press \Zb\Z7ESC\Zn.\n\n\
112 Please read the installer's help before proceeding (\Zb\Z7F1\Zn)." 14 63
114 # Try to detect and mount the hybrid ISO image, there may be a USB memory
115 # stick already inserted. If not, the media menu will be displayed.
117 mkdir
-p -- /media
/dragora-mount
119 if ! blkid
-t LABEL
="Dragora Packages" 2> /dev
/null
122 --backtitle "\ZbInstallation Medium" \
123 --title "Pendrive/SDCard/CDROM" \
125 "Please insert the media labeled as \"Dragora Packages\" and\n\
126 press \Zb\Z7ENTER\Zn to continue. Otherwise a media selection menu\n\
127 will be displayed." 7 63
128 if blkid
-t LABEL
="Dragora Packages" 2> /dev
/null
130 mount
-t iso9660 LABEL
="Dragora Packages" /media
/dragora-mount
2> /dev
/null
131 echo "/media/dragora-mount/packages" > ${SUBTMPDIR}/MediumFound
137 # Clean up possible empty mount-directory
138 rmdir -- /media
/dragora-mount
2> /dev
/null || true
140 # Double-check to see the installation directory
141 if test ! -f "${SUBTMPDIR}/MediumFound"
144 --backtitle "\ZbInstallation Medium" \
145 --title "MEDIUM NOT FOUND" \
146 --sleep 7 --infobox \
147 "\nNo means of installation was found to proceed with\n\
148 the installation of Dragora. Please check your\n\
149 drives and the directory containing the software\n\
154 . .
/parts
/MakeSwap
# Verify/give format to a swap partition.