[Webapps-common-discuss] [commit] r82 - in trunk: . debian debian/po dpkg examples/webapp-apache-dbapp-example/debian templates

Sean Finney seanius at costa.debian.org
Mon May 15 23:12:51 UTC 2006


Author: seanius
Date: 2006-05-15 23:12:50 +0000 (Mon, 15 May 2006)
New Revision: 82

Modified:
   trunk/TODO
   trunk/debian/changelog
   trunk/debian/po/templates.pot
   trunk/debian/webapps-common.templates
   trunk/dpkg/common
   trunk/dpkg/config
   trunk/dpkg/postinst
   trunk/dpkg/postrm
   trunk/dpkg/prerm
   trunk/examples/webapp-apache-dbapp-example/debian/postrm
   trunk/examples/webapp-apache-dbapp-example/debian/prerm
   trunk/templates/apache-virtualhost.conf
   trunk/templates/apache2-wc-master.conf
   trunk/templates/virtualhosts.conf
Log:
slight tweak to webapp+dbapp example

Modified: trunk/TODO
===================================================================
--- trunk/TODO	2006-05-15 22:50:51 UTC (rev 81)
+++ trunk/TODO	2006-05-15 23:12:50 UTC (rev 82)
@@ -2,16 +2,20 @@
 
 - "default" isn't really the right name for the default virtual host
   choice.  maybe "global" would be better because it's not the "default
-  host", but "all hosts" (those that include conf.d?).
+  host", but "all hosts" (those that include conf.d?). or maybe default
+  is best after all, because we don't reallyknow what happens when
+  we just drop the configuration in conf.d...
 
-- newly selected virtualhosts don't seem to be updating
-  /etc/webapps-common/virtualhosts.conf
-
-- we should probably prompt whether to reload the web servers
-
 - handling pre-existing virtualhosts.  currently we end up with duplicate
   configs...
 
+- finish dbconfig-common integration:
+  - currently the package has to set dbc_dbtype in each maintainer
+    script, which is a bit sub-optimal imo.
+  - multi-instance support, which may need to rely on multi-instance
+    support from dbconfig-common, and will certainly at the least
+	involve some more thought/planning
+
 further ahead:
 
 - there are some tasks which would probably do best to be abstracted into

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2006-05-15 22:50:51 UTC (rev 81)
+++ trunk/debian/changelog	2006-05-15 23:12:50 UTC (rev 82)
@@ -7,6 +7,9 @@
   * updated examples to be generally better examples
   * fix for disabling application instances (wc_disable_instance)
   * make sure virtualhost templates are correct
+  * make sure cut expressions inlcude -s where appropriate
+  * initial support for integration with dbconfig-common(!).  currently,
+    this only works for single-instance installs.
 
  -- sean finney <seanius at debian.org>  Tue, 09 May 2006 23:47:15 +0200
 

Modified: trunk/debian/po/templates.pot
===================================================================
--- trunk/debian/po/templates.pot	2006-05-15 22:50:51 UTC (rev 81)
+++ trunk/debian/po/templates.pot	2006-05-15 23:12:50 UTC (rev 82)
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: seanius at debian.org\n"
-"POT-Creation-Date: 2006-05-14 16:00-0500\n"
+"POT-Creation-Date: 2006-05-15 14:24-0500\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
 "Language-Team: LANGUAGE <LL at li.org>\n"
@@ -198,3 +198,18 @@
 #: ../webapps-common.templates:97
 msgid "Please provide the subdirectory for ${pkg} on ${vhost}"
 msgstr ""
+
+#. Type: multiselect
+#. Description
+#: ../webapps-common.templates:102
+msgid "Select the web servers to reload."
+msgstr ""
+
+#. Type: multiselect
+#. Description
+#: ../webapps-common.templates:102
+msgid ""
+"Due to configuration changes, some of your webservers may need to be "
+"reloaded.  You may de-select servers from the given list if you do not wish "
+"to do so now."
+msgstr ""

