Project

General

Profile

Download (2.81 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2
# Functions which perform mounting / unmounting and switching of optical / usb media
3

    
4
. ${BACKEND}/functions.sh
5
. ${BACKEND}/functions-parse.sh
6

    
7
# Displays an optical failure message
8
opt_fail()
9
{
10
   # If we got here, we must not have a DVD/USB we can find :(
11
   get_value_from_cfg installInteractive
12
   if [ "${VAL}" = "yes" ]
13
   then
14
     # We are running interactive, and didn't find a DVD, prompt user again
15
     echo_log "DISK ERROR: Unable to find installation disk!"
16
     echo_log "Please insert the installation disk and press enter."
17
     read tmp
18
   else
19
    exit_err "ERROR: Unable to locate installation DVD/USB"
20
   fi
21
};
22

    
23
# Performs the extraction of data to disk
24
opt_mount()
25
{
26
 FOUND="0"
27

    
28
 # Ensure we have a directory where its supposed to be
29
 if [ ! -d "${CDMNT}" ]
30
 then
31
   mkdir -p ${CDMNT}
32
 fi
33

    
34

    
35
 # Start by checking if we already have a cd mounted at CDMNT
36
 mount | grep "${CDMNT} " >/dev/null 2>/dev/null
37
 if [ "$?" = "0" ]
38
 then
39
   if [ -e "${CDMNT}/${INSFILE}" ]
40
   then
41
     echo "MOUNTED" >${TMPDIR}/cdmnt
42
     echo_log "FOUND DVD: MOUNTED"
43
     FOUND="1"
44
     return
45
   fi
46

    
47
   # failed to find optical disk
48
   opt_fail
49
   return
50
 fi
51

    
52
# Setup our loop to search for installation media
53
 while
54
 z=1
55
 do
56

    
57
   # Loop though and look for an installation disk
58
   for i in `ls -1 /dev/acd* /dev/cd* /dev/scd* /dev/rscd* 2>/dev/null`
59
   do
60
     # Find the CD Device
61
     /sbin/mount_cd9660 $i ${CDMNT}
62

    
63
     # Check the package type to see if we have our install data
64
     if [ -e "${CDMNT}/${INSFILE}" ]
65
     then
66
       echo "${i}" >${TMPDIR}/cdmnt
67
       echo_log "FOUND DVD: ${i}"
68
       FOUND="1"
69
       break
70
     fi
71
     /sbin/umount ${CDMNT} >/dev/null 2>/dev/null
72
   done
73

    
74
   # If no DVD found, try USB
75
   if [ "$FOUND" != "1" ]
76
   then
77
     # Loop though and look for an installation disk
78
     for i in `ls -1 /dev/da* 2>/dev/null`
79
     do
80
       # Check if we can mount this device UFS
81
       /sbin/mount -r $i ${CDMNT}
82

    
83
       # Check the package type to see if we have our install data
84
       if [ -e "${CDMNT}/${INSFILE}" ]
85
       then
86
         echo "${i}" >${TMPDIR}/cdmnt
87
         echo_log "FOUND USB: ${i}"
88
         FOUND="1"
89
         break
90
       fi
91
       /sbin/umount ${CDMNT} >/dev/null 2>/dev/null
92

    
93
       # Also check if it is a FAT mount
94
       /sbin/mount -r -t msdosfs $i ${CDMNT}
95

    
96
       # Check the package type to see if we have our install data
97
       if [ -e "${CDMNT}/${INSFILE}" ]
98
       then
99
         echo "${i}" >${TMPDIR}/cdmnt
100
         echo_log "FOUND USB: ${i}"
101
         FOUND="1"
102
         break
103
       fi
104
       /sbin/umount ${CDMNT} >/dev/null 2>/dev/null
105
     done
106
   fi # End of USB Check
107

    
108

    
109
   if [ "$FOUND" = "1" ]
110
   then
111
     break
112
   fi
113
   
114
   # Failed to find a disk, take action now
115
   opt_fail
116

    
117
 done
118

    
119
};
120

    
121
# Function to unmount optical media
122
opt_umount()
123
{
124
  /sbin/umount ${CDMNT} >/dev/null 2>/dev/null
125
};
126

    
(8-8/18)