home *** CD-ROM | disk | FTP | other *** search
/ ftp.rsa.com / 2014.05.ftp.rsa.com.tar / ftp.rsa.com / pub / agents / WebAgent_53_Apache_385_120407.tar / CD / install next >
Text File  |  2007-12-04  |  33KB  |  1,203 lines

  1. #!/bin/sh 
  2. #
  3. # Installation script for the RSA Authentication Agent for Web Servers Plugin.
  4. #
  5. #
  6. #********************************************************************************
  7. #* COPYRIGHT (C) 2007  by RSA Security Inc.
  8. #*    ---ALL RIGHTS RESERVED---
  9. #********************************************************************************
  10. #
  11.  
  12. ############################################################
  13. # Set default values and commands for the shell script.
  14. ############################################################
  15. clear
  16.  
  17. UNAME=`uname`
  18. UNAMER=`uname -r`
  19. HOSTNAME=`hostname`
  20. WEBSERVER="apache"
  21. WEBSERVERNAME="Apache"
  22. if [ $WEBSERVER = "iplanet" ] ; then
  23. WEBSERVERNAME="Sun Java System"
  24. fi
  25. PROCESS_LIST="httpd"
  26. PLATFORM_OK=FALSE
  27.  
  28. HERE=`dirname $0` 
  29. THEPWD=`/bin/pwd`
  30. if [ "$HERE" = "." ]; then
  31.     HERE="$THEPWD"
  32. else
  33. #if $HERE isn't absolute path add `pwd` to it
  34.  
  35.     cd $HERE
  36.     HERE=`/bin/pwd`
  37.     cd $THEPWD
  38. fi
  39.  
  40. #suji needs to change
  41. ########################
  42. ########################
  43. APACHE_DOCS=""
  44. APACHE_CONFIG=""
  45. APACHE_EXEC=""
  46. APACHE_LIB=""
  47. CONF_FILE=""
  48. OBJCONF_FILE=""
  49. WEB_AGENT="/tmp/toto"
  50. WEB_AGENT_DIR="rsawebagent"
  51. WEB_AGENT_TAR="$WEB_AGENT_DIR.tar"
  52. WEB_AGENT_DOC="doc"
  53. WEB_AGENT_README="readme"
  54. WEB_AGENT_TAR_GZ="$WEB_AGENT_TAR.gz"
  55. LICENSE="$HERE/license.txt"
  56. LICENSE2="$HERE/license2.txt"
  57. PATH_ROOT=""
  58. DF="df -P -k"
  59. MPM_WORKER_CONFIG=FALSE
  60.  
  61. # Disk space require for the installation
  62. SPACE=3500
  63.  
  64. PLUG_IS_INSTLD=FALSE
  65. ADMIN_IS_INSTLD=FALSE
  66. BACKUP_CRTD=FALSE
  67. PREV_INSTL=FALSE
  68.  
  69. echo_no_nl_mode="unknown"
  70.  
  71. ##############################################################################
  72. # Trap 
  73. #    this will trap any escape characters, and allow the program to abort normally 
  74. #    by calling abort_installation
  75. ##############################################################################
  76. trap 'trap "" 1 2 15; abort_installation' 1 2 15
  77.  
  78. ##############################################################################
  79. # echo_no_nl()
  80. #       Echo a string with no carriage return (if possible).  Must set
  81. #       $echo_no_nl to "unknown" before using for the first time.
  82. ##############################################################################
  83. echo_no_nl()
  84. {
  85.   if [ "$echo_no_nl_mode" = "unknown" ] ; then
  86.      echo_test=`echo \\\c`
  87.      if [ "$echo_test" = "\c" ] ; then
  88.         echo_no_nl_mode="-n"
  89.      else
  90.         echo_no_nl_mode="\c"
  91.      fi
  92.   fi
  93.  
  94.   if [ "$echo_no_nl_mode" = "\c" ] ; then
  95.      echo $* \\c
  96.   else
  97.      echo -n $*
  98.   fi
  99. }
  100.  
  101.  
  102. ##############################################################################
  103. # getfilename()
  104. # Gets a filename
  105. #   $1  The string to print to prompt the user
  106. #   $2  The default value if user hits <Enter> (y/n)
  107. #   $3  Type : DIRECTORY, EXISTINGFILE, NEWFILE, NEWDIRECTORY
  108. # The variable $YESORNO is set in accordance to what the user entered.
  109. ##############################################################################
  110. getfilename()
  111. {
  112. #####################################################
  113. # Set up line parameters as $1 and $2 are overwritten
  114. #####################################################
  115.   theprompt=$1
  116.   thedefault=$2
  117.   thetype=$3
  118.  
  119.   theans=""
  120.   until [ -n "$theans" ] ;
  121.   do
  122.     echo ""
  123.     echo_no_nl "$theprompt [$thedefault] "
  124.     read theans
  125.  
  126.     if [ "$theans" = "" ] ; then
  127.       theans=$thedefault
  128.     fi
  129.     case $thetype in
  130.         DIRECTORY) if [ ! -d "$theans" ]; then
  131.                         echo Directory $theans doesn\'t exist
  132.                         theans=""
  133.                    fi;;
  134.         READFILE)  if [ ! -f "$theans" ]; then
  135.                         echo File $theans doesn\'t exist
  136.                         theans=""
  137.                    elif [ ! -r "$theans" ]; then
  138.                         echo File "$theans" isn\'t readable
  139.                         theans=""
  140.                    fi;;
  141.         WRITEFILE)  if [ ! -f "$theans" ]; then
  142.                         echo File $theans doesn\'t exist
  143.                         theans=""
  144.                    elif [ ! -w "$theans" ]; then
  145.                         echo File "$theans" isn\'t writable
  146.                         theans=""
  147.                    fi;;
  148.         EXECFILE)  if [ ! -f "$theans" ]; then
  149.                         echo File $theans doesn\'t exist
  150.                         theans=""
  151.                    elif [ ! -x "$theans" ]; then
  152.                         echo File "$theans" isn\'t writable
  153.                         theans=""
  154.                    fi;;
  155.         NEWFILE)   if [ -f "$theans" ]; then
  156.                         echo File $theans already exist
  157.                         theans=""
  158.                    elif [ ! -d `dirname $theans` ]; then
  159.                         echo Directory `dirname $theans` doesn\'t exist
  160.                         theans=""
  161.                    elif [ ! -w `dirname $theans` ]; then
  162.                         echo Directory `dirname $theans` isn\'t writable
  163.                         theans=""
  164.                    fi;;
  165.         *);;
  166.     esac
  167.   done
  168.  
  169. }
  170.  
  171.  
  172. ##########################################################################
  173. #
  174. # getservername()
  175. # The variable WEBSERVER is set to the name of the server being used
  176. ##########################################################################
  177. #getservername()
  178. #{
  179. #####################################################
  180. # Set up line parameters as $1 and $2 are overwritten
  181. #####################################################
  182. #  theprompt=$1
  183. #  thedefault=$2
  184.  
  185. #### asf
  186. #  theans=2
  187. #  echo ""
  188.   
  189. #  while [ "$theans" != "1" ] && [ "$theans" != "2" ]
  190. #  do
  191. #  echo
  192. #  echo " 1. Apache"
  193. #  echo " 2. Sun ONE"
  194. #  echo
  195. #  echo_no_nl "$theprompt [$thedefault] "
  196. #  read theans
  197. #  if [ "$theans" = "" ] ; then
  198. #    theans=1
  199. #  fi
  200. #  done
  201.   
  202. #  if [ "$theans" = "1" ] ; then
  203. #    WEBSERVER="apache"
  204. #    PROCESS_LIST=" httpd| aceapi_rpc_"
  205. #  else
  206. #    WEBSERVER="iplanet"
  207. #    PROCESS_LIST="ns-httpd| aceapi_rpc_"
  208. #  fi
  209. ##### This is modified during kit generation by the makefile
  210. # WEBSERVER=""
  211. #####
  212. #}
  213.  
  214. ##############################################################################
  215. # getAcceptDecline()
  216. # Gets either a "Accept" or a "Decline" in the traditional (a/d) pattern 
  217. #               $1      The default value if user hits <Enter> (TRUE/FALSE)
  218. #               $2      The string to print to prompt the user
  219. # The variable $AORD is set in accordance to what the user entered.
  220. ##############################################################################
  221. getAcceptDecline()
  222. {
  223. #####################################################
  224. # Set up line parameters as $1 and $2 are overwritten
  225. #####################################################
  226.   AorDdef=$1
  227.   AorDprompt=$2
  228.  
  229.   AORD=""
  230.   until [ -n "$AORD" ] ;
  231.   do
  232.     echo ""
  233.     echo_no_nl $AorDprompt
  234.     read AORD
  235.  
  236.     AORD=`echo $AORD | tr '[a-z]' '[A-Z]'`
  237.  
  238.     case "$AORD"
  239.     in
  240.       A|ACCEPT )  AORD=TRUE;;
  241.       D|DECLINE )  AORD=FALSE;;
  242.       ''  )  AORD=$AorDdef;;
  243.       *   )  echo ""
  244.              echo "Please enter 'A', 'D' or '<return>' "
  245.              AORD="";;
  246.     esac
  247.   done
  248.  
  249. }
  250.  
  251.  
  252. ##############################################################################
  253. # getyesorno()
  254. # Gets either a "yes" or a "no" in the traditional (y/n) pattern 
  255. #               $1      The default value if user hits <Enter> (TRUE/FALSE)
  256. #               $2      The string to print to prompt the user
  257. # The variable $YESORNO is set in accordance to what the user entered.
  258. ##############################################################################
  259. getyesorno()
  260. {
  261. #####################################################
  262. # Set up line parameters as $1 and $2 are overwritten
  263. #####################################################
  264.   yesornodef=$1
  265.   yesornoprompt=$2
  266.  
  267.   YESORNO=""
  268.   until [ -n "$YESORNO" ] ;
  269.   do
  270.     echo ""
  271.     echo_no_nl $yesornoprompt
  272.     read YESORNO
  273.  
  274.     case "$YESORNO"
  275.     in
  276.       y|Y )  YESORNO=TRUE;;
  277.       n|N )  YESORNO=FALSE;;
  278.       ''  )  YESORNO=$yesornodef;;
  279.       *   )  echo ""
  280.              echo "Please enter 'y', 'n' or '<return>' "
  281.              YESORNO="";;
  282.     esac
  283.   done
  284.  
  285. }
  286.  
  287.  
  288. ##############################################################################
  289. # abort_installation()
  290. # This subroutine removes files that were recently installed and restores
  291. # the previous installation files, if they existed.
  292. ##############################################################################
  293. abort_installation()
  294. {
  295.   echo ""
  296.   echo "Aborting Installation..."
  297.  
  298.   if [ "$BACKUP_CRTD" = TRUE ] ; then
  299.     echo "Restoring Config Files..."
  300.  
  301.     cp -pf $CONF_SAVE $CONF_FILE
  302.     rm -f $CONF_SAVE
  303.  
  304.     if [ $WEBSERVER = "iplanet" ] ; then
  305.       cp -pf $OBJCONF_SAVE $OBJCONF_FILE
  306.       rm -f $OBJCONF_SAVE
  307.     fi
  308.  
  309.   fi
  310.  
  311.   if [ "$PLUG_IS_INSTLD" = TRUE ] ; then
  312.     echo "Removing installed Files...."
  313.     rm -rf "$WEB_AGENT"
  314.   fi 
  315.  
  316.   if [ "$PREV_INSTL" = TRUE ] ; then
  317.     echo "Restoring Old Agent..."
  318.     cp -Rpf $OLD_WEB_AGENT $WEB_AGENT
  319.     rm -rf $OLD_WEB_AGENT
  320.   fi
  321.  
  322.   exit 1
  323. }
  324.  
  325.  
  326. ############################################################
  327. # Display the License and Copyright files.
  328. ############################################################
  329. startup_screen()
  330. {
  331.  
  332.     # Changed so that we could have both license files shown
  333.     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]"
  334.     if [ "$YESORNO" = TRUE ] ; then
  335.         if [ -f $LICENSE ] ; then
  336.         more $LICENSE 
  337.     else
  338.         echo "The License Agreement text file could not be found in the current directory."
  339.         echo "Installation is aborting..."
  340.             abort_installation
  341.     fi
  342.     else
  343.         if [ -f $LICENSE2 ] ; then
  344.         more $LICENSE2 
  345.     else
  346.         echo "The License Agreement text file could not be found in the current directory."
  347.         echo "Installation is aborting..."
  348.         abort_installation
  349.     fi
  350.     fi
  351.  
  352.      getAcceptDecline FALSE "Do you accept the License Terms and Conditions stated above? (Accept/Decline) [D]"
  353.     if [ "$AORD" = FALSE ] ; then
  354.     abort_installation;
  355.     fi
  356. }
  357.  
  358. ############################################################
  359. # Check to see if the environment variable VAR_ACE is
  360. # defined and sdconf.rec exists
  361. ############################################################
  362. check_sdconf()
  363. {
  364. noerror=0
  365. if [ ! -n "$VAR_ACE" ]; then
  366.     VAR_ACE="/var/ace"
  367. fi
  368. theans=""
  369. while [ "$theans" = "" ] 
  370. do
  371.     getfilename "Enter Directory where sdconf.rec is located" $VAR_ACE DIRECTORY
  372.     if [ ! -f "$theans/sdconf.rec" ]; then 
  373.     echo file "$theans/sdconf.rec" not found
  374.     theans=""
  375.     elif [ ! -r "$theans/sdconf.rec" ]; then
  376.     echo file "$theans/sdconf.rec" not readable: change protection if needed
  377.         VAR_ACE="$theans"
  378.     theans=""
  379.     else
  380.     if [ "$theans" != "" ]; then
  381.             VAR_ACE="$theans"
  382.     fi
  383.     break
  384.     fi
  385.     
  386. done
  387.     
  388. }
  389.  
  390. ############################################################
  391. # Check to see if this is a supported platform.
  392. ############################################################
  393. check_platform()
  394. {
  395. case $UNAME in
  396. SunOS) OS_DIR=sol
  397.        DF="/usr/xpg4/bin/df -P -k";;
  398. Linux)
  399.     case $UNAMER in
  400.     2.4.* )
  401.        OS_DIR=lnxas3;;
  402.     2.6.* )
  403.        OS_DIR=lnxas4;;
  404.     * )
  405.        OS_DIR=lnx;;
  406.     esac;;
  407. HP*) OS_DIR=hp11;;
  408. esac
  409. case $WEBSERVER
  410.    in
  411.      apache )
  412.         case $UNAME in
  413.                 Linux|SunOS);;
  414.                 *)
  415.                       echo ""
  416.                       echo "Sorry, $UNAME is not currently supported for $WEBSERVERNAME."
  417.                       echo ""
  418.                       abort_installation;;
  419.         esac ;;
  420.  
  421.      iplanet )
  422.         case $UNAME in
  423.                 HP*|SunOS);;
  424.                 *)
  425.                    echo ""
  426.                    echo "Sorry, $UNAME is not currently supported for $WEBSERVERNAME
  427. ."
  428.                    echo ""
  429.                    abort_installation;;
  430.         esac ;;
  431.  
  432.      * ) echo ""
  433.          echo "Sorry, $WEBSERVERNAME Web Server is not currently supported."
  434.  echo ""
  435.          abort_installation
  436.          ;;
  437.  
  438. esac
  439. }
  440.  
  441.  
  442.  
  443. ############################################################
  444. # Check to see if webserver is running.
  445. ############################################################
  446. check_if_webserver_running()
  447. {
  448. a=`ps -ecf | grep -v grep | egrep "$PROCESS_LIST" | egrep -v "https-adms" | wc -l`
  449. if [ $a != 0 ] ; then
  450.     echo
  451.     echo "We recommend you stop the Web server before installing the Agent."
  452.     getyesorno FALSE "Do you want to continue (y/n) [n]:"
  453.     if [ "$YESORNO" = FALSE ] ; then
  454.             abort_installation 
  455.     fi
  456. fi
  457. }
  458.  
  459.  
  460. ############################################################
  461. # Check to see if this is a supported webserver platform.
  462. ############################################################
  463. check_webserver()
  464. {
  465. case $WEBSERVER in
  466.  'apache' )
  467.     apachevers=`$APACHE_EXEC -v | grep Apache | sed "s/.*Apache\///" | awk ' {print $1} '`
  468.     case $apachevers in
  469.        2.0.*) ;;
  470.        2.2.*) ;;
  471.          *)  echo ""
  472.         echo "Sorry, $WEBSERVERNAME version $apachevers is not currently supported."
  473.         echo "The install script will abort the installation"
  474.         echo "process. Please update the $WEBSERVERNAME web server"
  475.         echo "to version $WEBSERVERNAME/2.0.50 or higher and reinstall the web agent."
  476.         echo ""
  477.         abort_installation ;;                                                
  478.     esac 
  479. ########################
  480. # Check whether Apache has been installed to allow shared modules
  481. ########################
  482.     if [ ! -n "`$APACHE_EXEC -l | grep -v grep | grep mod_so.c`" ] ; then
  483.        echo "" 
  484.        echo "RSA Authentication Agent for Web can not be installed on your system"
  485.        echo "The current installation of $WEBSERVERNAME Web Server does not"
  486.        echo "allow for shared modules."
  487.        echo "Please re-install $WEBSERVERNAME to enable shared modules"
  488.        echo "and try again"
  489.        abort_installation
  490.     fi
  491.  
  492. ########################
  493. # Check to see if Apache is installed in worker MPM configuration.
  494. # If so, we must install the threaded libaceauth.so instead of
  495. # using the rpc server.
  496. ########################
  497. ##    if [ -n "`$APACHE_EXEC -l | grep -v grep | grep worker.c`" ] ; then
  498.     if [ -n "`$APACHE_EXEC -l | grep -v grep | grep worker.c`" ] ; then
  499.         MPM_WORKER_CONFIG=TRUE
  500.     fi
  501.  
  502.    ;;
  503.  
  504.    'iplanet' ) 
  505.      ipvers=`$WEB_SERVER_ROOT/start -version | grep iPlanet | cut -d/ -f2 | awk ' {print $1} '`
  506.      if [ ! -n "$ipvers" ] ; then
  507.         ipvers=`$WEB_SERVER_ROOT/start -version | grep "Sun ONE Web Server" | cut -d" " -f5 | awk ' {print $1} '`
  508.      fi
  509.  
  510.      case $ipvers in
  511.     6.0* | 6.1* ) ;;
  512.     * ) echo ""
  513.         echo "Sorry, $WEBSERVERNAME version $ipvers is not currently supported."        echo "The install script will abort the installation"
  514.         echo "process. Please update the $WEBSERVERNAME web server"
  515.         echo "to version Sun Java System Web Server 6.x and reinstall the web agent."
  516.         echo ""
  517.         abort_installation
  518.    ;;
  519.    esac
  520.  
  521. ;;
  522. esac
  523. }
  524.  
  525.  
  526.  
  527. ############################################################
  528. # Ask the user for the Web Server Root and setup
  529. # other installation information
  530. ############################################################
  531. setup_paths()
  532. {
  533. WEB_SERVER_ROOT=""
  534.  
  535. #############################################################
  536. ###############  A P A C H E  ###############################
  537. #############################################################
  538. case $WEBSERVER in
  539.    'apache' )
  540.  
  541. ###########################################
  542. # Get the Apache Server Root directory path
  543. ###########################################
  544. DEFAULT_ROOT="/etc/httpd"
  545. if [ ! -d  "$DEFAULT_ROOT" ] ; then
  546.     DEFAULT_ROOT="/usr/local/apache2"
  547.     if [ ! -d  "$DEFAULT_ROOT" ] ; then
  548.     DEFAULT_ROOT="/usr/apache2"
  549.     if [ ! -d  "$DEFAULT_ROOT" ] ; then
  550.         DEFAULT_ROOT="/usr/local/apache"
  551.         if [ ! -d  "$DEFAULT_ROOT" ] ; then
  552.         DEFAULT_ROOT="/usr/apache"
  553.             if [ ! -d  "$DEFAULT_ROOT" ] ; then
  554.             DEFAULT_ROOT="/usr/apache2"
  555.             fi
  556.         fi
  557.     fi
  558.     fi
  559. fi
  560.  
  561. until [ -n "$WEB_SERVER_ROOT" ] ;
  562. do
  563.     echo ""
  564.     getfilename "Please enter the path for the $WEBSERVERNAME installation directory" $DEFAULT_ROOT DIRECTORY
  565.     WEB_SERVER_ROOT=$theans
  566.     
  567.     if [ ! -f $WEB_SERVER_ROOT/conf/httpd.conf ] ; then
  568.       if [ ! -f $WEB_SERVER_ROOT/bin/httpd ] ; then
  569.         echo ""
  570.         echo "The path, $WEB_SERVER_ROOT, is not a valid path to your $WEBSERVERNAME root dir."
  571.         WEB_SERVER_ROOT=""
  572.       fi
  573.     fi
  574.     
  575.       
  576.     if [ "$WEB_SERVER_ROOT" != "" ]; then
  577.          dir="`$DF $WEB_SERVER_ROOT | sed -e "1,1d" | awk '{print($4)}'`"
  578.         if [ $dir -lt $SPACE ] ; then
  579.             echo ""
  580.               echo "The path, $WEB_SERVER_ROOT, does not have enough disk space to install the web agent."
  581.                 WEB_SERVER_ROOT=""
  582.          fi
  583.     fi
  584.  
  585. done
  586.  
  587. ##############################
  588. # Now find the httpd.conf file
  589. ##############################
  590. CONFIG_TMP="/usr/local/apache/conf/httpd.conf" 
  591. if [ -f $WEB_SERVER_ROOT/conf/httpd.conf ]; then
  592.    CONFIG_TMP=$WEB_SERVER_ROOT/conf/httpd.conf
  593. fi
  594.  
  595. #############
  596. # Now Confirm
  597. #############
  598.  
  599. echo ""
  600. getfilename "Please enter the path for the $WEBSERVERNAME Configuration File " $CONFIG_TMP WRITEFILE
  601. CONF_FILE=$theans
  602.  
  603. INSTALL_USER=`ps -f | awk '{ print $1 " " $2 }' | grep $$ | awk '{ print $1 }'`
  604. SERVER_USER=`grep "^User " $CONF_FILE | awk '{print $2}' | sed "s/#//" `
  605. SERVER_GROUP=`grep "^Group " $CONF_FILE | awk '{print $2}' | sed "s/#//" `
  606. if [ "$INSTALL_USER" = "root" ]; then
  607.     if [ "$SERVER_USER" = ""  ] || [ "$SERVER_USER" = "-1"  ]  ; then
  608.        echo "Error: could not find a valid User in $CONF_FILE"
  609.         echo
  610.         echo "You need to set a valid User directive in the $CONF_FILE file"
  611.         abort_installation 
  612.     fi
  613.     if [ "$SERVER_GROUP" = ""  ] || [ "$SERVER_GROUP" = "-1"  ]  ; then
  614.        echo "Error: could not find a valid Group in $CONF_FILE"
  615.         echo
  616.         echo "We recommend you set a valid Group directive in the $CONF_FILE file"
  617.         getyesorno FALSE "Do you want to continue (y/n) [n]:"
  618.         if [ "$YESORNO" = FALSE ] ; then
  619.             abort_installation 
  620.         fi
  621.     fi
  622. fi
  623. CONF_TMP="$CONF_FILE.tmp"
  624. CONF_SAVE="$CONF_FILE."`date +%D%T | sed "s/\//-/g" `
  625. ##############################
  626. # Now find the httpd executable
  627. ##############################
  628. EXEC_TMP="" 
  629. EXEC_TMP=$WEB_SERVER_ROOT/bin/httpd
  630. if [ ! -x $EXEC_TMP ]; then
  631.     EXEC_TMP=$WEB_SERVER_ROOT/src/httpd
  632.     if [ ! -x $EXEC_TMP ]; then
  633.         EXEC_TMP=`whereis httpd | awk '{print $2}'`
  634.         if [ "$EXEC_TMP" = "" ]; then
  635.             EXEC_TMP="/usr/bin/httpd"
  636.         fi
  637.     fi
  638. fi
  639.  
  640. echo ""
  641. getfilename "Please enter the path for the $WEBSERVERNAME httpd binary file" $EXEC_TMP EXECFILE
  642. APACHE_EXEC=$theans
  643.  
  644. APACHE_LIB=""
  645. if [ "$UNAME" = "SunOS" ]; then
  646. ##############################
  647. # Now find the apache lib directory
  648. ##############################
  649. LIB_TMP="" 
  650. LIB_TMP=$WEB_SERVER_ROOT/lib
  651. if [ ! -d $LIB_TMP ]; then
  652.     LIB_TMP=`dirname $APACHE_EXEC`
  653.     LIB_TMP=$LIB_TMP/../lib
  654.     if [ ! -d $LIB_TMP ]; then
  655.     LIB_TMP=$WEB_SERVER_ROOT/lib
  656.     fi
  657. fi
  658.  
  659. echo ""
  660. getfilename "Please enter the path for the $WEBSERVERNAME library directory" $LIB_TMP DIRECTORY
  661. APACHE_LIB=$theans
  662. fi
  663.  
  664.    ;;
  665.  
  666. #############################################################
  667. ###############  I P L A N E T  #############################
  668. #############################################################
  669.   iplanet )
  670. ################################
  671. # Get the Web Server root directory path
  672. ################################
  673.     DEFAULT_ROOT="/etc/iplanet/servers"
  674.     if [ ! -d  "$DEFAULT_ROOT" ] ; then
  675.         DEFAULT_ROOT="/usr/iplanet/servers"
  676.         if [ ! -d  "$DEFAULT_ROOT" ] ; then
  677.             DEFAULT_ROOT="/usr/local/iplanet/servers"
  678.         fi
  679.     fi
  680.     DEFAULT_ROOT=`ls -1d $DEFAULT_ROOT/https-* 2>/dev/null| grep -v admserv 2>/dev/null| head -1 2>/dev/null` 
  681.  
  682.     WEB_SERVER_ROOT=""
  683.     while [ "$WEB_SERVER_ROOT" = "" ] ;
  684.     do
  685.         echo ""
  686.         getfilename "Please enter the path for the $WEBSERVERNAME servername directory" $DEFAULT_ROOT DIRECTORY
  687.         WEB_SERVER_ROOT=$theans
  688.         if [ ! -f $WEB_SERVER_ROOT/config/magnus.conf ] ; then
  689.             echo ""
  690.             echo "The path, $WEB_SERVER_ROOT, is not a valid path to your $WEBSERVERNAME root dir."
  691.             WEB_SERVER_ROOT=""
  692.         else
  693.             dir="`$DF $theans | sed -e "1,1d" | awk '{print($4)}'`"
  694.            if [ $dir -lt $SPACE ] ; then
  695.             echo ""
  696.               echo "The path, $WEB_SERVER_ROOT, does not have enough disk space to install the web agent."
  697.                 WEB_SERVER_ROOT=""
  698.             fi
  699.         fi
  700.  
  701.     done
  702.  
  703.     CONF_FILE=$WEB_SERVER_ROOT/config/magnus.conf
  704.     OBJCONF_FILE=$WEB_SERVER_ROOT/config/obj.conf
  705.  
  706. #############
  707. # Now Confirm
  708. #############
  709.  
  710.  
  711.     INSTALL_USER=`ps -f | awk '{ print $1 " " $2 }' | grep $$ | awk '{ print $1 }'`
  712.     SERVER_USER=`grep "^User " $CONF_FILE | awk '{print $2}'`
  713.     SERVER_GROUP=`ls -l $CONF_FILE | awk '{print $4}'`
  714.     if [ "$SERVER_USER" = "" ] ; then
  715.        echo "Error could find User in $CONF_FILE"
  716.        abort_installation;
  717.     
  718.     fi
  719.     CONF_TMP="$CONF_FILE.tmp"
  720.     CONF_SAVE="$CONF_FILE."`date +%D%T | sed "s/\//-/g" `
  721.  
  722.     OBJCONF_TMP="$OBJCONF_FILE.tmp"
  723.     OBJCONF_SAVE="$OBJCONF_FILE."`date +%D%T | sed "s/\//-/g" `
  724.   
  725.     ;;
  726.  
  727. esac
  728.  
  729. WEB_AGENT="$WEB_SERVER_ROOT/$WEB_AGENT_DIR"
  730. OLD_WEB_AGENT="$WEB_AGENT.old"
  731. echo ""
  732. echo "The Web Agent will be installed in the $WEB_AGENT directory."
  733.  
  734. }
  735.  
  736. construct_apache_conf_str()
  737. {
  738.   RSA_CONF_STR="###### BEGIN_RSA_BLOCK
  739. ###### WARNING: DO NOT EDIT THIS BLOCK. ANYTHING ADDED WILL BE REMOVED BY
  740. ######          THE NEXT INSTALLATION OF RSA WEB AGENT
  741. include $WEB_AGENT/rsawebagent.conf
  742. ###### END_RSA_BLOCK"
  743.  
  744.   RSAWEBAGENT_CONF_STR="#
  745. # RSA Authentication Agent for Web configuration information
  746. # This file is included by the current httpd.conf file
  747. #
  748. # Load and add the web agent module in the configuration
  749. LoadModule rsawebagent_module $WEB_AGENT/mod_rsawa_apache.so
  750. #
  751. # RSA Authentication Agent for Web installation directory
  752. #
  753. <IfModule mod_rsawebagent.c>
  754. RSAWebAgentInstallPath $WEB_AGENT
  755. VAR_ACEPath $VAR_ACE
  756. </IfModule> "
  757. }
  758.  
  759. construct_iplanet_conf_str()
  760. {
  761. RSAWEBAGENT_CONF_STR="\\
  762. Init fn=\"load-modules\" shlib=\"$WEB_AGENT/mod_rsawa_iplanet.so\" funcs=\"mod_rsawa_init,mod_rsawa_url_translator,mod_rsawa_service_auth\"\\
  763. Init fn=\"mod_rsawa_init\" RSAWebAgentInstallPath=\"$WEB_AGENT\" VAR_ACEPath=\"$VAR_ACE\" "
  764.  
  765. NAME_TRANS_STR="NameTrans fn=\"mod_rsawa_url_translator\""
  766.  
  767. SERVICE_AUTH_STR="Service method=\"(GET|POST)\" type=\"magnus-internal/auth\" fn=\"mod_rsawa_service_auth\""
  768. }
  769.  
  770. delete_lines()
  771. {
  772.   FILE_TO_EDIT="$1"
  773.   LINE_TO_REMOVE="$2"
  774.   egrep -v "$LINE_TO_REMOVE" "$FILE_TO_EDIT" >  $CONF_TMP
  775.   if cp -f $CONF_TMP $FILE_TO_EDIT
  776.   then :
  777.   else
  778.     rm $CONF_TMP
  779.     echo "Error modifying $FILE_TO_EDIT"
  780.     abort_installation;
  781.   fi
  782.   rm $CONF_TMP
  783.  
  784. }
  785. delete_rsa_lines()
  786. {
  787.   ###################
  788.   # Now delete our lines if there are any
  789.   ###################
  790.  
  791.   ############
  792.   # First find our lines and delete them
  793.   ############
  794.   cat $FILE_TO_EDIT | awk 'BEGIN   {
  795.   printon = 1
  796.   }
  797.   {
  798.   if ( $0 ~ /BEGIN_RSA_BLOCK/ ) printon = 0
  799.   if ( printon == 1 ) print
  800.   if ( $0 ~ /END_RSA_BLOCK/ ) printon = 1
  801.   }' > $CONF_TMP
  802.  
  803.   if cp -f $CONF_TMP $FILE_TO_EDIT
  804.   then :
  805.   else
  806.     rm $CONF_TMP
  807.     echo "Error modifying $FILE_TO_EDIT"
  808.     abort_installation;
  809.   fi
  810.   rm $CONF_TMP
  811. }
  812.  
  813.  
  814. save_conf_file()
  815. {
  816.     if cp -p $ORIG_FILE $SAVE_FILE ; then
  817.        echo "Backup of $ORIG_FILE copied to $SAVE_FILE"
  818.     else
  819.        echo "Error backing up $ORIG_FILE"
  820.        abort_installation;
  821.     fi
  822.  
  823.     BACKUP_CRTD=TRUE
  824.                
  825. }
  826.  
  827.  
  828. ############################################################
  829. # Edit httpd.conf file to complete the install process
  830. ############################################################
  831. edit_conf()
  832. {
  833. #################
  834. # Construct the new configuration entries
  835. #################
  836. case $WEBSERVER in
  837.   'apache' )
  838.     construct_apache_conf_str
  839.  
  840.     #################
  841.     # create rsawebagent.conf
  842.     #################
  843.     echo "$RSAWEBAGENT_CONF_STR" > $WEB_AGENT/rsawebagent.conf
  844.     
  845.     #####################
  846.     # Save a copy of the original httpd.conf file
  847.     #####################
  848.     ORIG_FILE=$CONF_FILE
  849.     SAVE_FILE=$CONF_SAVE
  850.     save_conf_file
  851.  
  852.     echo ""
  853.     echo "Editing httpd.conf file...."
  854.  
  855.     ###################
  856.     # Now perform the necessary httpd.conf edits
  857.     ###################
  858.     if [ -n "`egrep 'mod_rsawa_apache.so|rsawebagent.conf' $CONF_FILE`" ] ; then
  859.  
  860.       PREV_INSTL=TRUE
  861.    
  862.       FILE_TO_EDIT=$CONF_FILE
  863.  
  864.       delete_rsa_lines
  865.     fi
  866.  
  867.     ################
  868.     # Always add our lines at the end
  869.     ################
  870.     if echo "$RSA_CONF_STR" >> $CONF_FILE
  871.     then :
  872.     else
  873.        echo "Error modifying $CONF_FILE"
  874.        abort_installation;
  875.     fi
  876.  
  877.     echo "Done editing httpd.conf file"
  878.     ;;
  879.  
  880.   'iplanet' )
  881.     construct_iplanet_conf_str
  882.  
  883.     #####################
  884.     # Save a copy of the original magnus/obj.conf file
  885.     #####################
  886.     ORIG_FILE=$CONF_FILE
  887.     SAVE_FILE=$CONF_SAVE
  888.     save_conf_file
  889.  
  890.     ORIG_FILE=$OBJCONF_FILE
  891.     SAVE_FILE=$OBJCONF_SAVE
  892.     save_conf_file
  893.  
  894.     echo ""
  895.     echo "Editing magnus.conf file...."
  896.  
  897.     ###################
  898.     # Now perform the necessary magnus.conf edits
  899.     ###################
  900.     if [ -n "`egrep 'mod_rsawa_iplanet.so|rsawebagent.conf' $CONF_FILE`" ] ; then
  901.       PREV_INSTL=TRUE
  902.       delete_lines $CONF_FILE "mod_rsawa_iplanet.so|rsawebagent.conf"
  903.     fi
  904.  
  905.  
  906.     ################
  907.     # Now add our lines
  908.     ################
  909.     insert_lines "$CONF_FILE" "Init fn" "$RSAWEBAGENT_CONF_STR"
  910.  
  911.     echo "Done editing magnus.conf file"
  912.     ;;
  913. esac
  914.  
  915. }
  916.  
  917.  
  918. insert_lines()
  919. {
  920.   FILE_TO_EDIT=$1
  921.   LINE_TO_FIND=$2
  922.   LINE_TO_ADD=$3
  923.   LINE_NO=`egrep -n "$LINE_TO_FIND" $FILE_TO_EDIT | head -1 | awk -F: '{print $1}'`
  924.   LINE_NO=`expr $LINE_NO - 1`
  925.  
  926.   ###########
  927.   # Now try to append our line
  928.   ###########
  929.   cat $FILE_TO_EDIT | sed "${LINE_NO}a\\
  930. $LINE_TO_ADD" > $CONF_TMP
  931.  
  932.   if cp -f $CONF_TMP $FILE_TO_EDIT
  933.   then :
  934.   else
  935.     rm $CONF_TMP
  936.     echo "Error modifying $FILE_TO_EDIT"
  937.     abort_installation;
  938.   fi
  939.   rm $CONF_TMP
  940. }
  941.  
  942. ###########################################################
  943. # Edit the INI file to add the protected URLs
  944. ###########################################################
  945. edit_ini()
  946. {
  947.  
  948.     echo "Configuring RSA Authentication Agent for Web...."
  949.  
  950.     #######################################
  951.     # Call config script
  952.     #######################################
  953.     if [ $WEBSERVER = "iplanet" ] ; then
  954.        CONF_LINK=magnus.conf
  955.     elif [ $WEBSERVER = "apache" ] ; then
  956.        CONF_LINK=httpd.conf
  957.     fi
  958.  
  959.     rm -f $WEB_AGENT/$CONF_LINK
  960.     ln -s $CONF_FILE $WEB_AGENT/$CONF_LINK
  961.     $WEB_AGENT/config GlobalServerData
  962.     if [ "$?" != "0" ]; then
  963.         abort_installation;
  964.     fi 
  965.     echo "Done configuring RSA Authentication Agent for Web"
  966.  
  967.  
  968.  
  969.  
  970. ############################################################
  971. # Install the RSA Authentication Agent for Web library and configuration.
  972. ############################################################
  973. install_webagent()
  974. {
  975. ##############
  976. #untar the RPM file
  977. ##############
  978.  
  979. if [ -d  $WEB_AGENT ]; then
  980.     echo "It appears that a Web Agent has already been installed."
  981.     if [ -d  $OLD_WEB_AGENT ]; then
  982.         echo "And that the Web Agent has already been backed up into $OLD_WEB_AGENT."
  983.         echo "Please remove or rename existing $OLD_WEB_AGENT directory."
  984.         abort_installation
  985.     fi
  986.     getyesorno FALSE "Should the installation upgrade the Web Agent ? (y/n) [n]:"
  987.     if [ "$YESORNO" = FALSE ] ; then
  988.        abort_installation
  989.     fi
  990.     cp -r $WEB_AGENT $OLD_WEB_AGENT
  991.     PREV_INSTL=TRUE
  992.     echo "Your previous installation has been backed up to $OLD_WEB_AGENT directory."
  993. fi
  994.  
  995. echo "Now installing the Web Agent for $WEBSERVERNAME Server Files."
  996. echo "This may take several minutes."
  997. echo ""
  998.  
  999. PLUG_IS_INSTLD=TRUE
  1000. cd $WEB_SERVER_ROOT/
  1001. if [ -f $HERE/$OS_DIR/$WEB_AGENT_TAR ]; then
  1002.     tar xvf $HERE/$OS_DIR/$WEB_AGENT_TAR
  1003. elif [ -f $HERE/$OS_DIR/$WEB_AGENT_TAR_GZ ]; then
  1004.     tar xzvf $HERE/$OS_DIR/$WEB_AGENT_TAR_GZ
  1005. elif [ -f $HERE/$WEB_AGENT_TAR ]; then
  1006.     tar xvf $HERE/$WEB_AGENT_TAR
  1007. elif [ -f $HERE/$WEB_AGENT_TAR_GZ ]; then
  1008.     tar xzvf $HERE/$WEB_AGENT_TAR_GZ
  1009. elif [ -d $HERE/$WEB_AGENT_DIR ]; then
  1010.     cp -r $HERE/$WEB_AGENT_DIR .
  1011. else
  1012.     echo Error $HERE/$WEB_AGENT_TAR, $HERE/$WEB_AGENT_TAR_GZ or $HERE/$WEB_AGENT_DIR does not exist
  1013. fi
  1014. if [ -d $HERE/$WEB_AGENT_DOC ]; then
  1015.     cp -r $HERE/$WEB_AGENT_DOC $WEB_AGENT_DIR
  1016. fi
  1017. if [ -d $HERE/$WEB_AGENT_README ]; then
  1018.     cp -r $HERE/$WEB_AGENT_README $WEB_AGENT_DIR
  1019. fi
  1020. if [ -f $WEB_AGENT_DIR/librwtool.so.2 ]; then
  1021.    chmod +x $WEB_AGENT_DIR/librwtool.so.2
  1022.    if [ "$APACHE_LIB" != "" ]; then
  1023.         if [ -d $APACHE_LIB ]; then
  1024.            cp $WEB_AGENT_DIR/librwtool.so.2 $APACHE_LIB
  1025.         fi
  1026.       if [ ! -f $APACHE_LIB/librwtool.so.2 ]; then
  1027.           echo Error: Could not copy $WEB_AGENT_DIR/librwtool.so.2 into $APACHE_LIB
  1028.       fi
  1029.    fi
  1030. fi
  1031.  
  1032. if [ "$MPM_WORKER_CONFIG" = TRUE ] ; then
  1033.     cd $WEB_SERVER_ROOT/$WEB_AGENT_DIR
  1034.     mv aceapi_rpc_server aceapi_rpc_server.org
  1035.     cd $WEB_SERVER_ROOT/$WEB_AGENT_DIR/Plugins
  1036.     mv libaceauth.so libaceauth_pre_fork_mpm.so.org
  1037.     tar xvf libaceauth_mpm_worker.tar
  1038.     echo "The Web Agent is setup for Apache worker MPM cofiguration."
  1039. else
  1040.     echo "The Web Agent is setup for Apache pre-fork MPM cofiguration."
  1041. fi
  1042.  
  1043. }
  1044.  
  1045.  
  1046.  
  1047. ############################################################
  1048. # All done now create uninstall script.
  1049. ############################################################
  1050. create_uninstall()
  1051. {
  1052. ############################################################
  1053. thedate=`date`
  1054. UNINSTALL_SCRIPT=$WEB_AGENT/uninstall
  1055. echo "Creating uninstall script $UNINSTALL_SCRIPT...."
  1056. if [ -f $UNINSTALL_SCRIPT ] ; then
  1057.     mv $UNINSTALL_SCRIPT $UNINSTALL_SCRIPT.old
  1058. fi
  1059. cat > $UNINSTALL_SCRIPT     <<DEBUT
  1060. #!/bin/sh 
  1061. # Created by RSA Authentication Agent for Web install script on $thedate
  1062. # to be used to uninstall Web Agent
  1063. #
  1064.  
  1065. ############
  1066. # First check if httpd or aceapi_rpc_server is running 
  1067. ############
  1068. a=\`ps -ecf | grep -v grep | egrep "$PROCESS_LIST" | egrep -v "https-adms" | wc -l\`
  1069. if [ \$a != 0 ] ; then
  1070.     ans=""
  1071.     until [ "\$ans" = "y" ] || [ "\$ans" = "n" ]
  1072.     do
  1073.     echo
  1074.         echo "We recommend you stop the Web server before un-installing the Agent."
  1075.         echo "Do you want to continue (y/n)"
  1076.         read ans
  1077.     ans=\`echo \$ans | tr '[A-Z]' '[a-z]'\`
  1078.     done
  1079.     if [ "\$ans" = "n" ] ; then
  1080.             exit 1 
  1081.     fi
  1082.     isrunning="1"
  1083. fi
  1084. ############
  1085. # Second verify need to uninstall 
  1086. ############
  1087. ans=""
  1088. until [ "\$ans" = "y" ] || [ "\$ans" = "n" ]
  1089. do
  1090.         echo "Uninstalling Web Agent."
  1091.         echo "Are you sure you want to continue (y/n)"
  1092.         read ans
  1093.     ans=\`echo \$ans | tr '[A-Z]' '[a-z]'\`
  1094. done
  1095. if [ "\$ans" != "y" ] ; then
  1096.             exit 1 
  1097. fi
  1098. if [ -d $OLD_WEB_AGENT ] ; then 
  1099. ############
  1100. # There is a old agent let's put back in place 
  1101. ############
  1102.     mv $OLD_WEB_AGENT $WEB_AGENT
  1103. else
  1104. ############
  1105. # Third find RSA lines in httpd.conf and delete them
  1106. ############
  1107. DEBUT
  1108.  
  1109.  
  1110. if [ "$WEBSERVER" = "iplanet" ] ; then
  1111. cat >> $UNINSTALL_SCRIPT     <<DEBUT
  1112.       egrep -v "mod_rsawa_iplanet.so|RSAWebAgentInstallPath" $CONF_FILE > $CONF_TMP
  1113.       cp -f $CONF_TMP $CONF_FILE
  1114.       for i in \`ls $WEB_SERVER_ROOT/config/*obj.conf \`
  1115.       do
  1116.     
  1117.           egrep -v "mod_rsawa_url_translator|mod_rsawa_service_auth" "\$i" > $OBJCONF_TMP
  1118.           cp -f $OBJCONF_TMP "\$i"
  1119.       done
  1120.       rm $OBJCONF_TMP
  1121. DEBUT
  1122. else
  1123. cat >> $UNINSTALL_SCRIPT     <<DEBUT
  1124.     cat $CONF_FILE | awk 'BEGIN   {
  1125.     printon = 1
  1126.     }
  1127.     {
  1128.     if ( \$0 ~ /BEGIN_RSA_BLOCK/ ) printon = 0
  1129.     if ( printon == 1 ) print
  1130.     if ( \$0 ~ /END_RSA_BLOCK/ ) printon = 1
  1131.     }' > $CONF_TMP
  1132.     
  1133.     cp -f $CONF_TMP $CONF_FILE
  1134. DEBUT
  1135. fi
  1136. cat >> $UNINSTALL_SCRIPT     <<DEBUT
  1137.     if [ "\$isrunning" = "1" ] ; then
  1138.         $WEB_AGENT/reloadWebAgent
  1139.     fi
  1140.     rm $CONF_TMP
  1141. ############
  1142. # Fourth remove rsawebagent directory 
  1143. ############
  1144.  
  1145.     cd "${WEB_AGENT}/.."
  1146.     rm -rf $WEB_AGENT 
  1147.  
  1148. fi
  1149. echo ""
  1150. echo "************************************************************************"
  1151. echo "* Successfully uninstalled RSA Authentication Agent for Web for $WEBSERVERNAME"
  1152. echo "************************************************************************"
  1153. DEBUT
  1154. chmod 500 $UNINSTALL_SCRIPT
  1155. echo "Done creating uninstall script $UNINSTALL_SCRIPT"
  1156. }
  1157.  
  1158. #getservername "Please enter the Web Server " 1
  1159. #echo "Installing WebAgent for $WEBSERVERNAME"
  1160. check_if_webserver_running
  1161. startup_screen
  1162. check_sdconf
  1163. check_platform
  1164. setup_paths
  1165. check_webserver
  1166. install_webagent
  1167. create_uninstall
  1168. edit_conf
  1169. edit_ini
  1170.  
  1171. chmod -R 700  $WEB_AGENT
  1172. if [ "$INSTALL_USER" = "root" ]; then
  1173.     if [ "$INSTALL_USER" != "$SERVER_USER" ]; then
  1174.         chown -R $SERVER_USER $WEB_AGENT
  1175.     fi
  1176.     if [ "$SERVER_GROUP" != "" ]; then
  1177.         chgrp -R $SERVER_GROUP  $WEB_AGENT
  1178.     fi
  1179. fi
  1180. chmod -R 4700  $WEB_AGENT/ace*
  1181.  
  1182. $WEB_AGENT/registerWA
  1183.  
  1184. if [ "$PREV_INSTL" = TRUE ] ; then
  1185. echo ""
  1186. echo "************************************************************************"
  1187. echo "* Successfully upgraded RSA Authentication Agent for Web for $WEBSERVERNAME"
  1188. echo "************************************************************************"
  1189. else
  1190. echo ""
  1191. echo "************************************************************************"
  1192. echo "* Successfully installed RSA Authentication Agent for Web for $WEBSERVERNAME"
  1193. echo "************************************************************************"
  1194. fi
  1195.  
  1196. echo "* By default every URL is protected "
  1197. echo "* If you want to unprotect specific URL, run the command :"
  1198. echo "*"
  1199. echo "* $WEB_AGENT/protectURL"
  1200. echo "*"
  1201. echo "************************************************************************"
  1202.