Modified: trunk/debian/webapps-common.templates
===================================================================
--- trunk/debian/webapps-common.templates	2006-05-15 22:50:51 UTC (rev 81)
+++ trunk/debian/webapps-common.templates	2006-05-15 23:12:50 UTC (rev 82)
@@ -95,3 +95,11 @@
 Template: webapps-common/httpd/website_subdirectory
 Type: string
 _Description: Please provide the subdirectory for ${pkg} on ${vhost}
+
+Template: webapps-common/httpd/reload
+Type: multiselect
+Choices: ${httpds}
+_Description: Select the web servers to reload.
+ Due to configuration changes, some of your webservers may need to be
+ reloaded.  You may de-select servers from the given list if you do
+ not wish to do so now.

Modified: trunk/dpkg/common
===================================================================
--- trunk/dpkg/common	2006-05-15 22:50:51 UTC (rev 81)
+++ trunk/dpkg/common	2006-05-15 23:12:50 UTC (rev 82)
@@ -42,7 +42,7 @@
 
 	# standard templates provided by webapps-common, which will have copies
 	# registered with the package in question.
-	wc_standard_templates="webapps_install httpd/instances httpd/instances_previous httpd/website_subdirectory httpd/select_httpd install_error httpd/virtualhost httpd/virtualhost_new"
+	wc_standard_templates="webapps_install httpd/instances httpd/instances_previous httpd/website_subdirectory httpd/select_httpd install_error httpd/virtualhost httpd/virtualhost_new httpd/reload"
 	wc_register_templates=$wc_standard_templates
 
 	###
@@ -54,6 +54,12 @@
 
 	# webserver-specific section?
 
+	# little dbc hook for debugging
+	if [ "$wc_dbapp" ]; then
+		if [ "$wc_debug" ]; then
+			dbc_debug="$wc_debug"
+		fi
+	fi
 }
 
 ###
@@ -69,8 +75,11 @@
 		old_vhost_list=`_wc_list_create $old_vhost_list`
 		cp "$wc_vhostconfig" "$tfile"
 	fi
-	db_metaget $wc_package/httpd/virtualhost virtualhosts && vhost_list="$RET"
-	vhost_list=`_wc_list_remove "$vhost_list" 'new vhost'`
+	# XXX isn't working and i'm not sure why, so i'll try a different method
+	#db_metaget $wc_package/httpd/virtualhost virtualhosts && vhost_list="$RET"
+	# XXX so we do it this way instead which works as long as config was dumped
+	vhost_list=`grep -v '^[[:space:]]*#' $wc_pkgconfig | cut -sf1 | cut -d / -f1`
+	vhost_list=`_wc_list_remove "$vhost_list" '=global='`
 	for v in `_wc_list_explode "$vhost_list"`; do
 		if ! _wc_list_is_member "$old_vhost_list" "$v"; then
 			echo $v >> "$tfile"
@@ -150,6 +159,12 @@
 	# finally, detect the list of servers which need to be reloaded.
 	if [ "$reload_list" ]; then
 		_wc_debug "the following servers need to be reloaded: ${reload_list}."
+		db_subst $wc_package/httpd/reload httpds "$reload_list"
+		db_set $wc_package/httpd/reload "$reload_list"
+		db_input medium $wc_package/httpd/reload || true
+		db_go || true
+		db_get $wc_package/httpd/reload && reload_list=$RET
+		reload_list=`_wc_list_explode $reload_list`
     	wc_httpd_invoke reload `wc_httpd_running $reload_list` || true
 	fi
 }
@@ -283,12 +298,10 @@
 		debconf_dest="$wc_package/sites/$instance"
 	fi
 
-	if ! db_get "$debconf_dest/httpd/website_subdirectory"; then
-		for f in $wc_register_templates; do
-			db_register "webapps-common/$f" "$debconf_dest/$f"
-		done
-		db_set $wc_package/httpd/website_subdirectory $wc_package
-	fi
+	for f in $wc_register_templates; do
+		db_register "webapps-common/$f" "$debconf_dest/$f"
+	done
+	db_set $wc_package/httpd/website_subdirectory $wc_package
 
 	# perform some basic customizing substitutions
 	for f in $wc_register_templates; do
