3 # SPDX-License-Identifier: BSD-2-Clause-FreeBSD
5 # Copyright (c) 2010 iXsystems, Inc. All rights reserved.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 # Functions which perform mounting / unmounting and switching of
33 . ${BACKEND}/functions.sh
34 . ${BACKEND}/functions-parse.sh
36 # Displays an optical failure message
39 # If we got here, we must not have a DVD/USB we can find :(
40 get_value_from_cfg installInteractive
41 if [ "${VAL}" = "yes" ]
43 # We are running interactive, and didn't find a DVD, prompt user again
44 echo_log "DISK ERROR: Unable to find installation disk!"
45 echo_log "Please insert the installation disk and press enter."
48 exit_err "ERROR: Unable to locate installation DVD/USB"
52 # Performs the extraction of data to disk
57 # Ensure we have a directory where its supposed to be
58 if [ ! -d "${CDMNT}" ]
64 # Start by checking if we already have a cd mounted at CDMNT
65 mount | grep -q "${CDMNT} " 2>/dev/null
68 if [ -e "${CDMNT}/${INSFILE}" ]
70 echo "MOUNTED" >${TMPDIR}/cdmnt
71 echo_log "FOUND DVD: MOUNTED"
76 # failed to find optical disk
81 # Setup our loop to search for installation media
86 # Loop though and look for an installation disk
87 for i in `ls -1 /dev/cd* 2>/dev/null`
90 /sbin/mount_cd9660 $i ${CDMNT}
92 # Check the package type to see if we have our install data
93 if [ -e "${CDMNT}/${INSFILE}" ]
95 echo "${i}" >${TMPDIR}/cdmnt
96 echo_log "FOUND DVD: ${i}"
100 /sbin/umount ${CDMNT} >/dev/null 2>/dev/null
103 # If no DVD found, try USB
104 if [ "$FOUND" != "1" ]
106 # Loop though and look for an installation disk
107 for i in `ls -1 /dev/da* 2>/dev/null`
109 # Check if we can mount this device UFS
110 /sbin/mount -r $i ${CDMNT}
112 # Check the package type to see if we have our install data
113 if [ -e "${CDMNT}/${INSFILE}" ]
115 echo "${i}" >${TMPDIR}/cdmnt
116 echo_log "FOUND USB: ${i}"
120 /sbin/umount ${CDMNT} >/dev/null 2>/dev/null
122 # Also check if it is a FAT mount
123 /sbin/mount -r -t msdosfs $i ${CDMNT}
125 # Check the package type to see if we have our install data
126 if [ -e "${CDMNT}/${INSFILE}" ]
128 echo "${i}" >${TMPDIR}/cdmnt
129 echo_log "FOUND USB: ${i}"
133 /sbin/umount ${CDMNT} >/dev/null 2>/dev/null
135 fi # End of USB Check
138 if [ "$FOUND" = "1" ]
143 # Failed to find a disk, take action now
150 # Function to unmount optical media
153 /sbin/umount ${CDMNT} >/dev/null 2>/dev/null