Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ###############################################################################
- ## This program is free software; you can redistribute it and/or modify it
- ## under the terms and conditions of the GNU General Public License,
- ## version 2, as published by the Free Software Foundation.
- ##
- ## This program is distributed in the hope it will be useful, but WITHOUT
- ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- ## more details.
- ##
- ## You should have received a copy of the GNU General Public License along with
- ## this program; if not, write to the Free Software Foundation, Inc.,
- ## 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- ##
- ## The full GNU General Public License is included in this distribution in
- ## the file called "COPYING".
- ##
- ## Contact Information:
- ## Robert Graham <robertgraham1906@gmail.com>
- ###############################################################################
- ###
- ### @brief
- ### VMware ESXi 5.0+ VIB Creation Tool (for Drivers)
- ###############################################################################
- LOG_FILE=$(dirname $(readlink -f $0))/log.txt
- PAYLOAD_FOLDER=$(dirname $(readlink -f $0))/payload
- OUTPUT_DRIVER_LOCATION=$(dirname $(readlink -f $0))/stage/usr/lib/vmware/vmkmod/
- DRIVER_NAME="sel3390e4"
- # Verify Root
- if [ "$(id -u)" -ne "0" ]
- then
- echo "ERROR: This should be run as root"
- exit 1
- fi
- # Verify input params
- if [ -z "$2" ] || [ -n "$3" ] || [ ! -n "$(echo $2 | grep "[0-9]\.[0-9]")" ]
- then
- echo "ERROR: incorrect input params\n"
- echo "$(basename $0) <path_to_driver_file_1> <version_number>"
- exit 1
- else
- DRIVER_FILE_1=$1
- VERSION=$2
- VIB_NAME="$DRIVER_NAME-5.0.0-$VERSION.vib"
- OUTPUT_FOLDER=$(dirname $(readlink -f $0))/bin/release/$VERSION
- fi
- # Verify descriptor.xml file exists
- if [ ! -f descriptor.xml ]
- then
- echo "ERROR: missing descriptor.xml"
- exit 1
- fi
- if [ ! -d payload ]
- then
- echo "ERROR: missing payload directory"
- exit 1
- fi
- # Remove output folder
- rm -rf $OUTPUT_FOLDER
- # Create output folder
- mkdir -p $OUTPUT_FOLDER
- # Create stage folder
- mkdir stage
- # Copy Everything in payload folder to stage
- cp -rf $PAYLOAD_FOLDER/* stage
- # Copy Driver Files
- cp -f $DRIVER_FILE_1 $OUTPUT_DRIVER_LOCATION >> $LOG_FILE ||
- { echo "ERROR: unable to copy $DRIVER_FILE_1" ; exit 1 ; }
- # Create gzipped file
- cd stage || { exit 1 ; }
- tar czvf ../$DRIVER_NAME.tgz * >> $LOG_FILE ||
- { echo "ERROR: unable to create .gz from stage/*" ; exit 1 ; }
- cd ../
- # Create empty signature file
- touch sig.pkcs7
- mkdir temp
- cp -f descriptor.xml temp/
- sed -i "s/\(<version>[0-9]\.[0-9]\.[0-9]-\)\([0-9]\.[0-9]\)\(<\/version>\)/\1$VERSION\3/g" temp/descriptor.xml
- # Create vib file (ORDER IS IMPORTANT!)
- # descriptor.xml sig.pkcs7 tar_file
- ar -r $VIB_NAME temp/descriptor.xml sig.pkcs7 $DRIVER_NAME.tgz
- # Move to output folder
- mv $VIB_NAME $OUTPUT_FOLDER
- # Remove stage files
- rm -f sig.pkcs7
- rm -f $DRIVER_NAME.tgz
- rm -rf temp/
- rm -rf stage/
- echo "Successfully created $OUTPUT_FOLDER/$VIB_NAME"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement