home *** CD-ROM | disk | FTP | other *** search
/ ftp.rsa.com / 2014.05.ftp.rsa.com.tar / ftp.rsa.com / pub / agents / WebAgent.tar / install next >
Text File  |  2002-11-15  |  22KB  |  796 lines

  1. #!/bin/sh 
  2. #
  3. # Installation script for the ACE/Agent for Web Servers Plugin.
  4. #
  5. #
  6. #********************************************************************************
  7. #* COPYRIGHT (C) 2001  by RSA Security Inc.
  8. #*    ---ALL RIGHTS RESERVED---
  9. #********************************************************************************
  10. #
  11.  
  12. ############################################################
  13. # Set default values and commands for the shell script.
  14. ############################################################
  15. UNAME=`uname`
  16. UNAMER=`uname -r`
  17. HOSTNAME=`hostname`
  18. WEBSERVER="Apache"
  19.  
  20. HERE=`dirname $0` 
  21. THEPWD=`/bin/pwd`
  22. if [ "$HERE" = "." ]; then
  23.     HERE="$THEPWD"
  24. else
  25. #if $HERE isn't absolute path add `pwd` to it
  26.  
  27.     cd $HERE
  28.     HERE=`/bin/pwd`
  29.     cd $THEPWD
  30. fi
  31.  
  32. #suji needs to change
  33. ########################
  34. ########################
  35. APACHE_DOCS=""
  36. APACHE_CONFIG=""
  37. APACHE_EXEC=""
  38. CONF_FILE=""
  39. WEB_AGENT="/tmp/toto"
  40. WEB_AGENT_DIR="rsawebagent"
  41. WEB_AGENT_TAR="$WEB_AGENT_DIR.tar"
  42. WEB_AGENT_DOC="doc"
  43. WEB_AGENT_README="readme.html"
  44. WEB_AGENT_TAR_GZ="$WEB_AGENT_TAR.gz"
  45. LICENSE="$HERE/license.txt"
  46. LICENSE2="$HERE/license2.txt"
  47. PATH_ROOT=""
  48.  
  49. PLUG_IS_INSTLD=FALSE
  50. ADMIN_IS_INSTLD=FALSE
  51. BACKUP_CRTD=FALSE
  52. PREV_INSTL=FALSE
  53.  
  54. echo_no_nl_mode="unknown"
  55.  
  56. ##############################################################################
  57. # Trap 
  58. #    this will trap any escape characters, and allow the program to abort normally 
  59. #    by calling abort_installation
  60. ##############################################################################
  61. trap 'trap "" 1 2 15; abort_installation' 1 2 15
  62.  
  63. ##############################################################################
  64. # echo_no_nl()
  65. #       Echo a string with no carriage return (if possible).  Must set
  66. #       $echo_no_nl to "unknown" before using for the first time.
  67. ##############################################################################
  68. echo_no_nl()
  69. {
  70.   if [ "$echo_no_nl_mode" = "unknown" ] ; then
  71.      echo_test=`echo \\\c`
  72.      if [ "$echo_test" = "\c" ] ; then
  73.         echo_no_nl_mode="-n"
  74.      else
  75.         echo_no_nl_mode="\c"
  76.      fi
  77.   fi
  78.  
  79.   if [ "$echo_no_nl_mode" = "\c" ] ; then
  80.      echo $* \\c
  81.   else
  82.      echo -n $*
  83.   fi
  84. }
  85.  
  86.  
  87. ##############################################################################
  88. # getfilename()
  89. # Gets a filename
  90. #   $1  The string to print to prompt the user
  91. #   $2  The default value if user hits <Enter> (y/n)
  92. #   $3  Type : DIRECTORY, EXISTINGFILE, NEWFILE, NEWDIRECTORY
  93. # The variable $YESORNO is set in accordance to what the user entered.
  94. ##############################################################################
  95. getfilename()
  96. {
  97. #####################################################
  98. # Set up line parameters as $1 and $2 are overwritten
  99. #####################################################
  100.   theprompt=$1
  101.   thedefault=$2
  102.   thetype=$3
  103.  
  104.   theans=""
  105.   until [ -n "$theans" ] ;
  106.   do
  107.     echo ""
  108.     echo_no_nl "$theprompt [$thedefault] "
  109.     read theans
  110.  
  111.     if [ "$theans" = "" ] ; then
  112.       theans=$thedefault
  113.     fi
  114.     case $thetype in
  115.         DIRECTORY) if [ ! -d "$theans" ]; then
  116.                         echo Directory $theans doesn\'t exist
  117.                         theans=""
  118.                    fi;;
  119.         READFILE)  if [ ! -f "$theans" ]; then
  120.                         echo File $theans doesn\'t exist
  121.                         theans=""
  122.                    elif [ ! -r "$theans" ]; then
  123.                         echo File "$theans" isn\'t readable
  124.                         theans=""
  125.                    fi;;
  126.         WRITEFILE)  if [ ! -f "$theans" ]; then
  127.                         echo File $theans doesn\'t exist
  128.                         theans=""
  129.                    elif [ ! -w "$theans" ]; then
  130.                         echo File "$theans" isn\'t writable
  131.                         theans=""
  132.                    fi;;
  133.         EXECFILE)  if [ ! -f "$theans" ]; then
  134.                         echo File $theans doesn\'t exist
  135.                         theans=""
  136.                    elif [ ! -x "$theans" ]; then
  137.                         echo File "$theans" isn\'t writable
  138.                         theans=""
  139.                    fi;;
  140.         NEWFILE)   if [ -f "$theans" ]; then
  141.                         echo File $theans already exist
  142.                         theans=""
  143.                    elif [ ! -d `dirname $theans` ]; then
  144.                         echo Directory `dirname $theans` doesn\'t exist
  145.                         theans=""
  146.                    elif [ ! -w `dirname $theans` ]; then
  147.                         echo Directory `dirname $theans` isn\'t writable
  148.                         theans=""
  149.                    fi;;
  150.         *);;
  151.     esac
  152.   done
  153.  
  154. }
  155.  
  156. ##############################################################################
  157. # getAcceptDecline()
  158. # Gets either a "Accept" or a "Decline" in the traditional (a/d) pattern 
  159. #               $1      The default value if user hits <Enter> (TRUE/FALSE)
  160. #               $2      The string to print to prompt the user
  161. # The variable $AORD is set in accordance to what the user entered.
  162. ##############################################################################
  163. getAcceptDecline()
  164. {
  165. #####################################################
  166. # Set up line parameters as $1 and $2 are overwritten
  167. #####################################################
  168.   AorDdef=$1
  169.   AorDprompt=$2
  170.  
  171.   AORD=""
  172.   until [ -n "$AORD" ] ;
  173.   do
  174.     echo ""
  175.     echo_no_nl $AorDprompt
  176.     read AORD
  177.  
  178.     AORD=`echo $AORD | tr '[a-z]' '[A-Z]'`
  179.  
  180.     case "$AORD"
  181.     in
  182.       A|ACCEPT )  AORD=TRUE;;
  183.       D|DECLINE )  AORD=FALSE;;
  184.       ''  )  AORD=$AorDdef;;
  185.       *   )  echo ""
  186.              echo "Please enter 'A', 'D' or '<return>' "
  187.              AORD="";;
  188.     esac
  189.   done
  190.  
  191. }
  192.  
  193.  
  194. ##############################################################################
  195. # getyesorno()
  196. # Gets either a "yes" or a "no" in the traditional (y/n) pattern 
  197. #               $1      The default value if user hits <Enter> (TRUE/FALSE)
  198. #               $2      The string to print to prompt the user
  199. # The variable $YESORNO is set in accordance to what the user entered.
  200. ##############################################################################
  201. getyesorno()
  202. {
  203. #####################################################
  204. # Set up line parameters as $1 and $2 are overwritten
  205. #####################################################
  206.   yesornodef=$1
  207.   yesornoprompt=$2
  208.  
  209.   YESORNO=""
  210.   until [ -n "$YESORNO" ] ;
  211.   do
  212.     echo ""
  213.     echo_no_nl $yesornoprompt
  214.     read YESORNO
  215.  
  216.     case "$YESORNO"
  217.     in
  218.       y|Y )  YESORNO=TRUE;;
  219.       n|N )  YESORNO=FALSE;;
  220.       ''  )  YESORNO=$yesornodef;;
  221.       *   )  echo ""
  222.              echo "Please enter 'y', 'n' or '<return>' "
  223.              YESORNO="";;
  224.     esac
  225.   done
  226.  
  227. }
  228.  
  229.  
  230. ##############################################################################
  231. # abort_installation()
  232. # This subroutine removes files that were recently installed and restores
  233. # the previous installation files, if they existed.
  234. ##############################################################################
  235. abort_installation()
  236. {
  237.   echo ""
  238.   echo "Aborting Installation..."
  239.  
  240.   if [ "$BACKUP_CRTD" = TRUE ] ; then
  241.     echo "Restoring Config Files..."
  242.     cp -pf $CONF_SAVE $CONF_FILE
  243.     rm -f $CONF_SAVE
  244.   fi
  245.  
  246.   if [ "$PLUG_IS_INSTLD" = TRUE ] ; then
  247.     echo "Removing installed Files...."
  248.     rm -rf "$WEB_AGENT"
  249.   fi 
  250.  
  251.   if [ "$PREV_INSTL" = TRUE ] ; then
  252.     echo "Restoring Old Agent..."
  253.     cp -Rpf $OLD_WEB_AGENT $WEB_AGENT
  254.     rm -rf $OLD_WEB_AGENT
  255.   fi
  256.  
  257.   exit 1
  258. }
  259.  
  260.  
  261. ############################################################
  262. # Display the License and Copyright files.
  263. ############################################################
  264. startup_screen()
  265. {
  266.  
  267.     # Changed so that we could have both license files shown
  268.     getyesorno TRUE "ARE YOU A CUSTOMER ORDERING THIS RSA PRODUCT FROM RSA SECURITY INC., FROM EITHER NORTH AMERICA, SOUTH AMERICA OR THE PEOPLE'S REPUBLIC OF CHINA (EXCLUDING HONG KONG): (y/n) [y]"
  269.     if [ "$YESORNO" = TRUE ] ; then
  270.         if [ -f $LICENSE ] ; then
  271.         more $LICENSE 
  272.     else
  273.         echo "The License Agreement text file could not be found in the current directory."
  274.         echo "Installation is aborting..."
  275.             abort_installation
  276.     fi
  277.     else
  278.         if [ -f $LICENSE2 ] ; then
  279.         more $LICENSE2 
  280.     else
  281.         echo "The License Agreement text file could not be found in the current directory."
  282.         echo "Installation is aborting..."
  283.         abort_installation
  284.     fi
  285.     fi
  286.  
  287.      getAcceptDecline FALSE "Do you accept the License Terms and Conditions stated above? (Accept/Decline) [D]"
  288.     if [ "$AORD" = FALSE ] ; then
  289.     abort_installation;
  290.     fi
  291. }
  292.  
  293. ############################################################
  294. # Check to see if the environment variable VAR_ACE is
  295. # defined and sdconf.rec exists
  296. ############################################################
  297. check_sdconf()
  298. {
  299. noerror=0
  300. if [ ! -n "$VAR_ACE" ]; then
  301.     VAR_ACE="/var/ace"
  302. fi
  303. theans=""
  304. while [ "$theans" = "" ] 
  305. do
  306.     getfilename "Enter Directory where sdconf.rec is located" $VAR_ACE DIRECTORY
  307.     if [ ! -f "$theans/sdconf.rec" ]; then 
  308.     echo file "$theans/sdconf.rec" not found
  309.     theans=""
  310.     elif [ ! -r "$theans/sdconf.rec" ]; then
  311.     echo file "$theans/sdconf.rec" not readable: change protection if needed
  312.         VAR_ACE="$theans"
  313.     theans=""
  314.     else
  315.     if [ "$theans" != "" ]; then
  316.             VAR_ACE="$theans"
  317.     fi
  318.     break
  319.     fi
  320.     
  321. done
  322.     
  323. }
  324.  
  325. ############################################################
  326. # Check to see if this is a supported platform.
  327. ############################################################
  328. check_platform()
  329. {
  330. case $UNAME
  331.    in
  332.      'SunOS'  )  SUN_VERS=`echo $UNAMER `
  333.                 case "$SUN_VERS" in
  334.                   '5.8' ) OS_DIR="sol" ;;
  335.                   * )
  336.                         echo""
  337.                         echo"Sorry we are currently supporting only the Solaris 8 Platform"
  338.                         echo""
  339.                         abort_installation;;
  340.                 esac;;
  341.  
  342.      'Linux' ) LNX_VERS=`echo $UNAMER | awk '{print substr($1, 1, 1)}'`
  343.                case "$LNX_VERS" in
  344.                * ) OS_DIR="lnx" ;;
  345.                esac;;
  346.  
  347. ## These are not supported yet.
  348. ##     'HP-UX' )  ;;
  349. ##
  350. ##     'AIX' ) AIX_VERS=`uname -vr | awk '{print $2 * 1000 + $1}'`
  351. ##        if [ AIX_VERS -lt 4001 ]; then
  352. ##            echo "Sorry we only support AIX 4.1 or greater"
  353. ##            abort_installation
  354. ##        fi
  355. ##        ;;
  356.    
  357.      *   )  echo ""
  358.             echo "Sorry, $UNAME is not currently supported."
  359.             echo ""
  360.             abort_installation ;;
  361. esac
  362. }
  363.  
  364. ############################################################
  365. # Check to see if webserver is running.
  366. ############################################################
  367. check_if_webserver_running()
  368. {
  369. a=`ps -ec | grep -v grep | egrep " httpd| aceapi_rpc" | wc -l`
  370. if [ $a != 0 ] ; then
  371.     echo
  372.     echo "We recommend you stop the Web server before installing the Agent."
  373.     getyesorno FALSE "Do you want to continue (y/n) "
  374.     if [ "$YESORNO" = FALSE ] ; then
  375.             abort_installation 
  376.     fi
  377.     
  378. fi
  379. }
  380. ############################################################
  381. # Check to see if this is a supported webserver platform.
  382. ############################################################
  383. check_webserver()
  384. {
  385. shvers=`$APACHE_EXEC -v | grep Stronghold | sed  "s/.*Stronghold\///" | awk ' {print $1} '`
  386. apachevers=`$APACHE_EXEC -v | grep Apache | sed "s/.*Apache\///" | awk ' {print $1} '`
  387. case $shvers in
  388.     3.0) case $apachevers in
  389.         1.3.19) ;;
  390.         1.3.2?) ;;
  391.         *)  echo ""
  392.                 echo "Sorry, $WEBSERVER version $apachevers is not currently supported."
  393.                 echo "The install script will abort the installation"
  394.                 echo "process. Please update the $WEBSERVER web server"
  395.                 echo "to version Stronghold 3.0 Build 3014 or later and reinstall"
  396.                 echo "the web agent."
  397.                 echo ""
  398.                 abort_installation ;;
  399.         esac ;;
  400.     *) case $apachevers in
  401.        1.3.19) ;;
  402.        1.3.2?) ;;
  403.          *)  echo ""
  404.         echo "Sorry, $WEBSERVER version $apachevers is not currently supported."
  405.         echo "The install script will abort the installation"
  406.         echo "process. Please update the $WEBSERVER web server"
  407.         echo "to version $WEBSERVER/1.3.22 and reinstall the web agent."
  408.         echo ""
  409.         abort_installation ;;                                                
  410.     esac ;;
  411. esac
  412. ########################
  413. # Check whether Apache has been installed to allow shared modules
  414. ########################
  415. if [ ! -n "`$APACHE_EXEC -l | grep -v grep | grep mod_so.c`" ] ; then
  416.    echo "" 
  417.    echo "RSA Web Agent can not be installed on your system"
  418.    echo "The current installation of $WEBSERVER Web Server does not"
  419.    echo "allow for shared modules."
  420.    echo "Please re-install $WEBSERVER to enable shared mdoules"
  421.    echo "and try again"
  422.    abort_installation
  423. fi
  424.  
  425. }
  426.  
  427.  
  428.  
  429. ############################################################
  430. # Ask the user for the Apache Server Root and setup
  431. # other installation information
  432. ############################################################
  433. setup_paths()
  434. {
  435. ###########################################
  436. # Get the Apache Server Root directory path
  437. ###########################################
  438. APACHE_SERVER_ROOT=""
  439. SERVER_SCRIPT_DIR=""
  440. DEFAULT_ROOT="/etc/httpd"
  441. if [ ! -d  "$DEFAULT_ROOT" ] ; then
  442.     DEFAULT_ROOT="/usr/apache"
  443.     if [ ! -d  "$DEFAULT_ROOT" ] ; then
  444.         DEFAULT_ROOT="/usr/local/apache"
  445.     fi
  446. fi
  447.  
  448. until [ -n "$APACHE_SERVER_ROOT" ] ;
  449. do
  450.     echo ""
  451.     getfilename "Please enter the path for the $WEBSERVER installation directory" $DEFAULT_ROOT DIRECTORY
  452.     APACHE_SERVER_ROOT=$theans
  453. done
  454.  
  455. SERVER_SCRIPT_DIR=$APACHE_SERVER_ROOT/bin
  456.  
  457. ##############################
  458. # Now find the httpd.conf file
  459. ##############################
  460. CONFIG_TMP="/usr/local/apache/conf/httpd.conf" 
  461. if [ -f $APACHE_SERVER_ROOT/conf/httpd.conf ]; then
  462.    CONFIG_TMP=$APACHE_SERVER_ROOT/conf/httpd.conf
  463. fi
  464.  
  465. #############
  466. # Now Confirm
  467. #############
  468.  
  469. echo ""
  470. getfilename "Please enter the path for the $WEBSERVER Configuration File " $CONFIG_TMP WRITEFILE
  471. CONF_FILE=$theans
  472.  
  473. INSTALL_USER=`ps -f | awk '{ print $1 " " $2 }' | grep $$ | awk '{ print $1 }'`
  474. APACHE_USER=`grep "^User " $CONF_FILE | awk '{print $2}'`
  475. APACHE_GROUP=`grep "^Group " $CONF_FILE | awk '{print $2}'`
  476. if [ "$APACHE_USER" = "" ] ; then
  477.    echo "Error could find User in $CONF_FILE"
  478.    abort_installation;
  479.     
  480. fi
  481. CONF_TMP="$CONF_FILE.tmp"
  482. CONF_SAVE="$CONF_FILE."`date +%D%T | sed "s/\//-/g" `
  483. ##############################
  484. # Now find the httpd executable
  485. ##############################
  486. EXEC_TMP="" 
  487. EXEC_TMP=$APACHE_SERVER_ROOT/bin/httpd
  488. if [ ! -x $EXEC_TMP ]; then
  489.     EXEC_TMP=$APACHE_SERVER_ROOT/src/httpd
  490.     if [ ! -x $EXEC_TMP ]; then
  491.         EXEC_TMP=`whereis httpd | awk '{print $2}'`
  492.         if [ "$EXEC_TMP" = "" ]; then
  493.             EXEC_TMP="/usr/bin/httpd"
  494.         fi
  495.     fi
  496. fi
  497.  
  498. echo ""
  499. getfilename "Please enter the path for the $WEBSERVER httpd binary file" $EXEC_TMP EXECFILE
  500. APACHE_EXEC=$theans
  501.  
  502.  
  503.  
  504. WEB_AGENT="$APACHE_SERVER_ROOT/$WEB_AGENT_DIR"
  505. OLD_WEB_AGENT="$WEB_AGENT.old"
  506. echo ""
  507. echo "The Web Agent will be installed in the $WEB_AGENT directory."
  508.  
  509. }
  510.  
  511. ############################################################
  512. # Edit httpd.conf file to complete the install process
  513. ############################################################
  514. edit_conf()
  515. {
  516. #################
  517. # Construct the new httpd.conf entries
  518. #################
  519. HTTPD_CONF_STR="
  520. ###### BEGIN_RSA_BLOCK
  521. ###### WARNING: DO NOT EDIT THIS BLOCK. ANYTHING ADDED WILL BE REMOVED BY
  522. ######          THE NEXT INSTALLATION OF RSA WEB AGENT
  523. include $WEB_AGENT/rsawebagent.conf
  524. ###### END_RSA_BLOCK
  525. "
  526.  
  527. RSAWEBAGENT_CONF_STR="
  528. #
  529. # RSA Web Agent configuration information
  530. # This file is included by the current httpd.conf file
  531. #
  532. # Load and add the web agent module in the configuration
  533. LoadModule rsawebagent_module $WEB_AGENT/mod_rsawebagent.so
  534. AddModule mod_rsawebagent.c
  535. #
  536. # RSA Web Agent installation directory
  537. #
  538. <IfModule mod_rsawebagent.c>
  539. RSAWebAgentInstallPath $WEB_AGENT
  540. VAR_ACEPath $VAR_ACE
  541. </IfModule>
  542. "
  543.  
  544. #################
  545. # create rsawebagent.conf
  546. #################
  547. echo "$RSAWEBAGENT_CONF_STR" > $WEB_AGENT/rsawebagent.conf
  548.  
  549. #####################
  550. # Save a copy of the original httpd.conf file
  551. #####################
  552. if cp -p $CONF_FILE $CONF_SAVE ; then
  553.    echo "Backup of $CONF_FILE copied to $CONF_SAVE"
  554. else
  555.    echo "Error backing up $CONF_FILE"
  556.    abort_installation;
  557. fi
  558.  
  559. BACKUP_CRTD=TRUE
  560.                
  561. echo ""
  562. echo "Editing httpd.conf file...."
  563.  
  564. ###################
  565. # Now perform the necessary httpd.conf edits
  566. ###################
  567. if [ -n "`egrep 'mod_rsawebagent.so|rsawebagent.conf' $CONF_FILE`" ] ; then
  568.  
  569.     PREV_INSTL=TRUE
  570.    
  571.     ############
  572.     # First find our lines and delete them
  573.     ############
  574.     cat $CONF_FILE | awk 'BEGIN   {
  575.     printon = 1
  576.     }
  577.     {
  578.     if ( $0 ~ /BEGIN_RSA_BLOCK/ ) printon = 0
  579.     if ( printon == 1 ) print
  580.     if ( $0 ~ /END_RSA_BLOCK/ ) printon = 1
  581.     }' > $CONF_TMP
  582.     
  583.     if cp -f $CONF_TMP $CONF_FILE
  584.     then :
  585.     else
  586.        echo "Error modifying $CONF_FILE"
  587.        abort_installation;
  588.     fi
  589.  
  590. fi
  591.  
  592. ################
  593. # Always add our lines at the end
  594. ################
  595.  
  596. if echo "$HTTPD_CONF_STR" >> $CONF_FILE
  597. then :
  598. else
  599.    echo "Error modifying $CONF_FILE"
  600.    abort_installation;
  601. fi
  602.  
  603. echo "Done editing httpd.conf file"
  604. }
  605.  
  606.  
  607. ###########################################################
  608. # Edit the INI file to add the protected URLs
  609. ###########################################################
  610. edit_ini()
  611. {
  612.  
  613.     echo "Configuring RSA Web Agent...."
  614.  
  615.     #######################################
  616.     # Call config script
  617.     #######################################
  618.     rm -f $WEB_AGENT/httpd.conf
  619.     ln -s $CONF_FILE $WEB_AGENT/httpd.conf
  620.     $WEB_AGENT/config GlobalServerData
  621.  
  622.     echo "Done configuring RSA Web Agent"
  623.  
  624.  
  625.  
  626.  
  627. ############################################################
  628. # Install the RSA Web Agent library and configuration.
  629. ############################################################
  630. install_webagent()
  631. {
  632. ##############
  633. #untar the RPM file
  634. ##############
  635.  
  636. if [ -d  $WEB_AGENT ]; then
  637.     echo "It appears that the Web Agent has already been installed."
  638.     getyesorno FALSE "Should the installation continue? (y/n) [n]:"
  639.     if [ "$YESORNO" = FALSE ] ; then
  640.        abort_installation
  641.     fi
  642.     cp -r $WEB_AGENT $OLD_WEB_AGENT
  643.     PREV_INSTL=TRUE
  644. fi
  645. echo "Now installing the Web Agent for $WEBSERVER Server Files."
  646. echo "This may take several minutes."
  647. echo ""
  648.  
  649. PLUG_IS_INSTLD=TRUE
  650. cd $APACHE_SERVER_ROOT/
  651. if [ -f $HERE/$OS_DIR/$WEB_AGENT_TAR ]; then
  652.     tar xvf $HERE/$OS_DIR/$WEB_AGENT_TAR
  653. elif [ -f $HERE/$OS_DIR/$WEB_AGENT_TAR_GZ ]; then
  654.     tar xzvf $HERE/$OS_DIR/$WEB_AGENT_TAR_GZ
  655. elif [ -f $HERE/$WEB_AGENT_TAR ]; then
  656.     tar xvf $HERE/$WEB_AGENT_TAR
  657. elif [ -f $HERE/$WEB_AGENT_TAR_GZ ]; then
  658.     tar xzvf $HERE/$WEB_AGENT_TAR_GZ
  659. elif [ -d $HERE/$WEB_AGENT_DIR ]; then
  660.     cp -r $HERE/$WEB_AGENT_DIR .
  661. else
  662.     echo Error $HERE/$WEB_AGENT_TAR, $HERE/$WEB_AGENT_TAR_GZ or $HERE/$WEB_AGENT_DIR does not exist
  663. fi
  664. if [ -d $HERE/$WEB_AGENT_DOC ]; then
  665.     cp -r $HERE/$WEB_AGENT_DOC $WEB_AGENT_DIR
  666. fi
  667. if [ -f $HERE/$WEB_AGENT_README ]; then
  668.     cp $HERE/$WEB_AGENT_README $WEB_AGENT_DIR
  669. fi
  670. cd $HERE
  671.  
  672. }
  673.  
  674.  
  675.  
  676. ############################################################
  677. # All done now create uninstall script.
  678. ############################################################
  679. create_uninstall()
  680. {
  681. ############################################################
  682. thedate=`date`
  683. UNINSTALL_SCRIPT=$WEB_AGENT/uninstall
  684. echo "Creating uninstall script $UNINSTALL_SCRIPT...."
  685. if [ -f $UNINSTALL_SCRIPT ] ; then
  686.     mv $UNINSTALL_SCRIPT $UNINSTALL_SCRIPT.old
  687. fi
  688. cat > $UNINSTALL_SCRIPT     <<DEBUT
  689. #!/bin/sh 
  690. # Created by RSA Web Agent install script on $thedate
  691. # to be used to uninstall Web Agent
  692. #
  693.  
  694. ############
  695. # First check if httpd or aceapi_rpc_server is running 
  696. ############
  697. a=\`ps -ec | grep -v grep | egrep " httpd| aceapi_rpc" | wc -l\`
  698. if [ \$a != 0 ] ; then
  699.     ans=""
  700.     until [ "\$ans" = "y" ] || [ "\$ans" = "n" ]
  701.     do
  702.     echo
  703.         echo "We recommend you stop the Web server before un-installing the Agent."
  704.         echo "Do you want to continue (y/n)"
  705.         read ans
  706.     ans=\`echo \$ans | tr '[A-Z]' '[a-z]'\`
  707.     done
  708.     if [ "\$ans" = "n" ] ; then
  709.             exit 1 
  710.     fi
  711.     isrunning="1"
  712. fi
  713. ############
  714. # Second verify need to uninstall 
  715. ############
  716. ans=""
  717. until [ "\$ans" = "y" ] || [ "\$ans" = "n" ]
  718. do
  719.         echo "Uninstalling Web Agent ."
  720.         echo "Are you sure you want to continue (y/n)"
  721.         read ans
  722.     ans=\`echo \$ans | tr '[A-Z]' '[a-z]'\`
  723. done
  724. if [ "\$ans" != "y" ] ; then
  725.             exit 1 
  726. fi
  727. ############
  728. # Third find RSA lines in httpd.conf and delete them
  729. ############
  730.  
  731.     cat $CONF_FILE | awk 'BEGIN   {
  732.     printon = 1
  733.     }
  734.     {
  735.     if ( \$0 ~ /BEGIN_RSA_BLOCK/ ) printon = 0
  736.     if ( printon == 1 ) print
  737.     if ( \$0 ~ /END_RSA_BLOCK/ ) printon = 1
  738.     }' > $CONF_TMP
  739.     
  740.     cp -f $CONF_TMP $CONF_FILE
  741.     if [ "\$isrunning" = "1" ] ; then
  742.         $WEB_AGENT/reloadWebAgent
  743.     fi
  744. ############
  745. # Fourth remove rsawebagent directory 
  746. ############
  747.  
  748.     rm -rf $WEB_AGENT 
  749.     if [ -d $OLD_WEB_AGENT ] ; then 
  750.         mv $OLD_WEB_AGENT $WEB_AGENT
  751.     fi
  752.  
  753. echo ""
  754. echo "*************************************************************"
  755. echo "* You have successfully uninstalled RSA Web Agent for $WEBSERVER"
  756. echo "*************************************************************"
  757. DEBUT
  758. chmod 500 $UNINSTALL_SCRIPT
  759. echo "Done creating uninstall script $UNINSTALL_SCRIPT"
  760. }
  761. check_if_webserver_running
  762. startup_screen
  763. check_sdconf
  764. check_platform
  765. setup_paths
  766. check_webserver
  767. install_webagent
  768. create_uninstall
  769. edit_conf
  770. edit_ini
  771.  
  772. chmod -R 700  $WEB_AGENT
  773. if [ "$INSTALL_USER" = "root" ]; then
  774.     if [ "$INSTALL_USER" != "$APACHE_USER" ]; then
  775.         chown -R $APACHE_USER $WEB_AGENT
  776.     fi
  777.     if [ "$APACHE_GROUP" != "" ]; then
  778.         chgrp -R $APACHE_GROUP  $WEB_AGENT
  779.     fi
  780. fi
  781. chmod -R 4700  $WEB_AGENT/ace*
  782.  
  783. $WEB_AGENT/registerWA
  784.  
  785. echo ""
  786. echo "*************************************************************"
  787. echo "* You have successfully installed RSA Web Agent for $WEBSERVER"
  788. echo "*************************************************************"
  789. echo "* By default every URL is protected "
  790. echo "* If you want to unprotect specific URL, run the command :"
  791. echo "*"
  792. echo "* $WEB_AGENT/protectURL"
  793. echo "*"
  794. echo "*************************************************************"
  795.