gforge-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gforge-commits] gforge/utils install-apache.sh,1.1,1.2


From: cbayle
Subject: [Gforge-commits] gforge/utils install-apache.sh,1.1,1.2
Date: Fri, 16 Jan 2004 19:53:59 -0600

Update of /cvsroot/gforge/gforge/utils
In directory db.perdue.net:/tmp/cvs-serv12961/utils

Modified Files:
        install-apache.sh 
Log Message:
Some improvement


Index: install-apache.sh
===================================================================
RCS file: /cvsroot/gforge/gforge/utils/install-apache.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- install-apache.sh   24 Nov 2003 23:29:55 -0000      1.1
+++ install-apache.sh   17 Jan 2004 01:53:56 -0000      1.2
@@ -4,144 +4,207 @@
 #
 # Configure apache for GForge
 # Christian Bayle, Roland Mas, debian-sf (GForge for Debian)
+#
+# Reset fb color mode
+RESET="]R"
+# ANSI COLORS
+# Erase to end of line
+CRE="
"
+# Clear and reset Screen
+CLEAR="c"
+# Normal color
+NORMAL=""
+# RED: Failure or error message
+RED=""
+# GREEN: Success message
+GREEN=""
 
 set -e
 
+ARG=$@
 if [ $(id -u) != 0 ] ; then
     echo "You must be root to run this, please enter passwd"
     exec su -c "$0 $1"
 fi
 
-if [ -z "$etcapache" ] 
-then 
-       if [ -d /etc/apache ]
-       then 
-               etcapache="/etc/apache" 
-       else 
-               if [ -d /etc/apache-ssl ]
-               then
-                       etcapache="/etc/apache-ssl"
-               else
-                       echo '[No etcapache]' ; exit 1
-               fi
+
+search_conf_file(){
+CONFFILE=$1
+shift
+echo -n "Searching $CONFFILE config file       "
+RESULT=""
+for i in $*
+do
+       if [ -f "$i" ]
+       then
+               RESULT="$i $RESULT"
        fi
+done
+if [ -z "$RESULT" ]
+then
+       echo "$RED[Failed]$NORMAL" 
+       echo "${CONFFILE} conf file not found at $*"
+       echo "Please set ${CONFFILE}_ETC_SEARCH" ; exit 1
+else
+       echo "$GREEN[OK]$NORMAL"
 fi
+}
 
-if [ -z "$etcgforge" ] 
+get_conf(){
+if [ "$HAVECONF" != "true" ]
+then
+if [ -z "$APACHE_ETC_SEARCH" ] 
 then 
-       if [ -d /etc/gforge ] 
-       then 
-               etcgforge="/etc/gforge" 
-       else 
-               echo '[No etcgforge]' ; exit 1
-       fi
+       APACHE_ETC_SEARCH="/etc/apache/httpd.conf /etc/apache-perl/httpd.conf 
/etc/apache-ssl/httpd.conf"
 fi
-if [ -z "$etcphp4apache" ] 
+if [ -z "$GFORGE_ETC_SEARCH" ] 
 then 
-       etcphp4apache="/etc/php4/apache"
-else
-       echo '[No etcphp4apache]' ; exit 1
+       GFORGE_ETC_SEARCH="/etc/gforge/httpd.conf"
 fi
+if [ -z "$PHP_ETC_SEARCH" ] 
+then 
+       PHP_ETC_SEARCH="/etc/php4/apache/php.ini /etc/php4/cgi/php.ini"
+fi
+export APACHE_ETC_SEARCH GFORGE_ETC_SEARCH PHP_ETC_SEARCH
+
+search_conf_file APACHE "$APACHE_ETC_SEARCH"
+APACHE_ETC_LIST="$RESULT"
+search_conf_file GFORGE "$GFORGE_ETC_SEARCH"
+GFORGE_ETC_LIST="$RESULT"
+search_conf_file PHP "$PHP_ETC_SEARCH"
+PHP_ETC_LIST="$RESULT"
+export APACHE_ETC_LIST GFORGE_ETC_LIST PHP_ETC_LIST
 
-[ -z "$etcphp4cgi" ] && etcphp4cgi="/etc/php4/cgi"
 [ -z "$gforgebin" ] && gforgebin="/usr/lib/gforge/bin"
+set $GFORGE_ETC_LIST
+gforgeconffile=$1
+echo Using $gforgeconffile
+export gforgeconffile
+HAVECONF=true
+export HAVECONF
+fi
+}
 
