#! /bin/sh # $Header$ # #*************************************************************************** # $Copyright: Copyright (c) 2022 Veritas Technologies LLC. All rights reserved $ #*************************************************************************** # # bpvxver.sh # # This script is called by the VfMS vxvm and vxfs FMMs to determine the # version of VxFS (JFS) or VxVM running on an HP-UX system. It is intended # for use only by those FMMs and only on an HP-UX system. # # This script: # Receives 1 parameter, indicating the product for which the version # is to be returned. The product may be either "VxFS" or "VxVM". # Must be executable by the root user # Should exit with a value which is ten times the version number of the # product. For example, if the product version is "3.2", the # script should exit with a value of 32. # Should exit with a 0 if the product is not installed on the system. # # This script should be installed with mode 555 so that user directed # backups and archives will be able to execute this script. # DEBUG=0 # Set to non-zero to debug script SWLIST=/usr/sbin/swlist PRODUCT= ME=`basename $0` # # error(message) - Issue error message, set exit code, and exit # error() { echo "$ME: $1" >&2; exit 0; } # # isver(version) - Issue message, set exit code, and exit # # Assumes that is in the form [0-9].[0-9].* # Anything beyond the first two digits is ignored. # isver() { rval=`echo $1 | sed 's/\([0-9]\)\.\([0-9]\).*/\1\2/'` # "Multiply" by ten by removing decimal point echo "$ME: $PRODUCT is version $1; returning $rval"; exit $rval; } # -------------------------------------------------------------------- # main script starts here # -------------------------------------------------------------------- # Set umask to 022 to make sure files and directories # are not created with world writable permissions. umask 022 if [ `uname -s` != "HP-UX" ] then error "This script is for use on HP-UX systems only" fi if [ "$#" -lt 1 ] then error "No product specified" fi if [ "$#" -gt 1 ] then error "Only one product may be specified" fi PRODUCT=$1 case "$PRODUCT" in VxFS) ;; VxVM) ;; *) error "Product must be either VxFS or VxVM"; ;; esac if [ "$PRODUCT" = "VxFS" ] then if [ 0 -ne $DEBUG ] then # # Just dump ${SWLIST} information for the kernel for debugging the script # ${SWLIST} -l fileset | grep VXFS-BASE-KRN fi # # The methods of detection below have proven insufficient. Just # hard-code the return of version 3.5 for HP11.11. # os=`uname -r` case "${os}" in "B.11.11") isver "3.5";; *) isver "3.5";; esac # # First, look for the VRTSvxfs package. # vxfs=`${SWLIST} -l fileset | grep '^[ ]*VRTSvxfs.VXFS-KRN' | sed 's/[ ]*VRTSvxfs.VXFS-KRN[ ][ ]*\([^ ][^ ]*\).*/\1/'` case "$vxfs" in "B.11.11") isver "3.3"; ;; 3.1* | 3.2* | 3.3* | 3.4* | 3.5*) isver "$vxfs"; ;; *) # # Next, look for JFS, which will appear on HP-UX 11.11. # vxfs=`${SWLIST} -l fileset | grep '^[ ]*JFS.VXFS-BASE-KRN' | sed 's/[ ]*JFS.VXFS-BASE-KRN[ ][ ]*\([^ ][^ ]*\).*/\1/'` case "$vxfs" in "B.11.11") isver "3.3"; ;; 3.1* | 3.2* | 3.3* | 3.4* | 3.5*) isver "$vxfs"; ;; *) # # Failing JFS, look for JournalFS. # vxfs=`${SWLIST} -l fileset | grep '^[ ]*JournalFS.VXFS-BASE-KRN' | sed 's/[ ]*JournalFS.VXFS-BASE-KRN[ ][ ]*\([^ ][^ ]*\).*/\1/'` case "$vxfs" in "B.11.11") isver "3.3"; ;; 3.1* | 3.2* | 3.3* | 3.4* | 3.5*) isver "$vxfs"; ;; *) error "No VxFS found"; ;; esac ;; esac ;; esac fi if [ "$PRODUCT" = "VxVM" ] then if [ 0 -ne $DEBUG ] then # # Just dump ${SWLIST} information for the kernel for debugging the script # ${SWLIST} -l product | grep -E 'VRTSvxvm|HPvxvm' fi # # First, figure out which package is installed, VRTSvxvm or HPvxvm. # Only the first "vxvm" product found is used. # package=`${SWLIST} -l product | grep -E 'VRTSvxvm|HPvxvm' | sed 's/^[ ]*\([A-Z]*vxvm\)[ ].*$/\1/p;q'` if [ 0 -ne $DEBUG ] then echo Package is $package fi # # Next, get the version number. If no appropriate package was found, exit with error. # case "$package" in HPvxvm) vxvm=`${SWLIST} -a revision -l product $package | grep '^[ ]*'$package | sed 's/^[ ]*'$package'[ ][ ]*B\.0\([0-9]\.[0-9]\)[0-9.]*.*$/\1/'` isver "$vxvm"; ;; VRTSvxvm) vxvm=`${SWLIST} -a revision -l product $package | grep '^[ ]*'$package | sed 's/^[ ]*'$package'[ ][ ]*\([0-9.][0-9.]*\).*$/\1/'` isver "$vxvm"; ;; *) error "No VxVM found"; ;; esac fi exit 0