home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / server / Server-on-CD.iso / socd / usr / sbin / apacheconfig < prev    next >
Encoding:
Text File  |  2003-09-04  |  2.8 KB  |  100 lines

  1. #!/bin/sh
  2. # Copyright 2001  David Cantrell, Concord, California USA
  3. # All rights reserved.
  4. #
  5. # Redistribution and use of this script, with or without modification, is
  6. # permitted provided that the following conditions are met:
  7. #
  8. # 1. Redistributions of this script must retain the above copyright
  9. #    notice, this list of conditions and the following disclaimer.
  10. #
  11. #  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  12. #  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
  14. #  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  15. #  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  16. #  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  17. #  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  18. #  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  19. #  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  20. #  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21. #
  22. # ChangeLog:
  23. # 09-Mar-2001    The module description is now obtained from the script
  24. #                in /var/log/setup/apache.
  25. #
  26. # 26-Feb-2001    Initial version.
  27. #
  28.  
  29. # Check to make sure that needed Apache components exist
  30. if [ ! -d /var/log/setup/apache ]; then
  31.    exit
  32. fi
  33. if [ "`( cd /var/log/setup/apache ; /bin/ls -1 )`" = "" ]; then
  34.    exit
  35. fi
  36. if [ ! -d /etc/apache ]; then
  37.    exit
  38. fi
  39. if [ "`( cd /etc/apache ; /bin/ls -1 )`" = "" ]; then
  40.    exit
  41. fi
  42.  
  43. if [ ! "$USER" = "root" ]; then
  44.    exit
  45. fi
  46.  
  47. # Set some initial variables and locations
  48. TMP=/var/log/setup/tmp
  49. if [ ! -d $TMP ]; then
  50.    mkdir -p $TMP
  51.    chmod 700 $TMP
  52. fi
  53.  
  54. # Generate the dialog script
  55. rm -rf $TMP/apachescript.sh
  56. cat << EOF > $TMP/apachescript.sh
  57. #!/bin/sh
  58. dialog --title "APACHE WEB SERVER CONFIGURATION" --menu \\
  59. "The following lists contains settings and/or modules for \\
  60. the Apache web server.  Select the one you would like to \\
  61. configure and press Enter." 13 60 4 \\
  62. EOF
  63.  
  64. # Add the modules to the menu
  65. for mod in `( cd /var/log/setup/apache ; /bin/ls -1 | sort )` ; do
  66.    moddesc="`cat /var/log/setup/apache/$mod | grep "# DESCRIPTION: " | sed -e "s|# DESCRIPTION: ||g"`"
  67.  
  68.    if [ "$moddesc" = "" ]; then
  69.       echo "\"$mod\" \"$mod\" \\" >> $TMP/apachescript.sh
  70.    else
  71.       echo "\"$mod\" \"$moddesc\" \\" >> $TMP/apachescript.sh
  72.    fi
  73. done
  74.  
  75. # Complete the script
  76. cat << EOF >> $TMP/apachescript.sh
  77. 2> $TMP/output
  78. if [ \$? = 1 -o \$? = 255 ]; then
  79.    rm -f $TMP/output
  80.    exit
  81. fi
  82. EOF
  83.  
  84. sh $TMP/apachescript.sh
  85.  
  86. if [ ! -r $TMP/output ]; then
  87.    rm -f $TMP/apachescript.sh
  88.    exit
  89. fi
  90.  
  91. OUTPUT=`cat $TMP/output`
  92.  
  93. # Configure this Apache module/setting
  94. if [ -x /var/log/setup/apache/$OUTPUT ]; then
  95.    sh /var/log/setup/apache/$OUTPUT
  96. fi
  97.  
  98. rm -f $TMP/apachescript.sh $TMP/output
  99.  
  100.