+get_conf
+set $ARG
 case "$1" in
     configure-files)
        # Make sure Apache sees us
-       if [ -e $etcapache/httpd.conf ] ; then
-           cp -a $etcapache/httpd.conf $etcapache/httpd.conf.gforge-new
-           perl -pi -e "s/# *LoadModule php4_module/LoadModule php4_module/gi" 
$etcapache/httpd.conf.gforge-new
-           perl -pi -e "s/# *LoadModule ssl_module/LoadModule ssl_module/gi" 
$etcapache/httpd.conf.gforge-new
-           perl -pi -e "s/# *LoadModule env_module/LoadModule env_module/gi" 
$etcapache/httpd.conf.gforge-new
-           perl -pi -e "s/# *LoadModule vhost_alias_module/LoadModule 
vhost_alias_module/gi" $etcapache/httpd.conf.gforge-new
+       for apacheconffile in $APACHE_ETC_LIST
+       do
+               APACHE_ETC_DIR=`basename $apacheconffile`
+               if [ -d "$APACHE_ETC_DIR/conf.d" ]
+               then
+                       # New apache conf       
+                       # Remove old hack to have Apache see us
+                       if [ -e $apacheconffile ] && grep -q "Include 
$gforgeconffile" $apacheconffile ; then
+                               cp -a $apacheconffile $apacheconffile.gforge-new
+                               pattern=$(basename $0)
+                               tmp=$(mktemp /tmp/$pattern.XXXXXX)
+                               grep -v "Include $gforgeconffile\|### Next line 
inserted by GForge install" $apacheconffile.gforge-new > $tmp
+                               cat $tmp > $apacheconffile.gforge-new
+                               rm -f $tmp
+                       fi
+               else    
+                       # Old fashion Apache
+                       if [ -e $apacheconffile ] ; then
+                               cp -a $apacheconffile $apacheconffile.gforge-new
+                               perl -pi -e "s/# *LoadModule 
php4_module/LoadModule php4_module/gi" $apacheconffile.gforge-new
+                               perl -pi -e "s/# *LoadModule 
ssl_module/LoadModule ssl_module/gi" $apacheconffile.gforge-new
+                               perl -pi -e "s/# *LoadModule 
env_module/LoadModule env_module/gi" $apacheconffile.gforge-new
+                               perl -pi -e "s/# *LoadModule 
vhost_alias_module/LoadModule vhost_alias_module/gi" $apacheconffile.gforge-new
            
-           if ! grep -q "^Include $etcgforge/httpd.conf" 
$etcapache/httpd.conf.gforge-new ; then
-               echo "### Next line inserted by GForge install" >> 
$etcapache/httpd.conf.gforge-new
-               echo "Include $etcgforge/httpd.conf" >> 
$etcapache/httpd.conf.gforge-new
-           fi
-       fi
-
+                               if ! grep -q "^Include $gforgeconffile" 
$apacheconffile.gforge-new ; then
+                                       echo "### Next line inserted by GForge 
install" >> $apacheconffile.gforge-new
+                                       echo "Include $gforgeconffile" >> 
$apacheconffile.gforge-new
+                               fi
+                       fi
+               fi
+       done
        # Make sure pgsql, ldap and gd are enabled in the PHP config files
