I've tried a few things to manually push out a script as a test from one of my primary machines to a test machine. I have a McAfee agent that I just obtained from McAfee, and I'm simply trying to remember what I did via terminal to push it out from my primary machine. Well, I finally figured it out. But now I want to execute the script on the test machine from the primary machine, so that I can install it.
What I'm trying to do is just create a script or use a command that will allow me to push out my shell script (which is on my desktop), out to the test machine, then execute the shell script on the test machine to install itself.
- Let me add that, I've tried on a few occasions to run: chmod +x install.sh, and I never got passed an error that stated: chmod: script1.sh: No such file or directory
what am I doing wrong here?
Any help would be appreciated.
Sure, and thanks for the assistance. I'll insert a little of the code here:
#!/bin/sh
###getopt for command line arguments.
###Handle the following
### -i install, rpm ivh
### -u upgrade, rpm Uvh )
### -b upgrade but no server info
### -c cloud config path (option for internal usage in bootstrap)
### -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=104088
cloud=
usage()
{
echo "Usage: $command [-i|-u|-b|-h ]"
echo "-i : fresh install "
echo "-u : upgrade install"
echo "-b :Upgrade Agent only , no server info will be updated"
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
updateserverinfo="yes"
##First get the options
while getopts e:ic:ubh: opt
do case "$opt" in
i) install="yes";;
c) cloud="$OPTARG";;
u) upgrade="yes";;
b) upgrade="yes";;
h) usage
exit 0;;
[?]) usage
exit 1;;
esac
value=`expr $OPTIND - 1`
done
shift $value
returncode=0
keydata_dir=/Library/McAfee/cma/scratch/keydata
###Cannot have install and upgrade together
if [ ! -z "$install" ] && [ ! -z "$upgrade" ];then
echo You cannot specify install and upgrade at the same time
usage
exit 1
fi
##Cannot have "neither install, nor upgrade"
if [ -z "$install" ] && [ -z "$upgrade" ];then
echo "Neither install nor upgrade has been specified in the options"
usage
exit 1
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
if [ ! -z "$cloud" ];then
#For Agent installation through bootstrap.
echo "Agent installation through bootstrap."
if [ ! -d "$cloud" ];then
echo "Cloud config path doesn't exist($cloud)."
exit 1
else
directory="$cloud"
temp_directory="$cloud"
fi
else
#For On-Prem install
temp_directory=`mktemp -d mfeXXXXXX`
if [ -f /etc/cma.d/bootstrap.xml ];then
rm -rf /etc/cma.d/bootstrap.xml
fi
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
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
if [ -z "$cloud" ];then
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
block_size=512
nblocks=`expr $unzip_exe_size / $block_size`
remainder=`expr $unzip_exe_size % $block_size`
if [ 0 != $remainder ];then
nblocks=`expr $nblocks + 1`
fi
dd if="$temp_directory"/payload of="$temp_directory"/unz bs=$block_size count=$nblocks
dd if="$temp_directory"/payload of="$temp_directory"/package.zip bs=$block_size skip=$nblocks
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
fi
if [ -n "$install" ] || [ -n "$upgrade" ];then
if [ "$updateserverinfo" = "yes" ] ; 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"
cp -f "$directory"/sr2048pubkey.bin "$keydata_dir"
cp -f "$directory"/req2048seckey.bin "$keydata_dir"
cp -f "$directory"/agentfipsmode "$keydata_dir"/agentfipsmode
cp -f "$directory"/RepoKeys.ini "$keydata_dir"/RepoKeys.ini
if [ ! -f "$keydata_dir"/SiteList.xml ] || [ ! -f "$keydata_dir"/srpubkey.bin ] || [ ! -f "$keydata_dir"/reqseckey.bin ] || [ ! -f "$keydata_dir"/sr2048pubkey.bin ] || [ ! -f "$keydata_dir"/req2048seckey.bin ];then
echo "Could not find key data files. Installation cannot continue"
rm -rf "$keydata_dir"
exit 1
fi
fi
fi
hdiutil attach -nobrowse "$directory/MFEcma.dmg"
fi
####Now do the actual install/ upgrade stuff
####The actual operations for copying the reqseckey and other files should already be there in the installer
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
flag=1
pltvrsn=`/usr/bin/sw_vers | grep ProductVersion | cut -d: -f2`
majvrsn=`echo $pltvrsn | cut -d. -f1`
minvrsn=`echo $pltvrsn | cut -d. -f2`
if [ -f /Library/McAfee/cma/bin/msaconfig ];then
flag=0;
fi
if (($majvrsn>=10 && $minvrsn>=6 && $flag)); then
sudo /usr/sbin/pkgutil --forget comp.nai.cmamac > /dev/null 2>&1
fi
sudo /usr/sbin/installer -pkg cma.pkg -target "/"
returncode=$?
sleep 5
cd "$mypwd"
hdiutil detach /Volumes/MFECMA
rm -rf /etc/mainstall.config
else
hdiutil detach /Volumes/MFECMA
fi
if [ -z "$cloud" ];then
rm -rf "$temp_directory"
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
Figured out what needed to happen, and this is the solution below--
Target the area you want to place the script in and create a directory for the script to live:
mkdir -p /Library/Application\ Support/McAfee
Next, install the McAfee script from wherever it resides
Make the file into an executable:
chmod +x /Library/Application\ Support/McAffee/install.sh
Activate the script:
/Library/Application\ Support/install.sh -i
Thank you for sharing what you have learned...
Shouldn't the code to activate your script include the McAffee
component in the pathname of your executable?:
/Library/Application\ Support/McAffee/install.sh -i