Project

General

Profile

Download (1.81 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2

    
3
echo "Running: find-update-parts" >> ${LOGOUT}
4

    
5
rm ${TMPDIR}/AvailUpgrades >/dev/null 2>/dev/null
6

    
7
FSMNT="/mnt"
8

    
9
# Get the freebsd version on this partition
10
get_fbsd_ver() {
11

    
12
  VER="`file ${FSMNT}/bin/sh | grep 'for FreeBSD' | sed 's|for FreeBSD |;|g' | cut -d ';' -f 2 | cut -d ',' -f 1`"
13
  if [ "$?" = "0" ] ; then
14
      file ${FSMNT}/bin/sh | grep '32-bit' >/dev/null 2>/dev/null
15
      if [ "${?}" = "0" ] ; then
16
        echo "${1}: FreeBSD ${VER} (32bit)"
17
      else
18
        echo "${1}: FreeBSD ${VER} (64bit)"
19
      fi
20
  fi
21

    
22
}
23

    
24
# Create our device listing
25
SYSDISK="`sysctl kern.disks | cut -d ':' -f 2 | sed 's/^[ \t]*//'`"
26
DEVS=""
27

    
28
# Now loop through these devices, and list the disk drives
29
for i in ${SYSDISK}
30
do
31

    
32
  # Get the current device
33
  DEV="${i}"
34
  # Make sure we don't find any cd devices
35
  echo "${DEV}" | grep -e "^acd[0-9]" -e "^cd[0-9]" -e "^scd[0-9]" >/dev/null 2>/dev/null
36
  if [ "$?" != "0" ] ; then
37
   DEVS="${DEVS} `ls /dev/${i}s*`" 
38
  fi
39

    
40
done
41

    
42
# Import any zpools
43
zpool import -a
44

    
45
for i in $DEVS
46
do
47
    if [ -e "${i}a.journal" ] ; then
48
      mount ${i}a.journal ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
49
      if [ "${?}" = "0" ] ; then
50
	get_fbsd_ver ${i}
51
        umount -f ${FSMNT} >/dev/null 2>/dev/null
52
      fi
53
    elif [ -e "${i}a" ]
54
    then
55
      mount ${i}a ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
56
      if [ "${?}" = "0" ] ; then
57
	get_fbsd_ver ${i}
58
        umount -f ${FSMNT} >/dev/null 2>/dev/null
59
      else
60
        # Lets try ZFS of this device
61
        ZNAME=`echo ${i} | cut -d '/' -f 3`
62
        mount -t zfs ${ZNAME}a ${FSMNT}
63
        if [ "${?}" = "0" ] ; then
64
	  get_fbsd_ver ${i}
65
          umount -f ${FSMNT} >/dev/null 2>/dev/null
66
        fi
67
      fi
68
    fi
69
done
70

    
71
# Export all zpools again, so that we can overwrite these partitions potentially
72
#for i in `zpool list -H -o name`
73
#do
74
#  zpool export -f ${i}
75
#done
(17-17/20)