functions-mountoptical.sh (209552) | functions-mountoptical.sh (211730) |
---|---|
1#!/bin/sh 2#- 3# Copyright (c) 2010 iXsystems, Inc. All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions 7# are met: 8# 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 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 24# SUCH DAMAGE. 25# | 1#!/bin/sh 2#- 3# Copyright (c) 2010 iXsystems, Inc. All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions 7# are met: 8# 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 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 24# SUCH DAMAGE. 25# |
26# $FreeBSD: head/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh 209552 2010-06-27 16:46:11Z imp $ | 26# $FreeBSD: head/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh 211730 2010-08-24 06:11:46Z imp $ |
27 28# Functions which perform mounting / unmounting and switching of 29# optical / usb media 30 31. ${BACKEND}/functions.sh 32. ${BACKEND}/functions-parse.sh 33 34# Displays an optical failure message 35opt_fail() 36{ | 27 28# Functions which perform mounting / unmounting and switching of 29# optical / usb media 30 31. ${BACKEND}/functions.sh 32. ${BACKEND}/functions-parse.sh 33 34# Displays an optical failure message 35opt_fail() 36{ |
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" ] 40 then 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." 44 read tmp 45 else 46 exit_err "ERROR: Unable to locate installation DVD/USB" 47 fi | 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" ] 40 then 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." 44 read tmp 45 else 46 exit_err "ERROR: Unable to locate installation DVD/USB" 47 fi |
48}; 49 50# Performs the extraction of data to disk 51opt_mount() 52{ | 48}; 49 50# Performs the extraction of data to disk 51opt_mount() 52{ |
53 FOUND="0" | 53 FOUND="0" |
54 | 54 |
55 # Ensure we have a directory where its supposed to be 56 if [ ! -d "${CDMNT}" ] 57 then 58 mkdir -p ${CDMNT} 59 fi | 55 # Ensure we have a directory where its supposed to be 56 if [ ! -d "${CDMNT}" ] 57 then 58 mkdir -p ${CDMNT} 59 fi |
60 61 | 60 61 |
62 # Start by checking if we already have a cd mounted at CDMNT 63 mount | grep "${CDMNT} " >/dev/null 2>/dev/null 64 if [ "$?" = "0" ] 65 then 66 if [ -e "${CDMNT}/${INSFILE}" ] 67 then 68 echo "MOUNTED" >${TMPDIR}/cdmnt 69 echo_log "FOUND DVD: MOUNTED" 70 FOUND="1" 71 return 72 fi | 62 # Start by checking if we already have a cd mounted at CDMNT 63 mount | grep "${CDMNT} " >/dev/null 2>/dev/null 64 if [ "$?" = "0" ] 65 then 66 if [ -e "${CDMNT}/${INSFILE}" ] 67 then 68 echo "MOUNTED" >${TMPDIR}/cdmnt 69 echo_log "FOUND DVD: MOUNTED" 70 FOUND="1" 71 return 72 fi |
73 | 73 |
74 # failed to find optical disk 75 opt_fail 76 return 77 fi | 74 # failed to find optical disk 75 opt_fail 76 return 77 fi |
78 | 78 |
79# Setup our loop to search for installation media 80 while 81 z=1 82 do | 79 # Setup our loop to search for installation media 80 while 81 z=1 82 do |
83 | 83 |
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` 86 do 87 # Find the CD Device 88 /sbin/mount_cd9660 $i ${CDMNT} | 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` 86 do 87 # Find the CD Device 88 /sbin/mount_cd9660 $i ${CDMNT} |
89 | 89 |
90 # Check the package type to see if we have our install data 91 if [ -e "${CDMNT}/${INSFILE}" ] 92 then 93 echo "${i}" >${TMPDIR}/cdmnt 94 echo_log "FOUND DVD: ${i}" 95 FOUND="1" 96 break 97 fi 98 /sbin/umount ${CDMNT} >/dev/null 2>/dev/null 99 done | 90 # Check the package type to see if we have our install data 91 if [ -e "${CDMNT}/${INSFILE}" ] 92 then 93 echo "${i}" >${TMPDIR}/cdmnt 94 echo_log "FOUND DVD: ${i}" 95 FOUND="1" 96 break 97 fi 98 /sbin/umount ${CDMNT} >/dev/null 2>/dev/null 99 done |
100 | 100 |
101 # If no DVD found, try USB 102 if [ "$FOUND" != "1" ] 103 then 104 # Loop though and look for an installation disk 105 for i in `ls -1 /dev/da* 2>/dev/null` 106 do 107 # Check if we can mount this device UFS 108 /sbin/mount -r $i ${CDMNT} | 101 # If no DVD found, try USB 102 if [ "$FOUND" != "1" ] 103 then 104 # Loop though and look for an installation disk 105 for i in `ls -1 /dev/da* 2>/dev/null` 106 do 107 # Check if we can mount this device UFS 108 /sbin/mount -r $i ${CDMNT} |
109 | 109 |
110 # Check the package type to see if we have our install data 111 if [ -e "${CDMNT}/${INSFILE}" ] 112 then 113 echo "${i}" >${TMPDIR}/cdmnt 114 echo_log "FOUND USB: ${i}" 115 FOUND="1" 116 break 117 fi 118 /sbin/umount ${CDMNT} >/dev/null 2>/dev/null | 110 # Check the package type to see if we have our install data 111 if [ -e "${CDMNT}/${INSFILE}" ] 112 then 113 echo "${i}" >${TMPDIR}/cdmnt 114 echo_log "FOUND USB: ${i}" 115 FOUND="1" 116 break 117 fi 118 /sbin/umount ${CDMNT} >/dev/null 2>/dev/null |
119 | 119 |
120 # Also check if it is a FAT mount 121 /sbin/mount -r -t msdosfs $i ${CDMNT} | 120 # Also check if it is a FAT mount 121 /sbin/mount -r -t msdosfs $i ${CDMNT} |
122 | 122 |
123 # Check the package type to see if we have our install data 124 if [ -e "${CDMNT}/${INSFILE}" ] 125 then 126 echo "${i}" >${TMPDIR}/cdmnt 127 echo_log "FOUND USB: ${i}" 128 FOUND="1" 129 break 130 fi 131 /sbin/umount ${CDMNT} >/dev/null 2>/dev/null 132 done 133 fi # End of USB Check | 123 # Check the package type to see if we have our install data 124 if [ -e "${CDMNT}/${INSFILE}" ] 125 then 126 echo "${i}" >${TMPDIR}/cdmnt 127 echo_log "FOUND USB: ${i}" 128 FOUND="1" 129 break 130 fi 131 /sbin/umount ${CDMNT} >/dev/null 2>/dev/null 132 done 133 fi # End of USB Check |
134 135 | 134 135 |
136 if [ "$FOUND" = "1" ] 137 then 138 break 139 fi | 136 if [ "$FOUND" = "1" ] 137 then 138 break 139 fi |
140 | 140 |
141 # Failed to find a disk, take action now 142 opt_fail | 141 # Failed to find a disk, take action now 142 opt_fail |
143 | 143 |
144 done | 144 done |
145 146}; 147 148# Function to unmount optical media 149opt_umount() 150{ 151 /sbin/umount ${CDMNT} >/dev/null 2>/dev/null 152}; 153 | 145 146}; 147 148# Function to unmount optical media 149opt_umount() 150{ 151 /sbin/umount ${CDMNT} >/dev/null 2>/dev/null 152}; 153 |