#!/bin/sh
set -e
echo VMware ISO Signature Creator 2.0.0
echo ==================================
# Ensure we only use unmodified commands
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
# Find out what OS we're running under and set relevant path
# Currently supports:
# Darwin - Fusion on Mac OS X
# Linux - works with both hosted products e.g. Server 2.0 and ESX 4.0 Service Console
# VMkernel - work with ESXi 4.0
OS=`uname -s`
if [ "$OS" = 'Darwin' ]; then
VMPATH='/Library/Application Support/VMware Fusion/isoimages'
elif [ "$OS" = 'Linux' ]; then
VMPATH='/usr/lib/vmware/isoimages'
vmware -v
elif [ "$OS" = 'VMkernel' ]; then
VMPATH='/usr/lib/vmware/isoimages'
vmware -v
else
echo Unknown operating system "$OS"!
fi
echo Running on "$OS" and using "$VMPATH"
# See how we were called.
case "$1" in
--install)
echo Backing up files
mkdir -p "./backup"
cp "$VMPATH"/*.pub ./backup
cp "$VMPATH"/*.sig ./backup
# Check for darwin.iso as may not be present
if [ -f "$VMPATH"/darwin.iso ]; then
cp "$VMPATH"/darwin.iso ./backup
fi
cp darwin.iso "$VMPATH"
cp tools-key.pem "$VMPATH"
cp tools-key.pub "$VMPATH"
cd "$VMPATH"
echo Creating new SHA-1 digests
for A in *.iso
do
echo SHA-1 digest for "$A"
openssl dgst -sha1 -sign tools-key.pem < "$A" > "$A".sig 2> /dev/null
done
cd -
;;
--uninstall)
echo Restoring backup files
rm -f "$VMPATH"/*.sig
rm -f "$VMPATH"/*.pem
rm -f "$VMPATH"/*.pub
rm -f "$VMPATH"/darwin.iso
cp ./backup/*.pub "$VMPATH"
cp ./backup/*.sig "$VMPATH"
# Check for darwin.iso as may not be present
if [ -f "$VMPATH"/darwin.iso ]; then
cp ./backup/darwin.iso "$VMPATH"
fi
rm -rf ./backup
;;
*)
echo "Usage: $0 {--install|--uninstall}"
echo install - install darwin.iso and signatures
echo uninstall - restore original signatures
exit 1
esac
echo Finished!
评论0
最新资源