2004-09-08 09:01:52 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
2004-10-07 11:22:21 -05:00
|
|
|
error()
|
|
|
|
{
|
|
|
|
echo
|
|
|
|
printf "ERROR:\t$1\n"
|
|
|
|
echo
|
|
|
|
echo "User Mode Installation script for developer and knowledgeable early access tester"
|
|
|
|
echo
|
|
|
|
echo "This installation method is not intended for use in a production environment!"
|
|
|
|
echo "Using this script is unsupported and completely at your own risk"
|
|
|
|
echo
|
|
|
|
echo "Usage:" $0 "<pkg-source-dir> <inst-destination-dir> [-l]"
|
|
|
|
echo " <pkg-source-dir>: directory *only* containing the Solaris pkg packages to be installed"
|
|
|
|
echo " <inst-destination-dir>: absolute path to where the office and the pkg database will get installed"
|
|
|
|
echo " -l: optional parameter to create a link \"soffice\" in $HOME"
|
|
|
|
echo
|
|
|
|
exit 2
|
|
|
|
}
|
|
|
|
|
|
|
|
cannot_install()
|
|
|
|
{
|
|
|
|
echo
|
|
|
|
printf "ERROR:\tCannot install to directory $MY_ROOT\n"
|
|
|
|
printf "\t$1\n"
|
|
|
|
printf "\tPlease check/cleanup $MY_ROOT or choose a different directory\n"
|
|
|
|
echo
|
|
|
|
exit 2
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# expect either two or three arguments
|
|
|
|
#
|
2004-09-08 09:01:52 -05:00
|
|
|
|
|
|
|
if [ \( $# -ne 2 -a $# -ne 3 \) -o -z "$1" -o -z "$2" ]
|
|
|
|
then
|
2004-10-07 11:22:21 -05:00
|
|
|
error "Wrong number of arguments"
|
2004-09-08 09:01:52 -05:00
|
|
|
fi
|
|
|
|
|
2004-10-07 11:22:21 -05:00
|
|
|
#
|
|
|
|
# this script is for userland not for root
|
|
|
|
#
|
|
|
|
|
|
|
|
if [ $UID -eq 0 ]
|
|
|
|
then
|
|
|
|
error "This script is for installation without administrative rights only\n\tPlease use pkgadd to install as root"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Evaluate command line arguments
|
|
|
|
#
|
|
|
|
|
2004-09-08 09:01:52 -05:00
|
|
|
PACKAGE_PATH=$1
|
|
|
|
MY_ROOT=$2
|
|
|
|
|
|
|
|
LINK="nolink"
|
|
|
|
if [ $# -eq 3 ]
|
|
|
|
then
|
|
|
|
LINK=$3
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d $PACKAGE_PATH ]
|
|
|
|
then
|
2004-10-07 11:22:21 -05:00
|
|
|
error "Directory $PACKAGE_PATH does not exist"
|
2004-09-08 09:01:52 -05:00
|
|
|
fi
|
|
|
|
|
2004-10-07 11:22:21 -05:00
|
|
|
if [ ! "${MY_ROOT:0:1}" = "/" ]
|
|
|
|
then
|
|
|
|
error "Invalid installation directory $MY_ROOT, has to be an absolute path"
|
|
|
|
fi
|
2004-09-08 09:01:52 -05:00
|
|
|
|
2004-10-07 11:22:21 -05:00
|
|
|
#
|
|
|
|
# the admin file is expected to be in the same directory as this script
|
|
|
|
#
|
|
|
|
|
|
|
|
DIRECTORY=`dirname $0`
|
2004-09-08 09:01:52 -05:00
|
|
|
ADMINFILE=$DIRECTORY/admin
|
2004-10-07 11:22:21 -05:00
|
|
|
if [ ! -r $ADMINFILE ]
|
|
|
|
then
|
|
|
|
error "Admin file $ADMINFILE does not exist or is not readable"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Check and get the list of packages to install
|
|
|
|
#
|
2004-09-08 09:01:52 -05:00
|
|
|
|
2004-10-07 11:22:21 -05:00
|
|
|
COREPKG=`find $PACKAGE_PATH/* -type d -prune -name "*-core*" -print`
|
|
|
|
PKGLIST=`find $PACKAGE_PATH/* -type d -prune ! -name "*adabas*" ! -name "*j3*" ! -name "*-gnome*" ! -name "*-cde*" ! -name "*-core*" -print`
|
2004-09-08 09:01:52 -05:00
|
|
|
|
|
|
|
if [ -z "$COREPKG" ]
|
|
|
|
then
|
2004-10-07 11:22:21 -05:00
|
|
|
error "No core package found in directory $PACKAGE_PATH"
|
2004-09-08 09:01:52 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Packages found:"
|
|
|
|
for i in $COREPKG $PKGLIST; do
|
|
|
|
echo `basename $i`
|
|
|
|
done
|
|
|
|
|
2004-10-07 11:22:21 -05:00
|
|
|
#
|
|
|
|
# Check/Create installation directory
|
|
|
|
#
|
2004-09-08 09:01:52 -05:00
|
|
|
|
|
|
|
CORENAME=`basename $COREPKG`
|
2004-10-07 11:22:21 -05:00
|
|
|
INSTALLDIR=$MY_ROOT`pkgparam -d $PACKAGE_PATH $CORENAME BASEDIR`
|
2004-09-08 09:01:52 -05:00
|
|
|
|
2004-10-07 11:22:21 -05:00
|
|
|
# We expect that $INSTALLDIR does not exist, however if it is empty we ignore it
|
|
|
|
if [ -d $INSTALLDIR ]
|
|
|
|
then
|
|
|
|
# if it is not empty we cannot rm it (might be a permission problem as well)
|
|
|
|
rmdir $INSTALLDIR
|
|
|
|
fi
|
|
|
|
if [ -d $INSTALLDIR ]
|
2004-09-08 09:01:52 -05:00
|
|
|
then
|
2004-10-07 11:22:21 -05:00
|
|
|
cannot_install "Directory $INSTALLDIR exists and is not empty or cannot be removed"
|
2004-09-08 09:01:52 -05:00
|
|
|
fi
|
|
|
|
|
2004-10-07 11:22:21 -05:00
|
|
|
if [ -d $MY_ROOT/var/sadm ]
|
|
|
|
then
|
|
|
|
cannot_install "pkg database does already exist $MY_ROOT/var/sadm"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Create the installation directory (otherwise the user would be asked)
|
|
|
|
mkdir -p $INSTALLDIR
|
|
|
|
if [ ! -d $INSTALLDIR ]
|
|
|
|
then
|
|
|
|
cannot_install "Unable to create directory $INSTALLDIR"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# the tail of the script contains a shared object for overloading the getuid() call
|
|
|
|
#
|
|
|
|
|
2004-11-18 01:19:48 -06:00
|
|
|
GETUID_SO=/tmp/getuid.so.$$
|
2004-10-07 11:22:21 -05:00
|
|
|
linenum=???
|
|
|
|
tail +$linenum $0 > $GETUID_SO
|
|
|
|
if [ ! -r $GETUID_SO ]
|
|
|
|
then
|
|
|
|
error "Cannot create getuid wrapper library $GETUID_SO"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Perform the installation
|
|
|
|
#
|
|
|
|
|
2004-09-08 09:01:52 -05:00
|
|
|
echo "####################################################################"
|
2004-10-07 11:22:21 -05:00
|
|
|
echo "# Installation of the found packages #"
|
2004-09-08 09:01:52 -05:00
|
|
|
echo "####################################################################"
|
|
|
|
echo
|
|
|
|
echo "Path to the packages : " $PACKAGE_PATH
|
|
|
|
echo "Path to the installation : " $MY_ROOT
|
|
|
|
|
2004-10-07 11:22:21 -05:00
|
|
|
export LD_PRELOAD=$GETUID_SO
|
2004-09-08 09:01:52 -05:00
|
|
|
|
|
|
|
for i in $COREPKG $PKGLIST; do
|
|
|
|
echo /usr/sbin/pkgadd -a $ADMINFILE -d $PACKAGE_PATH -R $MY_ROOT `basename $i`
|
|
|
|
/usr/sbin/pkgadd -a $ADMINFILE -d $PACKAGE_PATH -R $MY_ROOT `basename $i`
|
|
|
|
done
|
|
|
|
|
2004-10-07 11:22:21 -05:00
|
|
|
export -n LD_PRELOAD
|
|
|
|
rm -f $GETUID_SO
|
|
|
|
|
|
|
|
#
|
|
|
|
# Create a link into the users home directory
|
|
|
|
#
|
2004-09-08 09:01:52 -05:00
|
|
|
|
2004-10-07 11:22:21 -05:00
|
|
|
if [ "$LINK" = "-l" ]
|
2004-09-08 09:01:52 -05:00
|
|
|
then
|
|
|
|
echo
|
2004-10-07 11:22:21 -05:00
|
|
|
echo "Creating link from $INSTALLDIR/program/soffice to $HOME/soffice"
|
2004-09-08 09:01:52 -05:00
|
|
|
rm -f $HOME/soffice
|
2004-10-07 11:22:21 -05:00
|
|
|
ln -s $INSTALLDIR/program/soffice $HOME/soffice
|
2004-09-08 09:01:52 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Installation done ..."
|
|
|
|
|
|
|
|
exit 0
|