archive: dragora-installer: remove unused variable
[dragora.git] / archive / dragora-installer / dragora-installer
blobb2a946cb79fe46fd7cb256a6f8cb18bc1bcf2df4
1 #! /bin/sh -
3 # Dragora installer
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
20 set -e
22 PROGRAM="${0##*/}"
23 TMPDIR="${TMPDIR:-$HOME}"
24 TMPFILE="${TMPDIR}/${PROGRAM}.${RANDOM-0}$$"
25 LOCKFILE=/tmp/dragora-installer.lockfile
27 chkstatus_or_exit()
29 status=$?
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"
37 if test $status -ne 0
38 then
39 printf "%s\n" "" "Return status = $status" 1>&2
40 exit 2;
43 unset status
46 # Sanity checks
48 if test ! -d "$TMPDIR"
49 then
50 echo "${PROGRAM}: \`${TMPDIR}' is not a qualified temporary directory" 1>&2
51 exit 1;
53 if test ! -w "$TMPDIR"
54 then
55 echo "${PROGRAM}: \`${TMPDIR}' is not a writable temporary directory" 1>&2
56 exit 1;
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
66 then
67 true
68 else
69 if test -e "$LOCKFILE"
70 then
71 echo "Only one instance of \`${PROGRAM}' is allowed." 1>&2
72 exit 1;
73 else
74 echo "${PROGRAM}: \`${LOCKFILE}' lock failed." 1>&2
75 exit 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
83 export SUBTMPDIR
85 # Detect and prepare list of Linux partition(s)
87 if fdisk -l | grep -q -m 1 Linux
88 then
89 fdisk -l | grep Linux | LC_COLLATE=C sort > ${SUBTMPDIR}/partitions
90 else
91 printf "%s\n" \
92 " Linux partitions were not detected." \
93 "" \
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." \
98 exit 1;
101 umask 022; # Remove write permission for group and other.
103 dialog --colors \
104 --backtitle "\ZbDragora 3.0 Installer" \
105 --hfile "HELP" \
106 --title "INSTALLER INFORMATION" \
107 --msgbox \
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
120 then
121 dialog --colors \
122 --backtitle "\ZbInstallation Medium" \
123 --title "Pendrive/SDCard/CDROM" \
124 --msgbox \
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
129 then
130 mount -t iso9660 LABEL="Dragora Packages" /media/dragora-mount 2> /dev/null
131 echo "/media/dragora-mount/packages" > ${SUBTMPDIR}/MediumFound
132 else
133 . ./parts/MenuMedia
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"
142 then
143 dialog --colors \
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\
150 packages." 8 55
151 exit 99;
154 . ./parts/MakeSwap # Verify/give format to a swap partition.