-       cp -a $etcphp4apache/php.ini $etcphp4apache/php.ini.gforge-new
-       cp -a $etcphp4cgi/php.ini $etcphp4cgi/php.ini.gforge-new
-       if [ -f $etcphp4apache/php.ini.gforge-new ]; then
-           if ! grep -q 
"^[[:space:]]*extension[[:space:]]*=[[:space:]]*pgsql.so" 
$etcphp4apache/php.ini.gforge-new; then
-               echo "Enabling pgsql in $etcphp4apache/php.ini"
-               echo "extension=pgsql.so" >> $etcphp4apache/php.ini.gforge-new
-           fi
-           if ! grep -q "^[[:space:]]*extension[[:space:]]*=[[:space:]]*gd.so" 
$etcphp4apache/php.ini.gforge-new; then
-               echo "Enabling gd in $etcphp4apache/php.ini"
-               echo "extension=gd.so" >> $etcphp4apache/php.ini.gforge-new
-           fi
-           if ! grep -q 
"^[[:space:]]*extension[[:space:]]*=[[:space:]]*ldap.so" 
$etcphp4apache/php.ini.gforge-new; then
-               echo "Enabling ldap in $etcphp4apache/php.ini"
-               echo "extension=ldap.so" >> $etcphp4apache/php.ini.gforge-new
-           fi
-       fi
-       if [ -f $etcphp4cgi/php.ini.gforge-new ]; then
-           if ! grep -q 
"^[[:space:]]*extension[[:space:]]*=[[:space:]]*pgsql.so" 
$etcphp4cgi/php.ini.gforge-new; then
-               echo "Enabling pgsql in $etcphp4cgi/php.ini"
-               echo "extension=pgsql.so" >> $etcphp4cgi/php.ini.gforge-new
-           fi
-       fi
-
+       for phpconffile in $PHP_ETC_LIST
+       do
+               cp -a $phpconffile $phpconffile.gforge-new
+               if [ -f $etcphp4apache/php.ini.gforge-new ]; then
+                       if ! grep -q 
"^[[:space:]]*extension[[:space:]]*=[[:space:]]*pgsql.so" 
$phpconffile.gforge-new; then
+                               echo "Enabling pgsql in $phpconffile"
+                               echo "extension=pgsql.so" >> 
$phpconffile.gforge-new
+                       fi
+                       if ! grep -q 
"^[[:space:]]*extension[[:space:]]*=[[:space:]]*gd.so" $phpconffile.gforge-new; 
then
+                               echo "Enabling gd in $phpconffile"
+                               echo "extension=gd.so" >> 
$phpconffile.gforge-new
+                       fi
+                       if ! grep -q 
"^[[:space:]]*extension[[:space:]]*=[[:space:]]*ldap.so" 
$phpconffile.gforge-new; then
+                               echo "Enabling ldap in $phpconffile"
+                               echo "extension=ldap.so" >> 
$phpconffile.gforge-new
+                       fi
+               fi
+       done
        ;;
+       
     configure)
        [ -f $gforgebin/prepare-vhosts-file.pl ] && 
$gforgebin/prepare-vhosts-file.pl
        if [ -f /usr/sbin/modules-config ] ; then