@@ -362,7 +375,7 @@
 
 	# get the list of virtualhosts for which this app is configured
 	if [ -f "$wc_pkgconfig" ]; then
-		instances=`grep -vE '^[[:space:]]*#' "$wc_pkgconfig" | cut -f1`
+		instances=`grep -vE '^[[:space:]]*#' "$wc_pkgconfig" | cut -sf1`
 		instances=`_wc_list_create $instances`
 		_wc_debug "preseeding previously configured instances: $instances"
 		db_subst $wc_package/httpd/instances instances $instances
@@ -411,7 +424,7 @@
 	# otherwise, fill in the blanks using the contents of the config
 
 	idir=`echo $instance | cut -sd/ -f2`
-	httpds=`grep -E $grep_expr $wc_pkgconfig | cut -f2-`
+	httpds=`grep -E $grep_expr $wc_pkgconfig | cut -sf2-`
 
 	db_set $debconf_dest/httpd/website_subdirectory $idir
 	db_set $debconf_dest/httpd/select_httpd "$httpds"
@@ -455,7 +468,7 @@
 	local instance httpds h app_link
 	_wc_debug "wc_disable_instance() $@"
 	instance=$1
-	httpds=`grep "^$instance[[:space:]]" $wc_pkgconfig | cut -f2-`
+	httpds=`grep "^$instance[[:space:]]" $wc_pkgconfig | cut -sf2-`
 
 	for h in `_wc_list_explode "$httpds"`; do
 		app_link=`_wc_instance_cfg_link "$instance" "$h"`
@@ -477,7 +490,7 @@
 	local instance httpds h app_link
 	_wc_debug "wc_purge_instance() $@"
 	instance=$1
-	httpds=`grep "^$instance[[:space:]]" $wc_pkgconfig | cut -f2-`
+	httpds=`grep "^$instance[[:space:]]" $wc_pkgconfig | cut -sf2-`
 
 	for h in `_wc_list_explode "$httpds"`; do
 		app_file=`_wc_instance_cfg_file "$instance" "$h"`

Modified: trunk/dpkg/config
===================================================================
--- trunk/dpkg/config	2006-05-15 22:50:51 UTC (rev 81)
+++ trunk/dpkg/config	2006-05-15 23:12:50 UTC (rev 82)
@@ -29,10 +29,23 @@
 	fi
 
 	# state 200 - prompt them for the list of configured instances
-	while wc_config_select_more_instances; do true; done
+	if [ "$wc_multiple_instances" ]; then
+		while wc_config_select_more_instances; do true; done
+	else
+		wc_config_select_single_instance
+	fi
 
 	# let's stop here for now.
 	db_go || true
+
+	# no, now let's do the dbconfig-support
+	if [ ! "$wc_multiple_instances" ]; then
+		if [ "$wc_dbapp" ]; then
+			_wc_debug "configuring db support"
+			. /usr/share/dbconfig-common/dpkg/config
+			dbc_go $@
+		fi
+	fi
 }
 
 # select another instance for configuring a webapp.  returns non-zero when
@@ -85,6 +98,45 @@
 	db_go || true
 }
 
