[Webapps-common-discuss] [commit] r76 - in trunk: . debian
debian/po dpkg examples internal templates
Sean Finney
seanius at costa.debian.org
Wed May 3 22:04:18 UTC 2006
Author: seanius
Date: 2006-05-03 22:03:41 +0000 (Wed, 03 May 2006)
New Revision: 76
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/examples/buildpackages.sh
trunk/internal/httpd
trunk/templates/apache-inline.conf
trunk/templates/apache.conf
Log:
* random bugfixes, as always
* support for configuring/deconfiguring instances.
* moved stuff in the postinst to where it should be.
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2006-04-21 09:45:24 UTC (rev 75)
+++ trunk/TODO 2006-05-03 22:03:41 UTC (rev 76)
@@ -1,22 +1,20 @@
-- i'm in the middle of redoing configuration layout in /etc/webapps-common
- to something that actually makes sense
+right now:
-- have an available/enabled directory for the generated httpd files.
- - almost there... but layout enabled/disabled isn't quite consistant
- across all the code. in some places it's
-
- /e/w/apps-enabled/$httpd/$pkg_$vhost_$dir.conf
-
- and others it's
-
- /e/w/apps-enabled/$httpd/$vhost/$pkg_$dir.conf
-
- i think the latter is the way to go, as it is easier to include
- from virtual-host configurations.
-
- "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?).
- using [new vhost] and [default] is a PITA for special case checks in
anything that uses grep. maybe {new vhost} etc would be better...
+
+- all code/examples using Alias _WC_.... should be modified to instead
+ use something like _WC_DOCROOT_DIRECTIVE_, which will expand differently
+ depending on whether the subdirectory is "/" or not.
+
+further ahead:
+
+- there are some tasks which would probably do best to be abstracted into
+ actual cmdline programs, like wc-newsite foobar.com or something, which
+ could then be used as a general purpose tool.
+
+- support multiple directories under a single vhost
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2006-04-21 09:45:24 UTC (rev 75)
+++ trunk/debian/changelog 2006-05-03 22:03:41 UTC (rev 76)
@@ -1,3 +1,12 @@
+webapps-common (0.6) UNRELEASED; urgency=low
+
+ [sean finney]
+ * random bugfixes, as always
+ * support for configuring/deconfiguring instances.
+ * moved stuff in the postinst to where it should be.
+
+ -- sean finney <seanius at debian.org> Thu, 04 May 2006 01:59:11 +0200
+
webapps-common (0.5) UNRELEASED; urgency=low
[sean finney]
Modified: trunk/debian/po/templates.pot
===================================================================
--- trunk/debian/po/templates.pot 2006-04-21 09:45:24 UTC (rev 75)
+++ trunk/debian/po/templates.pot 2006-05-03 22:03:41 UTC (rev 76)
@@ -16,7 +16,7 @@
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2006-04-10 17:42+0200\n"
+"POT-Creation-Date: 2006-04-25 10:57+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"
@@ -233,24 +233,24 @@
#. Type: multiselect
#. Choices
-#: ../webapps-common.templates:108
+#: ../webapps-common.templates:112
msgid "${vhosts}"
msgstr ""
#. Type: multiselect
#. Description
-#: ../webapps-common.templates:109
+#: ../webapps-common.templates:113
msgid "Please select the virtualhosts with which to configure ${pkg}"
msgstr ""
#. Type: string
#. Default
-#: ../webapps-common.templates:113
+#: ../webapps-common.templates:117
msgid "${pkg}"
msgstr ""
#. Type: string
#. Description
-#: ../webapps-common.templates:114
+#: ../webapps-common.templates:118
msgid "Please provide the subdirectory for ${pkg} on \"${vhost}\""
msgstr ""
Modified: trunk/debian/webapps-common.templates
===================================================================
--- trunk/debian/webapps-common.templates 2006-04-21 09:45:24 UTC (rev 75)
+++ trunk/debian/webapps-common.templates 2006-05-03 22:03:41 UTC (rev 76)
@@ -103,6 +103,10 @@
_Choices: ${vhosts}
_Description: Please select the virtualhost with which to configure ${pkg}
+Template: webapps-common/httpd/virtualhost_previous
+Type: multiselect
+_Choices: ${vhosts}
+
Template: webapps-common/httpd/virtualhost
Type: multiselect
_Choices: ${vhosts}
Modified: trunk/dpkg/common
===================================================================
--- trunk/dpkg/common 2006-04-21 09:45:24 UTC (rev 75)
+++ trunk/dpkg/common 2006-05-03 22:03:41 UTC (rev 76)
@@ -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_new"
+ 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_register_templates=$wc_standard_templates
###
@@ -105,8 +105,8 @@
### 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
- _wc_debug "wc_write_package_config() $@"
+ local tmpconf tmpconf2 output vhost dir httpds h clink do_conf reload_file reload_list docroot_directive
+ _wc_debug "wc_write_package_httpd_config() $@"
tmpconf=`_wc_mktmp`
reload_file=`_wc_mktmp`
@@ -130,17 +130,31 @@
# 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
+ docroot_directive="DocumentRoot $wc_website_documentroot"
+ else
+ docroot_directive="Alias /$dir $wc_website_documentroot"
+ fi
+
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" < "$tmpconf" > "$tmpconf2"
- output=`_wc_instance_cfg_file $vhost $dir $h`
+ 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"`
+ mkdir -p `dirname "$output"`
# and register it via ucf
+ chmod 640 "$tmpconf2"
ucf "$tmpconf2" "$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 "$vhost" "$dir" "$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,8 +178,10 @@
# the above while loop is not preserved when the while loop exists.
reload_list=`cat $reload_file`
rm -f "$reload_file"
- _wc_debug "the following servers need to be reloaded: ${reload_list}."
- wc_httpd_invoke reload `wc_httpd_running $reload_list` || true
+ 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
+ fi
}
###
@@ -176,6 +192,7 @@
local vhost dir httpds h cfile
_wc_debug "wc_purge_httpd_conf() $@"
grep -vE '^[[:space:]]*(#|$)' "$wc_pkgconfig" | while read vhost dir httpds; do
+ dir=`eval echo $dir`
for h in `_wc_list_explode "$httpds"`; do
cfile="/etc/webapps-common/httpd.d/${wc_package}_${h}_${vhost}_${dir}.conf"
rm -f "$cfile"
@@ -193,7 +210,7 @@
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/httpd/website_subdirectory && wc_website_subdirectory=$RET
db_get $wc_package/webapps_install && wc_install="$RET"
}
@@ -314,7 +331,7 @@
# 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/website_subdirectory" $wc_package
db_set "$debconf_dest/httpd/select_httpd" "`wc_httpd_installed`"
fi
}
@@ -338,6 +355,7 @@
_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"`
for f in $wc_register_templates; do
db_unregister $wc_package/$f
for v in `_wc_list_explode "$vhosts"`; do
@@ -360,9 +378,11 @@
# 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"
- echo "$v $d $httpds" >> "$tmpconf"
+ 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"
done
ucf "$tmpconf" "$wc_pkgconfig"
@@ -385,17 +405,20 @@
if [ -f "$wc_pkgconfig" ]; then
vhosts=`grep -vE '^[[:space:]]*#' "$wc_pkgconfig" | cut -f1`
vhosts=`_wc_list_create $vhosts`
-set -x
+ _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
-set +x
+ db_set $wc_package/httpd/virtualhost_previous $vhosts
+ db_set $wc_package/httpd/virtualhost $vhosts
fi
# preseed each vhost debconf structure for this package.
@@ -416,6 +439,7 @@
# 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"
}
@@ -447,12 +471,14 @@
# 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"
+ db_set $debconf_dest/httpd/website_subdirectory $wc_package
db_set $debconf_dest/httpd/select_httpd "`wc_httpd_installed`"
return 0
fi
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-`
# and some sanity checking:
@@ -460,7 +486,7 @@
_wc_log "warning: instance '$vhost' missing directory name"
fi
- db_set $debconf_dest/httpd/website_subdirectory "$vdir"
+ db_set $debconf_dest/httpd/website_subdirectory $vdir
db_set $debconf_dest/httpd/select_httpd "$httpds"
}
@@ -470,7 +496,11 @@
## usage: _wc_instance_cfg_file site dir httpd
###
_wc_instance_cfg_file(){
- echo "$wc_confdir/apps-available/${3}/${wc_package}_${1}_${2}.conf"
+ local site dir httpd
+ site=$1
+ dir=`echo $2 | sed -e 's,/,%2f,g'`
+ httpd=$3
+ echo "$wc_confdir/apps-available/${httpd}/${site}/${wc_package}_${dir}.conf"
}
###
@@ -479,9 +509,52 @@
## usage: _wc_instance_cfg_link site dir httpd
###
_wc_instance_cfg_link(){
- echo "$wc_confdir/apps-enabled/${3}/${wc_package}_${1}_${2}.conf"
+ local site dir httpd
+ site=$1
+ dir=`echo $2 | sed -e 's,/,%2f,g'`
+ httpd=$3
+ echo "$wc_confdir/apps-enabled/${httpd}/${site}/${wc_package}_${dir}.conf"
}
###
+### disable a given instance by removing the appropriate "enabling" symlink
###
+##
+## usage: wc_disable_instance site dir httpd[, httpd2...]
###
+wc_disable_instance(){
+ local site dir httpds h app_link
+ site=$1
+ dir=$2
+ shift 2
+ httpds=$*
+ for h in `_wc_list_explode "$httpds"`; do
+ app_link=`_wc_instance_cfg_link "$site" "$dir" "$h"`
+ _wc_debug "disabling site config: $app_link"
+ rm -f $app_link
+ done
+}
+
+###
+### purge a given instance by removing the appropriate configuration
+###
+##
+## usage: wc_purge_instance site dir httpd[, httpd2...]
+###
+wc_purge_instance(){
+ local site dir httpds h app_file
+ site=$1
+ dir=$2
+ shift 2
+ httpds=$*
+ for h in `_wc_list_explode "$httpds"`; do
+ app_file=`_wc_instance_cfg_file "$site" "$dir" "$h"`
+ _wc_debug "purging site config: $app_file"
+ rm -f "$app_file"
+ ucf --purge "$app_file"
+ done
+}
+
+###
+###
+###
Modified: trunk/dpkg/config
===================================================================
--- trunk/dpkg/config 2006-04-21 09:45:24 UTC (rev 75)
+++ trunk/dpkg/config 2006-05-03 22:03:41 UTC (rev 76)
@@ -60,9 +60,9 @@
# 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 $@"
+ _wc_debug "wc_config_select_more_vhosts() $@"
- instype="$1"
+ instype="$@"
case "$instype" in
"directory")
wc_register_debconf "[default]"
@@ -75,6 +75,8 @@
"multiple instances")
vhost_question="httpd/virtualhost"
;;
+ *)
+ _wc_log "error, told to configure '$instype'"
esac
# fetch the current list of vhost choices.
@@ -90,7 +92,8 @@
db_input high "$wc_package/$vhost_question" || true
db_go || true
db_get "$wc_package/$vhost_question" && vhosts_selected=$RET
- _wc_debug vhosts_selected: $RET
+ db_set "$wc_package/httpd/virtualhost" "$vhosts_selected"
+ _wc_debug vhosts_selected: "$vhosts_selected"
# if '[new vhost]' was in the list of selected vhosts, then we
# have to fetch info about this new virtualhost
Modified: trunk/dpkg/postinst
===================================================================
--- trunk/dpkg/postinst 2006-04-21 09:45:24 UTC (rev 75)
+++ trunk/dpkg/postinst 2006-05-03 22:03:41 UTC (rev 76)
@@ -5,16 +5,6 @@
. /usr/share/webapps-common/dpkg/common
_wc_debug "(postinst) wc_go() $@"
wc_config $@
- # read in debconf responses (which are seeded from the config)
- wc_read_package_debconf $@
- # sync them to disk
- wc_dump_debconf_pkgconfig
- 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
-
###
### begin main code execution
###
@@ -23,11 +13,52 @@
###
### get all the debconf settings we need
###
+ # read in debconf responses (which are seeded from the config)
+ wc_read_package_debconf $@
# do they want our help at all? if so we'll quit
if [ "$wc_install" != "true" ]; then return 0; fi
+ # here is where we disable deselected choices
+ wc_postinst_purge_deconfigured_hosts
+ # sync them to disk
+ wc_dump_debconf_pkgconfig
+ 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
+ _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"
+ 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
+ fi
+}
Modified: trunk/dpkg/postrm
===================================================================
--- trunk/dpkg/postrm 2006-04-21 09:45:24 UTC (rev 75)
+++ trunk/dpkg/postrm 2006-05-03 22:03:41 UTC (rev 76)
@@ -20,20 +20,16 @@
}
wc_postrm_disable_app(){
- local h vhost dir httpds app_link reload_list reload_file
+ local vhost dir httpds reload_list reload_file
_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
- # update/merge the list of configured httpds
+ dir=`eval echo $dir`
+ wc_disable_instance "$vhost" "$dir" "$httpds"
reload_list=`_wc_list_join "$reload_list" "$httpds"`
- for h in `_wc_list_explode "$httpds"`; do
- app_link=`_wc_instance_cfg_link $vhost $dir $h`
- _wc_debug "disabling site config: $app_link"
- rm -f "$app_link"
- done
echo $reload_list > $reload_file
done
@@ -45,17 +41,13 @@
}
wc_postrm_purge_app(){
- local h vhost dir httpds app_file
+ local vhost dir httpds
_wc_debug "wc_postrm_purge_app() $@"
# for each configuration line in the file
grep -vE '^[[:space:]]*(#|$)' "$wc_pkgconfig" | while read vhost dir httpds; do
- # update/merge the list of configured httpds
- for h in `_wc_list_explode "$httpds"`; do
- app_file=`_wc_instance_cfg_file $vhost $dir $h`
- ucf --purge "$app_file"
- rm -f "$app_file"
- done
+ dir=`eval echo $dir`
+ wc_purge_instance "$vhost" "$dir" "$httpds"
done
ucf --purge "$wc_pkgconfig"
rm -f "$wc_pkgconfig"
Modified: trunk/examples/buildpackages.sh
===================================================================
--- trunk/examples/buildpackages.sh 2006-04-21 09:45:24 UTC (rev 75)
+++ trunk/examples/buildpackages.sh 2006-05-03 22:03:41 UTC (rev 76)
@@ -6,9 +6,12 @@
nwd=`dirname $0`
cd $nwd
+echo -n "building packages:"
for p in $packages; do
cd $p
- fakeroot debian/rules binary
- fakeroot debian/rules clean
+ echo -n " ($p)"
+ fakeroot debian/rules binary >/dev/null
+ fakeroot debian/rules clean >/dev/null
cd ..
done
+echo .
Modified: trunk/internal/httpd
===================================================================
--- trunk/internal/httpd 2006-04-21 09:45:24 UTC (rev 75)
+++ trunk/internal/httpd 2006-05-03 22:03:41 UTC (rev 76)
@@ -186,6 +186,7 @@
_wc_debug "wc_httpd_create_vhost() $@"
vhost=$1
+ shift
httpds=$*
for httpd in $httpds; do
Modified: trunk/templates/apache-inline.conf
===================================================================
--- trunk/templates/apache-inline.conf 2006-04-21 09:45:24 UTC (rev 75)
+++ trunk/templates/apache-inline.conf 2006-05-03 22:03:41 UTC (rev 76)
@@ -1,4 +1,4 @@
-Alias _WC_WEBSITE_SUBDIRECTORY_ _WC_WEBSITE_DOCUMENTROOT_
+_WC_DOCROOT_DIRECTIVE_
SetEnvIf REQUEST_URI '^http://_WC_WEBSITE_HOSTNAME_/_WC_WEBSITE_SUBDIRECTORY_' X_DEBIAN_SITEID=_WC_WEBSITE_HOSTNAME_/_WC_WEBSITE_SUBDIRECTORY_
Modified: trunk/templates/apache.conf
===================================================================
--- trunk/templates/apache.conf 2006-04-21 09:45:24 UTC (rev 75)
+++ trunk/templates/apache.conf 2006-05-03 22:03:41 UTC (rev 76)
@@ -1,3 +1,3 @@
-Alias _WC_WEBSITE_SUBDIRECTORY_ _WC_WEBSITE_DOCUMENTROOT_
+_WC_DOCROOT_DIRECTIVE_
SetEnvIf REQUEST_URI '^http://_WC_WEBSITE_HOSTNAME_/_WC_WEBSITE_SUBDIRECTORY_' X_DEBIAN_SITEID=_WC_WEBSITE_HOSTNAME_/_WC_WEBSITE_SUBDIRECTORY_
More information about the Webapps-common-discuss
mailing list