-               if [ -e /etc/apache/httpd.conf ] ; then
-                       /usr/sbin/modules-config apache enable mod_php4
-                       /usr/sbin/modules-config apache enable mod_ssl
-                       /usr/sbin/modules-config apache enable mod_env
-                       /usr/sbin/modules-config apache enable mod_vhost_alias
-               fi
-               if [ -e /etc/apache-ssl/httpd.conf ] ; then
-                       /usr/sbin/modules-config apache-ssl enable mod_php4
-                       /usr/sbin/modules-config apache-ssl enable mod_env
-                       /usr/sbin/modules-config apache-ssl enable 
mod_vhost_alias
-               fi
-       fi
-       if [ -x /usr/sbin/apache ]; then
-               invoke-rc.d apache restart || true
-       fi
-       if [ -x /usr/sbin/apache-ssl ]; then
-               invoke-rc.d apache-ssl restart || true
-       fi
-       if [ -x /usr/sbin/apache ]; then
-               invoke-rc.d apache restart || true
-       fi
-       if [ -x /usr/sbin/apache-ssl ]; then
-               invoke-rc.d apache-ssl restart || true
+               for flavour in apache apache-perl apache-ssl ; do
+                       if [ -e /etc/$flavour/httpd.conf ] ; then
+                               /usr/sbin/modules-config $flavour enable 
mod_php4
+                               if [ $flavour != apache-ssl ] ; then
+                                       /usr/sbin/modules-config $flavour 
enable mod_ssl
+                               fi
+                               /usr/sbin/modules-config $flavour enable mod_env
+                               /usr/sbin/modules-config $flavour enable 
mod_vhost_alias
+
+                               if [ -d /etc/$flavour/conf.d ] ; then
+                                       [ ! -e 
/etc/$flavour/conf.d/gforge.httpd.conf ] && ln -s /etc/gforge/httpd.conf 
/etc/$flavour/conf.d/gforge.httpd.conf
+                               fi
+                       fi
+                       if [ -x /usr/sbin/$flavour ]; then
+                               invoke-rc.d $flavour restart || true
+                       fi
+               done
        fi
        ;;
 
     purge-files)
-       cp -a $etcapache/httpd.conf $etcapache/httpd.conf.gforge-new
-       if grep -q "Include $etcgforge/httpd.conf" 
$etcapache/httpd.conf.gforge-new ; then
-           pattern=$(basename $0)
-           tmp=$(mktemp /tmp/$pattern.XXXXXX)
-           grep -v "Include $etcgforge/httpd.conf\|### Next line inserted by 
GForge install" $etcapache/httpd.conf.gforge-new > $tmp
-           cat $tmp > $etcapache/httpd.conf.gforge-new
-           rm -f $tmp
-       fi
+       for apacheconffile in $APACHE_ETC_LIST
+       do
+               if [ -e $apacheconffile ] && grep -q "Include $gforgeconffile" 
$apacheconffile ; then
+                       cp -a $apacheconffile $apacheconffile.gforge-new
+                       pattern=$(basename $0)
+                       tmp=$(mktemp /tmp/$pattern.XXXXXX)
+                       grep -v "Include $gforgeconffile\|### Next line 
inserted by GForge install" $apacheconffile.gforge-new > $tmp
+                       cat $tmp > $apacheconffile.gforge-new
+                       rm -f $tmp
+               fi
+       done
        ;;
+
     purge)
-       if [ -x /usr/sbin/apache ]; then
-               invoke-rc.d apache restart || true
-       fi
-       if [ -x /usr/sbin/apache-ssl ]; then
-               invoke-rc.d apache-ssl restart || true
-       fi
+       for flavour in apache apache-perl apache-ssl ; do
+               [ ! -e /etc/$flavour/conf.d/gforge.httpd.conf ] && rm -f 
/etc/$flavour/conf.d/gforge.httpd.conf
+               if [ -x /usr/sbin/$flavour ]; then
+                       invoke-rc.d $flavour restart || true
+               fi
+       done
        ;;
+
     setup)
        $0 configure-files
+       for apacheconffile in $APACHE_ETC_LIST
+       do
+               cp $apacheconffile $apacheconffile.gforge-old
+               mv $apacheconffile.gforge-new $apacheconffile
+       done
        $0 configure
-       cp $etcapache/httpd.conf $etcapache/httpd.conf.gforge-old
-       mv $etcapache/httpd.conf.gforge-new $etcapache/httpd.conf
        ;;
+
     cleanup)
        $0 purge-files
+       for apacheconffile in $APACHE_ETC_LIST
+       do
+               cp $apacheconffile $apacheconffile.gforge-old
+               mv $apacheconffile.gforge-new $apacheconffile
+       done
        $0 purge
        ;;
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]