#!/bin/sh Get_Product_Type() { if [ -f $INSTALL_PATH/start_arcims ]; then PRODTYPE="arcims" PRODSTRING="ArcIMS" elif [ -f $INSTALL_PATH/../servercore/.Server/serverobjectcontainer ] || [ -f $INSTALL_PATH/../servercore/.Server/serverobjectmanager ]; then PRODTYPE="arcgisserver" PRODSTRING="ArcGIS Server" echo "The script will also prompt for the root password in order to modify" echo "the file 'arcgis/.Setup/UninstallArcGISServer/installvariables.properties'" echo "owned by superuser." echo "" elif [ -f $INSTALL_PATH/init_engine.sh ]; then PRODTYPE="arcengine" PRODSTRING="ArcGIS Engine or ArcReader" else echo "Script is being run from an invalid location. " exit 1 fi #Check for ArcIMS installations that do not have ArcMap server if [ "$PRODTYPE" = "arcims" ] && [ ! -f $INSTALL_PATH/../etc/aimsamsrv.cfg ]; then echo "" echo "ArcMap Server is not installed on this machine. This script should only " echo "be run on ArcIMS installations that have ArcMap installed." echo "Terminating script execution.." echo "" exit 0 fi echo "" echo "Identified installed product as $PRODSTRING.." if [ "$PRODTYPE" = "arcgisserver" ] || [ "$PRODTYPE" = "arcims" ]; then echo "" echo "The $PRODSTRING processes must be stopped before running this script." echo "Continue? (y/n) [y]:" read ans if [ "$ans" = "N" ] || [ "$ans" = "n" ] ;then exit 0 fi fi } Init_Checks() { cd $INSTALL_PATH INSTALL_PATH=`pwd`; export INSTALL_PATH #echo "Path: $INSTALL_PATH" if [ "$PRODTYPE" = "arcengine" ]; then echo "Checking value of DISPLAY variable" if [ "x$DISPLAY" = "x" ]; then echo "Invalid DISPLAY. Please set DISPLAY variable." echo " e.g. DISPLAY=machine1:0; export DISPLAY " exit 0 fi fi } CheckXvfb() { if [ "$PRODTYPE" = "arcengine" ]; then return fi process_list="" if [ "$PRODTYPE" = "arcims" ]; then if [ "`uname`" = "Linux" ]; then process_list=`ps -efww | grep "$USER " | grep Xvfb | grep "7 -screen 0" | grep -v grep | awk '{print $2}'` else process_list=`ps -ef | grep "$USER " | grep Xvfb | grep "7 -screen 0" | grep -v grep | awk '{print $2}'` fi else portfl=$INSTALL_PATH/../servercore/.Server/xvfb.port if [ -f $portfl ]; then XVFBPORT=`cat $INSTALL_PATH/../servercore/.Server/xvfb.port` fi if [ "x$XVFBPORT" != "x" ]; then if [ "`uname`" = "Linux" ]; then process_list=`ps -efww | grep "$LOGNAME " | grep Xvfb | grep "$XVFBPORT -screen 0" | grep -v grep | awk '{print $2}'` else process_list=`ps -ef | grep "$LOGNAME " | grep Xsun | grep ":$XVFBPORT " | grep -v grep | awk '{print $2}'` fi fi fi if [ "x$process_list" = "x" ]; then echo "Unable to start Virtual X Server.." cat /tmp/xvfb.log; rm -f /tmp/xvfb.log exit 1 fi rm -f /tmp/xvfb.log } Initialize_Env() { echo "" echo "Initializing environment - " if [ "$PRODTYPE" = "arcengine" ] ; then . $INSTALL_PATH/init_engine.sh mwadm start > /dev/null 2>&1 elif [ "$PRODTYPE" = "arcims" ] ; then . $INSTALL_PATH/../../init_engine.sh $INSTALL_PATH/start_virtual_display_server > /tmp/xvfb.log 2>&1 DISPLAY=localhost:7.0; export DISPLAY mwadm start > /dev/null 2>&1 else . $INSTALL_PATH/../servercore/.Server/init_server.sh mwadm start > /dev/null 2>&1 . $INSTALL_PATH/../servercore/.Server/init_Xvfb.sh > /tmp/xvfb.log 2>&1 StartXvfb >> /tmp/xvfb.log 2>&1 fi CheckXvfb is_mw_running=`mwadm status | grep "Core Services" | cut -f 2 -d : | cut -f 2 -d ' '` if [ "$is_mw_running" != "running" ] || [ "x$DISPLAY" = "x" ]; then echo "Unable to initialize environment. Exiting.." exit 1 fi } RegisterBinaries() { PathToBin=$1 IsError=0 regerror=0 if [ ! -f $PathToBin/mapserver.dll ]; then echo "Error: Could not locate folder for binaries" ERROR_OCCURED=1 fi echo "The following steps may take a little while.." cd $PathToBin LOGFILE=$INSTALL_PATH/SP3config.log echo "Unregistering binaries" > $LOGFILE echo "Unregistering libraries.." ./regall.exe -u *.dll >> $LOGFILE 2>&1 echo "Unregistering controls.." find . -name "*.ocx" -exec regsvr32 -u -c {} \; >> $LOGFILE 2>&1 if [ -d $PathToBin/../com ]; then cd $PathToBin/../com echo "Unregistering type libraries.." $PathToBin/regall.exe -u *.olb >> $LOGFILE 2>&1 fi echo "" >> $LOGFILE echo "" >> $LOGFILE echo "Re-registering binaries" >> $LOGFILE 2>&1 cd $PathToBin echo "Registering libraries.." ./regall.exe *.dll >> $LOGFILE 2>&1 if [ "$?" != "0" ]; then regerror=1 fi echo "Registering controls.." find . -name "*.ocx" -exec regsvr32 -c {} \; >> $LOGFILE 2>&1 if [ "$?" != "0" ]; then regerror=1 fi if [ -d $PathToBin/../com ]; then cd $PathToBin/../com echo "Registering type libraries.." $PathToBin/regall.exe *.olb >> $LOGFILE 2>&1 if [ "$?" != "0" ]; then regerror=1 fi fi echo "Applying changes to Core services' registry" mwregfile=$PathToBin/mwsystem1.reg >> $LOGFILE 2>&1 sed '/\[HKEY_LOCAL_MACHINE\\Software\\Mainsoft\\Authentication\]/,/"Port"=dword:0000029B/d' $MWHOME/system/mwsystem.reg > $mwregfile if [ -f $mwregfile ]; then regedit -c $mwregfile >> $LOGFILE 2>&1 if [ "$?" != "0" ]; then regerror=1 fi rm -f $mwregfile fi if [ "$regerror" != "0" ]; then echo "" echo "ERROR: Registration of binaries did not go through correctly!!" ERROR_OCCURED=1 fi echo "" return } Run() { envcheck=`which regsvr32 | grep "no regsvr32 "` if [ "x$envcheck" != "x" ]; then echo "Environment could not be initialized properly. The $PRODSTRING installation may be corrupted.." exit 1 fi echo "" if [ "$PRODTYPE" = "arcgisserver" ]; then RegisterBinaries $INSTALL_PATH/../bin echo "" echo "Running the ArcGISServer92_UninstallPatcher.sh script - " /bin/sh -c ". $INSTALL_PATH/ArcGISServer92_UninstallPatcher.sh" if [ "$?" != "0" ]; then echo "" echo "ERROR: Script was not executed successfully!!" ERROR_OCCURED=1 fi echo "" echo "Running the ArcGISServer92_PasswordCleaner.sh script - " echo "This requires superuser privileges. Please check KB article 32856 at" echo "http://support.esri.com for details." echo "Do you want to continue running this script? (y/n) [y]:" read ans1 if [ "$ans1" != "n" ] && [ "$ans1" != "N" ]; then echo "Please enter password for root:" su - root -c "/bin/sh $INSTALL_PATH/ArcGISServer92_PasswordCleaner.sh" fi elif [ "$PRODTYPE" = "arcims" ]; then RegisterBinaries $INSTALL_PATH/../../bin else RegisterBinaries $INSTALL_PATH/bin fi } WrapUp() { echo "" if [ "$PRODTYPE" = "arcgisserver" ]; then echo "Shutting down core services" mwadm stop > /dev/null 2>&1 echo "Shutting down Xvfb" StopXvfb > /dev/null 2>&1 else if [ "$PRODTYPE" = "arcims" ]; then echo "Shutting down virtual display server" $INSTALL_PATH/stop_virtual_display_server fi mwadm stop > /dev/null 2>&1 fi if [ "$ERROR_OCCURED" = "0" ]; then echo "" echo "Script completed successfully." echo "" else echo "" echo "Errors occured during execution of script!" echo "" fi } PRODTYPE="" PRODSTRING="" INSTALL_PATH=`dirname $0` ERROR_OCCURED=0 export INSTALL_PATH echo "This script must be run as the owner of the ArcGIS/ArcIMS/ArcReader/ArcEngine product. " Get_Product_Type Init_Checks Initialize_Env Run WrapUp