home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
autolist.mesd.k12.or.us
/
autolist.mesd.k12.or.us.zip
/
autolist.mesd.k12.or.us
/
antivirus
/
mcafee-macosx-old.dmg
/
mcafee-macosx
/
cma-install.sh
< prev
next >
Wrap
Linux/UNIX/POSIX Shell Script
|
2009-01-14
|
7MB
|
24,535 lines
#!/bin/sh
###getopt for command line arguments.
###Handle the following
### -i install, rpm ivh
### -u upgrade, rpm Uvh )
### -e extract only , must have directory
### -h help
PATH=/usr/bin:/bin
umask 022
NATIVE_INSTALLER_FILE=MFEcma.dmg #NATIVE_INSTALL_PACKAGE_NAME_HERE
command=$0
install=
upgrade=
extract=
directory=
unzip_exe_size=110420
usage()
{
echo "Usage: $command [-i|-u|-h ]"
echo "-i : fresh install"
echo "-u : upgrade install"
echo "-h : show this help"
echo ""
}
user=`id | cut -d'=' -f2 | cut -d\( -f1`
if [ $user -ne 0 ]; then
echo "This package needs root authentication to install."
exit 1
fi
###BZ 392336 Bail out if NWA exists
if [ -d /Library/NETAepoagt ];then
echo "Detected presence of previous agent in /Library/NETAepoagt. Installation cannot continue."
exit 1
fi
###Validation: No args, go away
if [ $# -eq 0 ]; then
usage
exit 1
fi
##First get the options
while getopts e:iuh opt
do case "$opt" in
i) install="yes";;
u) upgrade="yes";;
e) extract="yes"
directory=$OPTARG
;;
h) usage
exit 0;;
[?]) usage
exit 1;;
esac
value=`expr $OPTIND - 1`
done
shift $value
returncode=0
keydata_dir=/Library/McAfee/cma/keydata
###Cannot have install and upgrade together
if [ ! -z "$install" ] && [ ! -z "$upgrade" ];then
echo You cannot specify install and upgrade at the same time
fi
###Cannot have both install and extract
if [ ! -z "$extract" ] ; then
if [ ! -z "$install" ] || [ ! -z "$upgrade" ];then
echo cannot do extract and install/upgrade at the same time
exit 1
fi
fi
if [ -e /Volumes/MFECMA ];then
echo /Volumes/MFECMA already exists.The agent disk image cannot be mounted
echo Please move or rename /Volumes/MFECMA and then rerun this setup
exit 1
fi
###Okay, now that everything has been checked, its time to get going
##First we need to extract everything to a temp location,
##and then unzip it to the final destination
temp_directory=`mktemp -d mfeXXXXXX`
if [ -z "$directory" ];then
directory=$temp_directory
fi
if [ -f "$directory" ];then
echo Output destination specified is a file which laready exists. Cannot overwrite
rm -rf "$temp_directory"
exit 1
fi
if [ ! -e "$directory" ];then
mkdir -p "$directory"
fi
if [ -e "$temp_directory" ] ;then
###installer has checks for disk space, and so I wont bother about it.
###unzip will also complain is there isnt enough space for the extracted file
###So, all I care about is to have enough space for the zip itself.
###Since the zip is appended to this file itself, it would never be larger that
###this sfx itself.So havin enough space in $temp_dir to hold the sfx is good enough
required_space=`stat -f %z $command`
required_space=`expr $required_space \* 2`
echo space required to copy archive is $required_space bytes
available_space=`df -k $temp_directory | tail -n -1 | awk '{if ( $4 ~ /%/) { print $3 } else { print $4 } }'`
#convert the kb to bytes
available_space=`expr $available_space \* 1024`
echo space available at $temp_directory is $available_space bytes
if [ $required_space -gt $available_space ];then
echo Not enough space to extract contents
rm -rf $temp_directory
exit 1
fi
echo "extracting archive to $directory... please wait"
SKIP=`awk '/^__ARCHIVE_FOLLOWS__/ { print NR + 1; exit 0; }' $0`
# take the archive portion of this file and pipe it to unzip
tail +$SKIP "$command" > "$temp_directory"/payload
dd if="$temp_directory"/payload of="$temp_directory"/unz bs=1 count=$unzip_exe_size
dd if="$temp_directory"/payload of="$temp_directory"/package.zip bs=1 skip=$unzip_exe_size
chmod +x "$temp_directory"/unz
# /bin/sh "$temp_directory"/unz -j -o $"$temp_directory"/package.zip -d "$directory"
unzip -j -o $"$temp_directory"/package.zip -d "$directory"
rm -rf "$temp_directory"/package.zip
rm -rf "$temp_directory"/unz
if [ -n "$install" ] || [ -n "$upgrade" ];then
mkdir -p "$keydata_dir"
returncode=$?
if [ $returncode -ne 0 ] ; then
echo "Failed to create keydata directory.exiting"
exit 1
fi
cp -f "$directory"/sitelist.xml "$keydata_dir"/SiteList.xml
cp -f "$directory"/srpubkey.bin "$keydata_dir"
cp -f "$directory"/reqseckey.bin "$keydata_dir"
if [ ! -f "$keydata_dir"/SiteList.xml ] || [ ! -f "$keydata_dir"/srpubkey.bin ] || [ ! -f "$keydata_dir"/reqseckey.bin ];then
echo "Could not find key data files. Installation cannot continue"
rm -rf "$keydata_dir"
exit 1
fi
fi
hdiutil attach "$directory/MFEcma.dmg"
rm -rf "$temp_directory"
fi
####Now do the actual install/ upgrade stuff
####The actual operations for copying the reqseckey and other files should already be there in the rpm
returncode=0
if [ -z "$extract" ];then
mypwd=`pwd`
cd "/Volumes/MFECMA"
echo "IsLegacyEPO:N" > /etc/mainstall.config
echo "ConfigDirPath:/Volumes/MFECMA" >> /etc/mainstall.config
echo "StartService:Y" >> /etc/mainstall.config
sudo /usr/sbin/installer -pkg cma.pkg -target "/" >>/tmp/agent.log 2>&1
returncode=$?
sleep 5
cd "$mypwd"
hdiutil detach /Volumes/MFECMA
rm -rf /etc/mainstall.config
else
hdiutil detach /Volumes/MFECMA
fi
if [ $returncode -ne 0 ];then
rm -rf "$keydata_dir"
exit 1
fi
if [ -d "$keydata_dir" ] ; then
rm -rf "$keydata_dir"
fi
exit 0
##DO NOT PUT ANYTHING AFTER __ARCHIVE_FOLLOWS__ UNDER ANY CIRCUMSTANCE (NOT EVEN WHITESPACE). YOU SHALL BE HANGED IF YOU DO
###SUCCESSFUL extraction from the zip depends on it
__ARCHIVE_FOLLOWS__
╬·φ■ ` à 8 __PAGEZERO ╨ __TEXT p p __text __TEXT \$ π \ Ç __picsymbol_stub__TEXT ?: ?* Ç __symbol_stub __TEXT ?: ?* Ç __cstring __TEXT @: á @* __textcoal_nt __TEXT αB α2 Ç __const __TEXT C °<