[evolvis-commits] r7524: Added dpkg-like stuff to ask whether to replace a config file before↵ doing it?=.=?UTF-8?Q?↵

mirabilos at evolvis.org mirabilos at evolvis.org
Thu Feb 24 15:42:55 CET 2011


Author: mirabilos
Date: 2011-02-24 15:42:54 +0100 (Thu, 24 Feb 2011)
New Revision: 7524

Modified:
   trunk/gforge_base/evolvisforge-5.1/gforge/deb-specific/install-apache.sh
   trunk/gforge_base/evolvisforge-5.1/gforge/debian/changelog
Log:
Added dpkg-like stuff to ask whether to replace a config file before
doing it.


Modified: trunk/gforge_base/evolvisforge-5.1/gforge/deb-specific/install-apache.sh
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/deb-specific/install-apache.sh	2011-02-24 14:42:54 UTC (rev 7523)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/deb-specific/install-apache.sh	2011-02-24 14:42:54 UTC (rev 7524)
@@ -12,19 +12,74 @@
     exec su -c "$0 $1"
 fi
 
+replace_file () {
+    file=$1
+    cp $file ${file}.sourceforge-old
+    mv ${file}.sourceforge-new $file
+}
+
+propose_update () {
+    file=$1
+    if diff -q ${file} ${file}.sourceforge-new &> /dev/null ; then
+	# Old file and new file are identical
+	rm -f ${file}.sourceforge-new
+    else
+	done=NO
+	while [ "X$done" = "XNO" ]; do
+	    cat >&2 <<EOPRMT
+Configuration file \`$file':
+Installing Sourceforge requires modifications in this file.
+   What would you like to do about it ?  Your options are:
+    Y or I  : automatically preform these changes
+    N or O  : keep your currently version
+      D     : show the differences between the versions
+      Z     : start a new shell to examine the situation
+ The default action is to keep your current version.
+EOPRMT
+	    echo -n >&2 "Automatically change $file (Y/I/N/O/D/Z) [default=N] ?"
+	    read -e ANSWER;
+	    case "$ANSWER" in
+		y|Y|I|i)
+		    echo >&2 "Replacing file $file with changed version"
+		    replace_file $file
+		    done=YES
+		    ;;
+		D|d)
+		    diff -uBbw "$file" "${file}.sourceforge-new" | sensible-pager
+		    ;;
+		Z|z)
+		    bash
+		    ;;
+		n|N|o|O)
+		    # Do nothing
+		    done=YES
+		    exit 0;
+		    ;;
+		*)
+		    # Do nothing
+		    done=YES
+		    exit 0;
+	    esac
+	done
+    fi
+}
+
 case "$1" in
     configure)
 	# Make sure Apache sees us
-	perl -pi -e "s/# *LoadModule php4_module/LoadModule php4_module/gi" /etc/apache/httpd.conf
-	perl -pi -e "s/# *LoadModule ssl_module/LoadModule ssl_module/gi" /etc/apache/httpd.conf
-	perl -pi -e "s/# *LoadModule apache_ssl_module/LoadModule apache_ssl_module/gi" /etc/apache/httpd.conf
-	perl -pi -e "s/# *LoadModule env_module/LoadModule env_module/gi" /etc/apache/httpd.conf
-	perl -pi -e "s/# *LoadModule vhost_alias_module/LoadModule vhost_alias_module/gi" /etc/apache/httpd.conf
+	cp -a /etc/apache/httpd.conf /etc/apache/httpd.conf.sourceforge-new
+	perl -pi -e "s/# *LoadModule php4_module/LoadModule php4_module/gi" /etc/apache/httpd.conf.sourceforge-new
+	perl -pi -e "s/# *LoadModule ssl_module/LoadModule ssl_module/gi" /etc/apache/httpd.conf.sourceforge-new
+	perl -pi -e "s/# *LoadModule apache_ssl_module/LoadModule apache_ssl_module/gi" /etc/apache/httpd.conf.sourceforge-new
+	perl -pi -e "s/# *LoadModule env_module/LoadModule env_module/gi" /etc/apache/httpd.conf.sourceforge-new
+	perl -pi -e "s/# *LoadModule vhost_alias_module/LoadModule vhost_alias_module/gi" /etc/apache/httpd.conf.sourceforge-new
 	
-	if ! grep -q "^Include /etc/sourceforge/sf-httpd.conf" /etc/apache/httpd.conf ; then
-	    echo "### Next line inserted by Sourceforge install" >> /etc/apache/httpd.conf
-	    echo "Include /etc/sourceforge/sf-httpd.conf" >> /etc/apache/httpd.conf
+	if ! grep -q "^Include /etc/sourceforge/sf-httpd.conf" /etc/apache/httpd.conf.sourceforge-new ; then
+	    echo "### Next line inserted by Sourceforge install" >> /etc/apache/httpd.conf.sourceforge-new
+	    echo "Include /etc/sourceforge/sf-httpd.conf" >> /etc/apache/httpd.conf.sourceforge-new
 	fi
+
+	propose_update /etc/apache/httpd.conf
 	
 	# Make sure pgsql,ldap and gd are enabled in the PHP config files
 	if [ -f /etc/php4/apache/php.ini ]; then

Modified: trunk/gforge_base/evolvisforge-5.1/gforge/debian/changelog
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/debian/changelog	2011-02-24 14:42:54 UTC (rev 7523)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/debian/changelog	2011-02-24 14:42:54 UTC (rev 7524)
@@ -1,8 +1,11 @@
 sourceforge (2.6-0+6+) unstable; urgency=low
 
   * [Roland] [From 2.5] Added templates to conffiles.
+  * [Roland] Added dpkg-like stuff to ask whether to replace a config file
+    before doing it.  Only for installation of /etc/apache/httpd.conf for
+    now (more will follow).
 
- -- Roland Mas <lolando at debian.org>  Thu, 14 Feb 2002 18:37:28 +0100
+ -- Roland Mas <lolando at debian.org>  Sat, 16 Feb 2002 17:35:41 +0100
 
 sourceforge (2.6-0+6) unstable; urgency=low
 



More information about the evolvis-commits mailing list