+# select a single instance for configuring a webapp.  
+wc_config_select_single_instance(){
+	local oldvhosts selected_instances vhost vdir instance 
+	_wc_debug "wc_config_select_single_instance() $@"
+
+	db_input high $wc_package/httpd/virtualhost || true
+	db_go || true
+	db_get $wc_package/httpd/virtualhost && vhost="$RET"
+
+	if [ "$vhost" = "new vhost" ]; then
+		db_metaget $wc_package/httpd/virtualhost virtualhosts && oldvhosts="$RET"
+		db_input high $wc_package/httpd/virtualhost_new || true
+		db_go || true
+		db_get $wc_package/httpd/virtualhost_new && vhost="$RET"
+		oldvhosts=`_wc_list_add "$oldvhosts" "$vhost"`
+		db_subst $wc_package/httpd/virtualhost virtualhosts "$oldvhosts"
+		db_set $wc_package/httpd/virtualhost $vhost
+	fi
+
+	db_subst $wc_package/httpd/website_subdirectory vhost $vhost
+	db_input high $wc_package/httpd/website_subdirectory || true
+	db_go || true
+	db_get $wc_package/httpd/website_subdirectory && vdir="$RET"
+
+	instance="$vhost"
+	if [ "$vdir" ]; then
+		instance="$instance/$vdir"
+	fi
+
+	wc_register_debconf "$instance"
+	wc_preseed_debconf_instance "$instance"
+	wc_config_select_instance_httpds "$instance"
+
+	selected_instances=$instance
+	db_subst $wc_package/httpd/instances instances $selected_instances
+	db_set $wc_package/httpd/instances $selected_instances
+	db_go || true
+}
+
 ###
 ###	choose the servers and directory for a particular instance
 ###

Modified: trunk/dpkg/postinst
===================================================================
--- trunk/dpkg/postinst	2006-05-15 22:50:51 UTC (rev 81)
+++ trunk/dpkg/postinst	2006-05-15 23:12:50 UTC (rev 82)
@@ -29,6 +29,7 @@
 		# of debconf's cache, to make sure we're not doing any evil
 		# "Debconf Is Not A Registry(tm)" stuff.
 		wc_forget_debconf
+		wc_postinst_dbapp_support $@
 	fi
 }
 
@@ -53,3 +54,11 @@
 		wc_httpd_invoke reload `wc_httpd_running $reload_list` || true
 	fi
 }
+
+wc_postinst_dbapp_support(){
+	if [ "$wc_dbapp" ]; then
+		. /usr/share/dbconfig-common/dpkg/postinst
+		dbc_go $@
+	fi
+}
+

Modified: trunk/dpkg/postrm
===================================================================
--- trunk/dpkg/postrm	2006-05-15 22:50:51 UTC (rev 81)
+++ trunk/dpkg/postrm	2006-05-15 23:12:50 UTC (rev 82)
@@ -17,20 +17,37 @@
 	if [ "$wc_command" = "purge" ]; then
 		wc_postrm_purge_app
 	fi
+
+	# no, now let's do the dbconfig-support
+	if [ ! "$wc_multiple_instances" ]; then
+		if [ "$wc_dbapp" ]; then
+			. /usr/share/dbconfig-common/dpkg/postrm
+			dbc_go $@
+		fi
+	fi
 }
 
 wc_postrm_disable_app(){
-	local instance httpds reload_list
+	local instances instance httpds reload_list
 	_wc_debug "wc_postrm_disable_app() $@"
 
 	# for each configuration line in the file
-	grep -vE '^[[:space:]]*(#|$)' "$wc_pkgconfig" | cut -f1 | while read instance; do
-		httpds=`grep "^$instance[[:space:]]" "$wc_pkgconfig" | cut -f2`
+	instances=`grep -vE '^[[:space:]]*(#|$)' "$wc_pkgconfig" | cut -sf1`
+
+	for instance in $instances; do
 		wc_disable_instance "$instance"
+		httpds=`grep "^$instance[[:space:]]" "$wc_pkgconfig" | cut -sf2`
 		reload_list=`_wc_list_join "$reload_list" "$httpds"`
 	done
 
 	_wc_debug "need to reload the following servers: ${reload_list}."
+	wc_register_debconf
+	db_subst $wc_package/httpd/reload httpds "$reload_list"
+	db_set $wc_package/httpd/reload "$reload_list"
+	db_input medium $wc_package/httpd/reload || true
+	db_go || true
+	db_get $wc_package/httpd/reload && reload_list=$RET
+	reload_list=`_wc_list_explode $reload_list`
 	wc_httpd_invoke reload `wc_httpd_running $reload_list` || true
 }
 
@@ -39,7 +56,7 @@
 	_wc_debug "wc_postrm_purge_app() $@"
 
 	# for each configuration line in the file
