[Webapps-common-discuss] [commit] r78 - in trunk: debian debian/po
doc dpkg internal templates
Sean Finney
seanius at costa.debian.org
Sun May 14 20:16:03 UTC 2006
Author: seanius
Date: 2006-05-14 20:16:02 +0000 (Sun, 14 May 2006)
New Revision: 78
Modified:
trunk/debian/changelog
trunk/debian/po/templates.pot
trunk/debian/webapps-common.templates
trunk/doc/webapps-common.sgml
trunk/dpkg/common
trunk/dpkg/config
trunk/dpkg/postinst
trunk/dpkg/postrm
trunk/dpkg/prerm
trunk/internal/common
trunk/templates/apache2-wc-master.conf
trunk/templates/virtualhosts.conf
Log:
multi-instance support even on the same vhost
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2006-05-09 17:22:01 UTC (rev 77)
+++ trunk/debian/changelog 2006-05-14 20:16:02 UTC (rev 78)
@@ -1,3 +1,12 @@
+webapps-common (0.7) UNRELEASED; urgency=low
+
+ [sean finney]
+ * you can now have multiple instances on the same host. this involved
+ a rather large rewrite of code, but much to my surprise and confusement
+ this "feature" resulted in almost 200 lines less of code. go figure.
+
+ -- sean finney <seanius at debian.org> Tue, 09 May 2006 23:47:15 +0200
+
webapps-common (0.6) UNRELEASED; urgency=low
[sean finney]
@@ -3,5 +12,6 @@
* random bugfixes, as always
* support for configuring/deconfiguring instances.
- * moved stuff in the postinst to where it should be.
+ * moved stuff around in the postinst to where it should be.
+ * other misc superficial changes to sgml docs
-- sean finney <seanius at debian.org> Thu, 04 May 2006 01:59:11 +0200
Modified: trunk/debian/po/templates.pot
===================================================================
--- trunk/debian/po/templates.pot 2006-05-09 17:22:01 UTC (rev 77)
+++ trunk/debian/po/templates.pot 2006-05-14 20:16:02 UTC (rev 78)
@@ -16,7 +16,7 @@
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2006-04-25 10:57+0200\n"
+"POT-Creation-Date: 2006-05-10 12:48+0200\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"
@@ -171,86 +171,38 @@
"circumstances, such as if the list of installed webservers change."
msgstr ""
-#. Type: select
-#. Choices
-#: ../webapps-common.templates:79
-msgid "directory, virtualhost + directory, multiple instances"
-msgstr ""
-
-#. Type: select
-#. Description
-#: ../webapps-common.templates:80
-msgid "How should ${pkg} be configured for web access?"
-msgstr ""
-
-#. Type: select
-#. Description
-#: ../webapps-common.templates:80
-msgid ""
-"If you select \"directory\", then you will be simply prompted for the name "
-"of the directory on your web server from which you would like your "
-"application to be available."
-msgstr ""
-
-#. Type: select
-#. Description
-#: ../webapps-common.templates:80
-msgid ""
-"If you select \"virtualhost + directory\", you will also be given the choice "
-"of running your application under a new or pre-existing virtualhost."
-msgstr ""
-
-#. Type: select
-#. Description
-#: ../webapps-common.templates:80
-msgid ""
-"If you select \"multiple instances\", then you will be provided with the "
-"ability to configure multiple virtualhost + directory configurations. For "
-"some applications this may allow a single package to host many independant "
-"instances of itself, which is ideal for situations where you may wish to "
-"provide the same service to multiple groups of users."
-msgstr ""
-
#. Type: string
#. Description
-#: ../webapps-common.templates:97
+#: ../webapps-common.templates:79
msgid "Please enter the name of a new virtualhost."
msgstr ""
-#. Type: string
-#. Description
-#: ../webapps-common.templates:97
-msgid ""
-"Alternatively, for a global instance available over all virtual hosts, enter "
-"the name [default] (including the square brackets)."
-msgstr ""
-
#. Type: select
#. Description
-#: ../webapps-common.templates:104
-msgid "Please select the virtualhost with which to configure ${pkg}"
+#: ../webapps-common.templates:83
+msgid "Please select a virtualhost with which to configure ${pkg}"
msgstr ""
-#. Type: multiselect
+#. Type: select
#. Choices
-#: ../webapps-common.templates:112
-msgid "${vhosts}"
+#: ../webapps-common.templates:84
+msgid "=global=, new vhost, ${virtualhosts}"
msgstr ""
#. Type: multiselect
#. Description
-#: ../webapps-common.templates:113
-msgid "Please select the virtualhosts with which to configure ${pkg}"
+#: ../webapps-common.templates:88
+msgid "Please select the instances to configure for ${pkg}"
msgstr ""
-#. Type: string
-#. Default
-#: ../webapps-common.templates:117
-msgid "${pkg}"
+#. Type: multiselect
+#. Choices
+#: ../webapps-common.templates:93
+msgid "configure new instance, ${instances}"
msgstr ""
#. Type: string
#. Description
-#: ../webapps-common.templates:118
+#: ../webapps-common.templates:97
msgid "Please provide the subdirectory for ${pkg} on \"${vhost}\""
msgstr ""
Modified: trunk/debian/webapps-common.templates
===================================================================
--- trunk/debian/webapps-common.templates 2006-05-09 17:22:01 UTC (rev 77)
+++ trunk/debian/webapps-common.templates 2006-05-14 20:16:02 UTC (rev 78)
@@ -74,45 +74,24 @@
Please note that you may be asked this question again in certain
circumstances, such as if the list of installed webservers change.
-Template: webapps-common/httpd/install_type
-Type: select
-_Choices: directory, virtualhost + directory, multiple instances
-_Description: How should ${pkg} be configured for web access?
- If you select "directory", then you will be simply prompted for the
- name of the directory on your web server from which you would like
- your application to be available.
- .
- If you select "virtualhost + directory", you will also be given the
- choice of running your application under a new or pre-existing
- virtualhost.
- .
- If you select "multiple instances", then you will be provided with the
- ability to configure multiple virtualhost + directory configurations.
- For some applications this may allow a single package to host many
- independant instances of itself, which is ideal for situations where
- you may wish to provide the same service to multiple groups of users.
-
Template: webapps-common/httpd/virtualhost_new
Type: string
_Description: Please enter the name of a new virtualhost.
- Alternatively, for a global instance available over all virtual hosts,
- enter the name [default] (including the square brackets).
-Template: webapps-common/httpd/virtualhost_single
+Template: webapps-common/httpd/virtualhost
Type: select
-_Choices: ${vhosts}
-_Description: Please select the virtualhost with which to configure ${pkg}
+_Description: Please select a virtualhost with which to configure ${pkg}
+_Choices: =global=, new vhost, ${virtualhosts}
-Template: webapps-common/httpd/virtualhost_previous
+Template: webapps-common/httpd/instances
Type: multiselect
-_Choices: ${vhosts}
+_Description: Please select the instances to configure for ${pkg}
+_Choices: configure new instance, ${instances}
-Template: webapps-common/httpd/virtualhost
+Template: webapps-common/httpd/instances_previous
Type: multiselect
-_Choices: ${vhosts}
-_Description: Please select the virtualhosts with which to configure ${pkg}
+_Choices: configure new instance, ${instances}
Template: webapps-common/httpd/website_subdirectory
Type: string
-_Default: ${pkg}
_Description: Please provide the subdirectory for ${pkg} on "${vhost}"
Modified: trunk/doc/webapps-common.sgml
===================================================================
--- trunk/doc/webapps-common.sgml 2006-05-09 17:22:01 UTC (rev 77)
+++ trunk/doc/webapps-common.sgml 2006-05-14 20:16:02 UTC (rev 78)
@@ -21,7 +21,7 @@
important to provide a common infrastructure for how these
applications should behave.
<p>
- webapps-common aims to fill this niche, by providing a centralized
+ webapps-common fills this niche by providing a centralized
set of tools and procedures for configuring web applications,
webserver extensions, and other packages related to the world
of web applications.
@@ -38,8 +38,6 @@
variable substitution into maintainer-supplied templates
<item>NOTYET: integrated support for database applications
via dbconfig-common (dbc needs manydb support)
- <item>import configs from packages previously managing databases
- on their own
<item>prompt users with a set of normalized, pre-translated questions
<item>NOTYET: handle failures gracefully, with an option to retry.
<item>work for package maintainers with little effort on their part
Modified: trunk/dpkg/common
===================================================================
--- trunk/dpkg/common 2006-05-09 17:22:01 UTC (rev 77)
+++ trunk/dpkg/common 2006-05-14 20:16:02 UTC (rev 78)
@@ -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/install_type httpd/website_subdirectory httpd/select_httpd install_error httpd/virtualhost httpd/virtualhost_single httpd/virtualhost_previous 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"
wc_register_templates=$wc_standard_templates
###
@@ -69,8 +69,8 @@
old_vhost_list=`_wc_list_create $old_vhost_list`
cp "$wc_vhostconfig" "$tfile"
fi
- db_metaget $wc_package/httpd/virtualhost choices && vhost_list="$RET"
- vhost_list=`_wc_list_remove "$vhost_list" '\[new vhost\]'`
+ db_metaget $wc_package/httpd/virtualhost virtualhosts && vhost_list="$RET"
+ vhost_list=`_wc_list_remove "$vhost_list" 'new vhost'`
for v in `_wc_list_explode "$vhost_list"`; do
if ! _wc_list_is_member "$old_vhost_list" "$v"; then
echo $v >> "$tfile"
@@ -105,56 +105,50 @@
### dump package configuration to a config file
###
wc_write_package_httpd_configs(){
- local tmpconf tmpconf2 output vhost dir httpds h clink do_conf reload_file reload_list docroot_directive
+ local srcfile tmpconf instances i site dir httpds h output clink reload_list docroot_directive
_wc_debug "wc_write_package_httpd_config() $@"
tmpconf=`_wc_mktmp`
- reload_file=`_wc_mktmp`
- # detect what kind of install this is and copy/merge the correct file
- case $wc_apache_conf_style in
- inline)
- cp /usr/share/webapps-common/templates/apache-inline.conf "$tmpconf"
- sed -i -e "/^<Directory/r /usr/share/webapps-common/install/$wc_package/httpd/apache_inline" "$tmpconf"
- ;;
- simple|"")
- cp /usr/share/webapps-common/templates/apache.conf "$tmpconf"
- ;;
- template)
- cp "/usr/share/webapps-common/install/$wc_package/httpd/apache_template" "$tmpconf"
- ;;
- *)
- echo "illegal value specified for wc_apache_conf_style" >&2
- ;;
- esac
+ if [ -f "/usr/share/webapps-common/install/$wc_package/httpd/apache_template" ]; then
+ srcfile="/usr/share/webapps-common/install/$wc_package/httpd/apache_template"
+ else
+ srcfile="/usr/share/webapps-common/templates/apache.conf"
+ fi
- # now perform some substitutions on the file into the output files
- grep -vE '^[[:space:]]*(#|$)' "$wc_pkgconfig" | while read vhost dir httpds; do
- dir=`eval echo $dir`
- if [ ! "$dir" ] || [ "dir" = "/" ]; then
+ # now perform some substitutions on the file into the output files,
+ # one per configured instance
+ db_get $wc_package/httpd/instances && instances="$RET"
+ for i in `_wc_list_explode "$instances"`; do
+ site=`echo $i | cut -d/ -f1`
+ selected_sites=`_wc_list_add "$selected_sites" "$site"`
+ dir="/`echo $i | cut -sd/ -f2- | sed -e 's,^/,,'`"
+
+ if [ "$dir" = "/" ]; then
docroot_directive="DocumentRoot $wc_website_documentroot"
else
- docroot_directive="Alias /$dir $wc_website_documentroot"
+ docroot_directive="Alias $dir $wc_website_documentroot"
fi
+ db_get $wc_package/sites/$i/httpd/select_httpd && httpds="$RET"
+
for h in `_wc_list_explode "$httpds"`; do
- do_conf="yes"
- tmpconf2=`_wc_mktmp`
sed -e "s,_WC_WEBSITE_SUBDIRECTORY_,$dir,g" \
-e "s,_WC_WEBSITE_DOCUMENTROOT_,$wc_website_documentroot,g" \
- -e "s,_WC_WEBSITE_HOSTNAME_,$vhost,g" \
- -e "s,_WC_DOCROOT_DIRECTIVE_,$docroot_directive,g" < "$tmpconf" > "$tmpconf2"
- output=`_wc_instance_cfg_file "$vhost" "$dir" "$h"`
+ -e "s,_WC_WEBSITE_HOSTNAME_,$site,g" \
+ -e "s,_WC_DOCROOT_DIRECTIVE_,$docroot_directive,g" < "$srcfile" > "$tmpconf"
+ output=`_wc_instance_cfg_file "$i" "$h"`
mkdir -p `dirname "$output"`
# and register it via ucf
- chmod 640 "$tmpconf2"
- ucf "$tmpconf2" "$output"
+ chmod 640 "$tmpconf"
+ ucf "$tmpconf" "$output"
chgrp www-data "$output"
# check to see if the file exists but the symlink was removed
- clink=`_wc_instance_cfg_link "$vhost" "$dir" "$h"`
+ clink=`_wc_instance_cfg_link "$i" "$h"`
mkdir -p `dirname "$clink"`
+
if [ -f "$output" -a ! -h "$clink" ]; then
# also make sure that there's nothing else where the
# symlink ought to be
@@ -164,20 +158,16 @@
ln -s "$output" "$clink"
reload_list=`_wc_list_add "$reload_list" "$h"`
fi
- wc_httpd_create_vhost $vhost $h
+ if [ ! "$site" = "=global=" ]; then
+ wc_httpd_create_vhost $site $h
+ fi
fi
-
- rm -f "$tmpconf2"
done
- echo $reload_list > "$reload_file"
done
+
rm -f "$tmpconf"
# finally, detect the list of servers which need to be reloaded.
- # we need to use a tmpfile because the value of reload_list from
- # the above while loop is not preserved when the while loop exists.
- reload_list=`cat $reload_file`
- rm -f "$reload_file"
if [ "$reload_list" ]; then
_wc_debug "the following servers need to be reloaded: ${reload_list}."
wc_httpd_invoke reload `wc_httpd_running $reload_list` || true
@@ -210,7 +200,6 @@
wc_read_package_debconf(){
_wc_debug "wc_read_package_debconf() $@"
_wc_sanity_check package || wc_install_error
- db_get $wc_package/httpd/website_subdirectory && wc_website_subdirectory=$RET
db_get $wc_package/webapps_install && wc_install="$RET"
}
@@ -303,37 +292,32 @@
### of the templates for a vhost identified with said argument
###
wc_register_debconf(){
- local f vhost_id debconf_dest
+ local f vhost instance debconf_dest
_wc_debug "wc_register_debconf() $@"
- vhost_id="$1"
+ instance="$1"
- if [ ! "$vhost_id" ]; then
+ if [ ! "$instance" ]; then
debconf_dest="$wc_package"
else
- debconf_dest="$wc_package/vhosts/$vhost_id"
+ vhost=`echo $instance | cut -d/ -f1`
+ 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
# perform some basic customizing substitutions
for f in $wc_register_templates; do
db_subst "$debconf_dest/$f" pkg "$wc_package"
- if [ "$vhost_id" ]; then
- db_subst "$debconf_dest/$f" vhost "$vhost_id"
+ if [ "$instance" ]; then
+ db_subst "$debconf_dest/$f" vhost "$vhost"
+ db_subst "$debconf_dest/$f" instance "$instance"
fi
done
-
- # set some default values if this is a first-time installation
- # for all other installations, we rely on the config -> debconf
- # preseeding to load in the correct values.
- if [ ! "$wc_oldversion" ]; then
- db_set "$debconf_dest/httpd/website_subdirectory" $wc_package
- db_set "$debconf_dest/httpd/select_httpd" "`wc_httpd_installed`"
- fi
}
###
@@ -351,38 +335,33 @@
### unregister all the registered debconf templates
###
wc_forget_debconf(){
- local f v vhosts
+ local f i instances
_wc_debug "wc_forget_debconf() $@"
- db_get $wc_package/httpd/virtualhost && vhosts="$RET"
- db_get $wc_package/httpd/virtualhost_previous && vhosts=`_wc_list_join "$vhosts" "$RET"`
+ db_get $wc_package/httpd/instances && instances="$RET"
+ db_get $wc_package/httpd/instances_previous && instances=`_wc_list_join "$instances" "$RET"`
for f in $wc_register_templates; do
db_unregister $wc_package/$f
- for v in `_wc_list_explode "$vhosts"`; do
- db_unregister "$wc_package/vhosts/$v/$f"
+ for i in `_wc_list_explode "$instances"`; do
+ db_unregister "$wc_package/sites/$i/$f"
done
done
}
###
-### dump the vhost/dir combinations for a package to the config file
-### this should only be called in the postinst i guess
+### dump the configured instances for a package to the config file
###
wc_dump_debconf_pkgconfig(){
- local tmpconf vhosts v d httpds debconf_src
+ local tmpconf instances i httpds
_wc_debug "wc_dump_debconf_pkgconfig() $@"
tmpconf=`_wc_mktmp`
# get the list of selected virtualhosts
- db_get $wc_package/httpd/virtualhost && vhosts="$RET"
+ db_get $wc_package/httpd/instances && instances="$RET"
# and for each one, dump their config
- for v in `_wc_list_explode "$vhosts"`; do
- debconf_src="$wc_package/vhosts/$v"
- db_get $debconf_src/httpd/website_subdirectory && d=$RET
- db_get $debconf_src/httpd/select_httpd && httpds=$RET
- # this strips the quotes if they happen to be there
- d=`eval echo $d`
- echo "$v \"$d\" $httpds" >> "$tmpconf"
+ for i in `_wc_list_explode "$instances"`; do
+ db_get $wc_package/sites/$i/httpd/select_httpd && httpds=$RET
+ echo "$i $httpds" >> "$tmpconf"
done
ucf "$tmpconf" "$wc_pkgconfig"
@@ -393,7 +372,7 @@
### this should only be called in the config script, i guess
###
wc_preseed_debconf(){
- local v old_vhosts vhosts vhost_count
+ local i old_vhosts instances
_wc_debug "wc_preseed_debconf() $@"
# set the master control flag
@@ -403,28 +382,19 @@
# get the list of virtualhosts for which this app is configured
if [ -f "$wc_pkgconfig" ]; then
- vhosts=`grep -vE '^[[:space:]]*#' "$wc_pkgconfig" | cut -f1`
- vhosts=`_wc_list_create $vhosts`
- _wc_debug "preseeding previously configured vhosts: $vhosts"
- vhost_count=`grep -vcE '^[[:space:]]*#' "$wc_pkgconfig"` || true
- # automatically fill in the right default choice for this question
- if [ $vhost_count -eq 0 ]; then
- db_set $wc_package/httpd/install_type "directory"
- db_set $wc_package/httpd/virtualhost_single $vhosts
- elif [ $vhost_count -eq 1 ]; then
- db_set $wc_package/httpd/install_type "virtualhost + directory"
- db_set $wc_package/httpd/virtualhost_single $vhosts
- else
- db_set $wc_package/httpd/install_type "multiple instances"
- fi
- db_set $wc_package/httpd/virtualhost_previous $vhosts
- db_set $wc_package/httpd/virtualhost $vhosts
+ instances=`grep -vE '^[[:space:]]*#' "$wc_pkgconfig" | cut -f1`
+ instances=`_wc_list_create $instances`
+ _wc_debug "preseeding previously configured instances: $instances"
+ db_subst $wc_package/httpd/instances instances $instances
+ db_set $wc_package/httpd/instances $instances
+ db_subst $wc_package/httpd/instances_previous instances $instances
+ db_set $wc_package/httpd/instances_previous $instances
fi
- # preseed each vhost debconf structure for this package.
- for v in `_wc_list_explode "$vhosts"`; do
- wc_register_debconf "$v"
- wc_preseed_debconf_vhost "$v"
+ # preseed each instance's debconf tree
+ for i in `_wc_list_explode "$instances"`; do
+ wc_register_debconf "$i"
+ wc_preseed_debconf_instance "$i"
done
# now, get any pre-existing vhosts from global configuration
@@ -433,86 +403,65 @@
old_vhosts=`_wc_list_create $old_vhosts`
fi
vhosts=`_wc_list_join "$old_vhosts" "$vhosts"`
-
- # and append the '[new vhost]' option
- vhosts=`_wc_list_add "[new vhost]" "$vhosts"`
-
- # finally, put the big list into the vhost options.
- db_subst $wc_package/httpd/virtualhost vhosts "$vhosts"
- db_subst $wc_package/httpd/virtualhost_previous vhosts "$vhosts"
- db_subst $wc_package/httpd/virtualhost_single vhosts "$vhosts"
+ db_subst $wc_package/httpd/virtualhost virtualhosts $vhosts
}
###
### preseed debconf values from the config files on disk
-### this should only be called in the config script, i guess
###
-wc_preseed_debconf_vhost(){
- local vhost vhost_grep vdir httpds debconf_dest
- _wc_debug "wc_preseed_debconf_vhost() $@"
+wc_preseed_debconf_instance(){
+ local instance grep_expr idir httpds debconf_dest
+ _wc_debug "wc_preseed_debconf_instance() $@"
if [ ! -f "$wc_pkgconfig" ]; then return 0; fi
- vhost="$1"
- debconf_dest="$wc_package/vhosts/$vhost"
+ instance="$@"
+ debconf_dest="$wc_package/sites/$instance"
- # a quick bozo fix to prevent '[default]' from being interpreted
- # as a regexp.
- if [ "$vhost" = "[default]" ]; then
- vhost_expr="\\[default\\]"
- else
- vhost_expr="$vhost"
- fi
- vhost_expr="^$vhost_expr[[:space:]]"
+ grep_expr="^$instance[[:space:]]"
- # first, for new installs there will be nothing to preseed, but
- # there are cases where we may wish to preseed something even
- # though it doesn't exist. so, if they're not in the config,
- # set some default values
- if ! grep -qE $vhost_expr $wc_pkgconfig; then
- db_set $debconf_dest/httpd/website_subdirectory $wc_package
+ # first, test for new installs / reconfigurations where the
+ # given choice does not exist in the config file. this is where
+ # we set "default" values
+ if ! grep -qE $grep_expr $wc_pkgconfig; then
db_set $debconf_dest/httpd/select_httpd "`wc_httpd_installed`"
return 0
fi
+ # otherwise, fill in the blanks using the contents of the config
- vdir=`grep -E $vhost_expr $wc_pkgconfig | cut -f2`
- # strip the surrounding quotes
- vdir=`eval echo $vdir`
- httpds=`grep -E $vhost_expr $wc_pkgconfig | cut -f3-`
+ idir=`echo $instance | cut -sd/ -f2`
+ httpds=`grep -E $grep_expr $wc_pkgconfig | cut -f2-`
- # and some sanity checking:
- if [ ! "$vdir" ]; then
- _wc_log "warning: instance '$vhost' missing directory name"
- fi
-
- db_set $debconf_dest/httpd/website_subdirectory $vdir
+ db_set $debconf_dest/httpd/website_subdirectory $idir
db_set $debconf_dest/httpd/select_httpd "$httpds"
}
###
### output the name of a configuration file for a particular instance
##
-## usage: _wc_instance_cfg_file site dir httpd
+## usage: _wc_instance_cfg_file instance httpd
###
_wc_instance_cfg_file(){
- local site dir httpd
- site=$1
- dir=`echo $2 | sed -e 's,/,%2f,g'`
- httpd=$3
+ local instance site dir httpd
+ instance=$1
+ httpd=$2
+ site=`echo $instance | cut -d/ -f1`
+ dir=`echo $instance | cut -sd/ -f2- | sed -e 's,/,%2f,g'`
echo "$wc_confdir/apps-available/${httpd}/${site}/${wc_package}_${dir}.conf"
}
###
### output the name of where a symlink to the instance cfg file should be
##
-## usage: _wc_instance_cfg_link site dir httpd
+## usage: _wc_instance_cfg_link instance httpd
###
_wc_instance_cfg_link(){
- local site dir httpd
- site=$1
- dir=`echo $2 | sed -e 's,/,%2f,g'`
- httpd=$3
+ local instance site dir httpd
+ instance=$1
+ httpd=$2
+ site=`echo $instance | cut -d/ -f1`
+ dir=`echo $instance | cut -sd/ -f2- | sed -e 's,/,%2f,g'`
echo "$wc_confdir/apps-enabled/${httpd}/${site}/${wc_package}_${dir}.conf"
}
@@ -520,18 +469,20 @@
### disable a given instance by removing the appropriate "enabling" symlink
###
##
-## usage: wc_disable_instance site dir httpd[, httpd2...]
+## usage: wc_disable_instance instance
###
wc_disable_instance(){
- local site dir httpds h app_link
- site=$1
- dir=$2
- shift 2
- httpds=$*
+ local instance httpds h app_link
+ instance=$1
+ httpds=`grep "^$instance[[:space:]]" $wc_pkgconfig | cut -f2-`
+
for h in `_wc_list_explode "$httpds"`; do
- app_link=`_wc_instance_cfg_link "$site" "$dir" "$h"`
+ app_link=`_wc_instance_cfg_link "$instance" "$h"`
_wc_debug "disabling site config: $app_link"
rm -f $app_link
+ # attempt to remove the parent directory in case it's now empty
+ # can't do this here because the vhost config still includes it
+ #rmdir `dirname $app_link` >/dev/null 2>&1 || true
done
}
@@ -539,16 +490,15 @@
### purge a given instance by removing the appropriate configuration
###
##
-## usage: wc_purge_instance site dir httpd[, httpd2...]
+## usage: wc_purge_instance instance
###
wc_purge_instance(){
- local site dir httpds h app_file
- site=$1
- dir=$2
- shift 2
- httpds=$*
+ local instance httpds h app_link
+ instance=$1
+ httpds=`grep "^$instance[[:space:]]" $wc_pkgconfig | cut -f2-`
+
for h in `_wc_list_explode "$httpds"`; do
- app_file=`_wc_instance_cfg_file "$site" "$dir" "$h"`
+ app_file=`_wc_instance_cfg_file "$instance" "$h"`
_wc_debug "purging site config: $app_file"
rm -f "$app_file"
ucf --purge "$app_file"
Modified: trunk/dpkg/config
===================================================================
--- trunk/dpkg/config 2006-05-09 17:22:01 UTC (rev 77)
+++ trunk/dpkg/config 2006-05-14 20:16:02 UTC (rev 78)
@@ -2,7 +2,7 @@
# sean finney <seanius at debian.org>
wc_go(){
- local installtype donewithvhosts vhosts_selected vhost_list v
+ local oldinstances
. /usr/share/webapps-common/dpkg/common
_wc_debug "(config) wc_go() $@"
wc_config $@
@@ -28,130 +28,76 @@
return 0;
fi
- # state 200 - get how we're going to be installed
- db_input medium $wc_package/httpd/install_type || true
- db_go || true
- db_get $wc_package/httpd/install_type && installtype="$RET"
- _wc_debug install-type: $installtype
+ # state 200 - prompt them for the list of configured instances
+ while wc_config_select_more_instances; do true; done
- # state 300 - if we're doing vhosts, choose vhosts
- while wc_config_select_more_vhosts "$installtype"; do true; done
-
- # state 400 - ask for the httpds/site directory for each instance
- # - if we're doing directory style install, then configure the
- # the global instance
- if [ "$installtype" = "directory" ]; then
- wc_config_instance "[default]"
- # - otherwise configure each virtualhost instance
- else
- db_get $wc_package/httpd/virtualhost && vhosts_selected=$RET
- for v in `_wc_list_explode "$vhosts_selected"`; do
- wc_register_debconf "$v"
- wc_preseed_debconf_vhost "$v"
- wc_config_instance "$v"
- done
- fi
-
# let's stop here for now.
db_go || true
}
-# select some set of vhosts. return non-zero when the user is done
-# selecting hosts (or has chosen to quit maybe)
-wc_config_select_more_vhosts(){
- local instype vhost_question vhost_list vhost_new vhost_name vhosts_selected
- _wc_debug "wc_config_select_more_vhosts() $@"
+# select another instance for configuring a webapp. returns non-zero when
+# the user is done selecting hosts (or has chosen to quit maybe)
+wc_config_select_more_instances(){
+ local oldvhosts selected_instances vhost vdir instance
+ _wc_debug "wc_config_select_more_instances() $@"
- instype="$@"
- case "$instype" in
- "directory")
- wc_register_debconf "[default]"
- db_set $wc_package/httpd/virtualhost "[default]"
- return 1;
- ;;
- "virtualhost + directory")
- vhost_question="httpd/virtualhost_single"
- ;;
- "multiple instances")
- vhost_question="httpd/virtualhost"
- ;;
- *)
- _wc_log "error, told to configure '$instype'"
- esac
+ db_input high $wc_package/httpd/instances || true
+ db_go || true
+ db_get $wc_package/httpd/instances && selected_instances="$RET"
- # fetch the current list of vhost choices.
- # if the list is empty, add the default "[new vhost]" entry
- db_metaget $wc_package/httpd/virtualhost choices && vhost_list=$RET
- if [ ! "$vhost_list" ]; then
- vhost_list="[new vhost]"
- db_subst $wc_package/httpd/virtualhost vhosts "$vhost_list"
- db_subst $wc_package/httpd/virtualhost_single vhosts "$vhost_list"
+ # first check to see if they're done
+ if ! `_wc_list_is_member "$selected_instances" "configure new instance"`; then
+ return 1
fi
- # ask, and fetch what they entered
- db_input high "$wc_package/$vhost_question" || true
+ db_input high $wc_package/httpd/virtualhost || true
db_go || true
- db_get "$wc_package/$vhost_question" && vhosts_selected=$RET
- db_set "$wc_package/httpd/virtualhost" "$vhosts_selected"
- _wc_debug vhosts_selected: "$vhosts_selected"
+ db_get $wc_package/httpd/virtualhost && vhost="$RET"
- # if '[new vhost]' was in the list of selected vhosts, then we
- # have to fetch info about this new virtualhost
- if _wc_list_is_member "$vhosts_selected" '\[new vhost\]'; then
- # fetch the new virtualhost setting
+ 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_new=$RET
+ 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
- # if they provide a name
- if [ "$vhost_new" ]; then
- # add it to the original list prompted in the question
- vhost_list=`_wc_list_add "$vhost_list" "$vhost_new"`
- # add it to the list of selected vhosts
- vhosts_selected=`_wc_list_add "$vhosts_selected" "$vhost_new"`
- # remove mention of '[new vhost]' being selected
- vhosts_selected=`_wc_list_remove "$vhosts_selected" "\[new vhost\]"`
- # update the list of available vhosts in the debconf question
- db_subst $wc_package/httpd/virtualhost vhosts "$vhost_list"
- db_subst $wc_package/httpd/virtualhost_single vhosts "$vhost_list"
- # update the value of the answer
- db_set $wc_package/httpd/virtualhost $vhosts_selected
- db_set $wc_package/httpd/virtualhost_single $vhosts_selected
- # reset the value of virtualhost_new in case it's asked again
- db_set $wc_package/httpd/virtualhost_new ""
- # copy over all the answers into a subtree just for this package
- wc_register_debconf "$vhost_new"
- # set the default directory
- db_set $wc_package/vhosts/$vhost_new/website_subdirectory ""
- fi
- # at this point it's possible that they want to enter more
- # vhosts, so we're not done yet
- return 0
- else
- # if they're done entering new vhosts, we're done with this part
- return 1
+ 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=`_wc_list_add "$selected_instances" "$instance"`
+ selected_instances=`_wc_list_remove "$selected_instances" "configure new 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
###
-wc_config_instance(){
+wc_config_select_instance_httpds(){
local instd_httpds oldchoices debconf_dest
- _wc_debug "wc_config_instance() $@"
+ _wc_debug "wc_config_select_instance_httpds() $@"
- if [ "$1" ]; then
- debconf_dest="$wc_package/vhosts/$1"
- else
- debconf_dest="$wc_package"
- fi
+ debconf_dest="$wc_package/sites/$@"
- db_input medium $debconf_dest/httpd/website_subdirectory || true
-
# create a list of installed httpds
instd_httpds=`_wc_list_create \`wc_httpd_installed\``
# get a list of previously offered choices of installed httpds
- db_metaget $debconf_dest/httpd/select_httpd choices && oldchoices="$RET"
+ db_metaget $debconf_dest/httpd/select_httpd httpds && oldchoices="$RET"
# if the old list was empty or does not match the current list, we need
# to update the list of available choices
Modified: trunk/dpkg/postinst
===================================================================
--- trunk/dpkg/postinst 2006-05-09 17:22:01 UTC (rev 77)
+++ trunk/dpkg/postinst 2006-05-14 20:16:02 UTC (rev 78)
@@ -21,42 +21,33 @@
# here is where we disable deselected choices
wc_postinst_purge_deconfigured_hosts
- # sync them to disk
+ # now sync the new configuration to disk
wc_dump_debconf_pkgconfig
+ wc_write_package_httpd_configs
wc_write_global_config
# and finally, let's go out of our way to flush everything out
# of debconf's cache, to make sure we're not doing any evil
# "Debconf Is Not A Registry(tm)" stuff.
wc_forget_debconf
-
- # write out all of the required httpd configuration files
- wc_write_package_httpd_configs
fi
}
wc_postinst_purge_deconfigured_hosts(){
- local hosthosts newhosts h dir httpds reload_file reload_list
+ local oldinstances newinstances i dir httpds reload_list
_wc_debug "wc_postinst_purge_deconfigured_hosts() $@"
- reload_file=`_wc_mktmp`
- db_get $wc_package/httpd/virtualhost_previous && oldhosts=$RET
- db_get $wc_package/httpd/virtualhost && newhosts=$RET
- _wc_debug " previously selected hosts: $oldhosts"
- _wc_debug " currently selected hosts: $newhosts"
- for h in `_wc_list_explode "$oldhosts"`; do
- if ! _wc_list_is_member "$newhosts" "$h"; then
- _wc_log "deconfiguring deselected instance $h"
- dir=`grep -w "^$h" "$wc_pkgconfig" | cut -f2`
- dir=`eval echo $dir`
- httpds=`grep -w "^$h" "$wc_pkgconfig" | cut -f3-`
- wc_disable_instance "$h" "$dir" "$httpds"
+ db_get $wc_package/httpd/instances_previous && oldinstances=$RET
+ db_get $wc_package/httpd/instances && newinstances=$RET
+ _wc_debug " previously selected instances: $oldinstances"
+ _wc_debug " currently selected instances: $newinstances"
+ for i in `_wc_list_explode "$oldinstances"`; do
+ if ! _wc_list_is_member "$newinstances" "$i"; then
+ _wc_log "deconfiguring deselected instance $i"
+ wc_disable_instance "$i"
reload_list=`_wc_list_join "$reload_list" "$httpds"`
- echo $reload_list > $reload_file
fi
done
- reload_list=`cat $reload_file`
- rm -f "$reload_file"
if [ "$reload_list" ]; then
_wc_debug "need to reload the following servers: ${reload_list}."
wc_httpd_invoke reload `wc_httpd_running $reload_list` || true
Modified: trunk/dpkg/postrm
===================================================================
--- trunk/dpkg/postrm 2006-05-09 17:22:01 UTC (rev 77)
+++ trunk/dpkg/postrm 2006-05-14 20:16:02 UTC (rev 78)
@@ -20,23 +20,18 @@
}
wc_postrm_disable_app(){
- local vhost dir httpds reload_list reload_file
+ local instance line httpds reload_list
_wc_debug "wc_postrm_disable_app() $@"
- reload_file=`_wc_mktmp`
-
# for each configuration line in the file
- grep -vE '^[[:space:]]*(#|$)' "$wc_pkgconfig" | while read vhost dir httpds; do
- dir=`eval echo $dir`
- wc_disable_instance "$vhost" "$dir" "$httpds"
+ grep -vE '^[[:space:]]*(#|$)' "$wc_pkgconfig" | while read line; do
+ instance=`echo $line | cut -f1`
+ httpds=`echo $line | cut -f2-`
+ wc_disable_instance "$instance"
reload_list=`_wc_list_join "$reload_list" "$httpds"`
- echo $reload_list > $reload_file
done
- reload_list=`cat $reload_file`
- rm -f "$reload_file"
_wc_debug "need to reload the following servers: ${reload_list}."
-
wc_httpd_invoke reload `wc_httpd_running $reload_list` || true
}
@@ -45,9 +40,8 @@
_wc_debug "wc_postrm_purge_app() $@"
# for each configuration line in the file
- grep -vE '^[[:space:]]*(#|$)' "$wc_pkgconfig" | while read vhost dir httpds; do
- dir=`eval echo $dir`
- wc_purge_instance "$vhost" "$dir" "$httpds"
+ grep -vE '^[[:space:]]*(#|$)' "$wc_pkgconfig" | cut -f1 | while read instance; do
+ wc_purge_instance "$instance"
done
ucf --purge "$wc_pkgconfig"
rm -f "$wc_pkgconfig"
Modified: trunk/dpkg/prerm
===================================================================
--- trunk/dpkg/prerm 2006-05-09 17:22:01 UTC (rev 77)
+++ trunk/dpkg/prerm 2006-05-14 20:16:02 UTC (rev 78)
@@ -3,15 +3,6 @@
wc_go(){
. /usr/share/webapps-common/dpkg/common
_wc_debug "(prerm) wc_go() $@"
- wc_config $@
+ # wc_config $@
- # anything after this point is not an upgrade
- if [ "$wc_command" = "upgrade" ]; then
- return 0
- fi
-
- # XXX shouldn't this be in the postrm?
- if [ "$wc_command" = "purge" ]; then
- wc_unregister_templates
- fi
}
Modified: trunk/internal/common
===================================================================
--- trunk/internal/common 2006-05-09 17:22:01 UTC (rev 77)
+++ trunk/internal/common 2006-05-14 20:16:02 UTC (rev 78)
@@ -92,6 +92,11 @@
echo $list
}
+_wc_list_count(){
+ local list
+ list=$*
+ echo $list | sed -e 's/, \?/\n/g' | wc -l
+}
###
### logging messages
Modified: trunk/templates/apache2-wc-master.conf
===================================================================
--- trunk/templates/apache2-wc-master.conf 2006-05-09 17:22:01 UTC (rev 77)
+++ trunk/templates/apache2-wc-master.conf 2006-05-14 20:16:02 UTC (rev 78)
@@ -2,4 +2,4 @@
# this file is responsible for instructing apache2 to load all
# application configuration files for packages configured via
# webapps common.
-Include /etc/webapps-common/apps-enabled/apache2/*.conf
+Include /etc/webapps-common/apps-enabled/apache2/=global=/*.conf
Modified: trunk/templates/virtualhosts.conf
===================================================================
--- trunk/templates/virtualhosts.conf 2006-05-09 17:22:01 UTC (rev 77)
+++ trunk/templates/virtualhosts.conf 2006-05-14 20:16:02 UTC (rev 78)
@@ -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