#
# install - installer for the DTraceToolkit
#
# This is a fairly simple script, most of it is error checking.
# All the script does is copy the DTraceToolkit files to another directory,
# with various checks. The user could have copied the files themselves, this
# script doesn't do anything special to them. It's really here in case
# people extrace the toolkit and go looking for an installer.
#
# 15-May-2005 Brendan Gregg Created this.
### Ensure we know where we are,
dir=${0%/*}
cd $dir
### Print welcome,
print "DTraceToolkit Installation\n---------------------------"
print "\nhit Ctrl-C any time you wish to quit.\n\n"
### Fetch location,
print ""
### Sanity check,
print "ERROR1: Location \"$loc\" is ambiguous.\n."
print ".\tSorry!\n"
exit 1
fi
### Evilness check,
print "ERROR2: Sorry, location \"$loc\" contains bad characters.\n."
print ".\tSorry!\n"
exit 2
fi
### Process location,
### Check parent dir exists,
if [[ ! -d "$basename" ]]; then
print "ERROR3: Parent directory \"$basename\" does not exist!\n."
print ".\tI'm not sure what you want me to do here, if you were"
print ".\tserious about the above parent directory - then run"
print ".\ta \"mkdir -p $basename\" first, then rerun this script.\n."
print ".\tSorry!\n"
exit 3
fi
### Check parent dir perms,
if [[ ! -w "$basename" ]]; then
print "ERROR4: Can't write to parent directory \"$basename\"!\n."
print ".\tSince I can't write to this directory, I can't install the"
print ".\tDTraceToolkit. You are currently logged in as,\n."
print ".\n.\tand the directory has permissions,\n."
print ".\n.\tMaybe you need to run \"su - $owner\" first?\n."
print ".\tSorry!\n"
exit 4
fi
### Check if toolkit is already installed,
if [[ -d "$loc" ]]; then
print "Warning: Possible old version of the DTraceToolkit found."
print "\tThis will DELETE the files in $loc, then install the toolkit."
if [[ ! -f "$loc/Version" ]]; then
print "\nWARNING: $loc doesn't look like an old DTraceToolkit!"
fi
print -n "\nContinue (will run \"rm -rf $loc\"). Are you sure (y/N)?: "
if [[ "$ans" != "y" ]]; then
print "\nExiting..."
exit 5
fi
else
fi
fi
### Make new toolkit dir,
print "\nMaking directory \"$loc\"...\n"
else
fi
print "ERROR6: Creation of \"$loc\" failed.\n."
print ".\tCheck directory location and try again.\n."
print ".\tSorry!\n"
exit 6
fi
### Copy files across,
print "\nCopying DTraceToolkit files...\n"
else
fi
error=$?
print "ERROR7: Failure during copy.\n."
print ".\ttry again.\n."
print ".\tSorry!\n"
exit 7
fi
### Delete installer,
else
fi
### Finished,
print "\nFinished.\n"