3 # Copyright (c) 2010 iXsystems, Inc. All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
14 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 # Functions which perform mounting / unmounting and switching of
31 . ${BACKEND}/functions.sh
32 . ${BACKEND}/functions-parse.sh
34 # Displays an optical failure message
37 # If we got here, we must not have a DVD/USB we can find :(
38 get_value_from_cfg installInteractive
39 if [ "${VAL}" = "yes" ]
41 # We are running interactive, and didn't find a DVD, prompt user again
42 echo_log "DISK ERROR: Unable to find installation disk!"
43 echo_log "Please insert the installation disk and press enter."
46 exit_err "ERROR: Unable to locate installation DVD/USB"
50 # Performs the extraction of data to disk
55 # Ensure we have a directory where its supposed to be
56 if [ ! -d "${CDMNT}" ]
62 # Start by checking if we already have a cd mounted at CDMNT
63 mount | grep -q "${CDMNT} " 2>/dev/null
66 if [ -e "${CDMNT}/${INSFILE}" ]
68 echo "MOUNTED" >${TMPDIR}/cdmnt
69 echo_log "FOUND DVD: MOUNTED"
74 # failed to find optical disk
79 # Setup our loop to search for installation media
84 # Loop though and look for an installation disk
85 for i in `ls -1 /dev/acd* /dev/cd* /dev/scd* /dev/rscd* 2>/dev/null`
88 /sbin/mount_cd9660 $i ${CDMNT}
90 # Check the package type to see if we have our install data
91 if [ -e "${CDMNT}/${INSFILE}" ]
93 echo "${i}" >${TMPDIR}/cdmnt
94 echo_log "FOUND DVD: ${i}"
98 /sbin/umount ${CDMNT} >/dev/null 2>/dev/null
101 # If no DVD found, try USB
102 if [ "$FOUND" != "1" ]
104 # Loop though and look for an installation disk
105 for i in `ls -1 /dev/da* 2>/dev/null`
107 # Check if we can mount this device UFS
108 /sbin/mount -r $i ${CDMNT}
110 # Check the package type to see if we have our install data
111 if [ -e "${CDMNT}/${INSFILE}" ]
113 echo "${i}" >${TMPDIR}/cdmnt
114 echo_log "FOUND USB: ${i}"
118 /sbin/umount ${CDMNT} >/dev/null 2>/dev/null
120 # Also check if it is a FAT mount
121 /sbin/mount -r -t msdosfs $i ${CDMNT}
123 # Check the package type to see if we have our install data
124 if [ -e "${CDMNT}/${INSFILE}" ]
126 echo "${i}" >${TMPDIR}/cdmnt
127 echo_log "FOUND USB: ${i}"
131 /sbin/umount ${CDMNT} >/dev/null 2>/dev/null
133 fi # End of USB Check
136 if [ "$FOUND" = "1" ]
141 # Failed to find a disk, take action now
148 # Function to unmount optical media
151 /sbin/umount ${CDMNT} >/dev/null 2>/dev/null