-	grep -vE '^[[:space:]]*(#|$)' "$wc_pkgconfig" | cut -f1 | while read instance; do
+	grep -vE '^[[:space:]]*(#|$)' "$wc_pkgconfig" | cut -sf1 | while read instance; do
 		wc_purge_instance "$instance"
 	done
 	ucf --purge "$wc_pkgconfig"

Modified: trunk/dpkg/prerm
===================================================================
--- trunk/dpkg/prerm	2006-05-15 22:50:51 UTC (rev 81)
+++ trunk/dpkg/prerm	2006-05-15 23:12:50 UTC (rev 82)
@@ -5,4 +5,11 @@
     _wc_debug "(prerm) wc_go() $@"
 	# wc_config $@
 
+    # no, now let's do the dbconfig-support
+    if [ ! "$wc_multiple_instances" ]; then
+        if [ "$wc_dbapp" ]; then
+            . /usr/share/dbconfig-common/dpkg/prerm
+            dbc_go $@
+        fi
+    fi
 }

Modified: trunk/examples/webapp-apache-dbapp-example/debian/postrm
===================================================================
--- trunk/examples/webapp-apache-dbapp-example/debian/postrm	2006-05-15 22:50:51 UTC (rev 81)
+++ trunk/examples/webapp-apache-dbapp-example/debian/postrm	2006-05-15 23:12:50 UTC (rev 82)
@@ -5,6 +5,7 @@
 . /usr/share/debconf/confmodule
 . /usr/share/webapps-common/dpkg/postrm
 wc_dbapp="yes"
+dbc_dbtype="mysql"
 wc_go webapp-apache-dbapp-example $@
 
 #DEBHELPER#

Modified: trunk/examples/webapp-apache-dbapp-example/debian/prerm
===================================================================
--- trunk/examples/webapp-apache-dbapp-example/debian/prerm	2006-05-15 22:50:51 UTC (rev 81)
+++ trunk/examples/webapp-apache-dbapp-example/debian/prerm	2006-05-15 23:12:50 UTC (rev 82)
@@ -5,6 +5,7 @@
 . /usr/share/debconf/confmodule
 . /usr/share/webapps-common/dpkg/prerm
 wc_dbapp="yes"
+dbc_dbtype="mysql"
 wc_go webapp-apache-dbapp-example $@
 
 #DEBHELPER#

Modified: trunk/templates/apache-virtualhost.conf
===================================================================
--- trunk/templates/apache-virtualhost.conf	2006-05-15 22:50:51 UTC (rev 81)
+++ trunk/templates/apache-virtualhost.conf	2006-05-15 23:12:50 UTC (rev 82)
@@ -1,4 +1,3 @@
-NameVirtualHost *
 <VirtualHost _WC_VHOST_>
 	Include /etc/webapps-common/apps-enabled/_WC_HTTPD_/_WC_VHOST_/*.conf
 </VirtualHost>

Modified: trunk/templates/apache2-wc-master.conf
===================================================================
--- trunk/templates/apache2-wc-master.conf	2006-05-15 22:50:51 UTC (rev 81)
+++ trunk/templates/apache2-wc-master.conf	2006-05-15 23:12:50 UTC (rev 82)
@@ -2,4 +2,5 @@
 # this file is responsible for instructing HTTPD to load all
 # application configuration files for packages configured via
 # webapps-common.
+NameVirtualHost *
 Include /etc/webapps-common/apps-enabled/HTTPD/=global=/*.conf

Modified: trunk/templates/virtualhosts.conf
===================================================================
--- trunk/templates/virtualhosts.conf	2006-05-15 22:50:51 UTC (rev 81)
+++ trunk/templates/virtualhosts.conf	2006-05-15 23:12:50 UTC (rev 82)
@@ -2,5 +2,5 @@
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 # this file contains a list of the virtualhosts available to applications
 # during installation/reconfiguration.  you can feel free to add
-# more here (one per line), or add them by selecting '@new vhost@'
+# more here (one per line), or add them by selecting 'new vhost'
 # during installation/configuration.




More information about the Webapps-common-discuss mailing list