[Webapps-common-discuss] webapps-common/dpkg common, 1.4, 1.5 config, 1.2, 1.3 postinst, 1.3, 1.4 postrm, 1.3, 1.4 prerm, 1.1, 1.2

seanius at haydn.debian.org seanius at haydn.debian.org
Mon Oct 17 10:17:19 UTC 2005


Update of /cvsroot/webapps-common/webapps-common/dpkg
In directory haydn:/org/alioth.debian.org/chroot/home/users/seanius/tmp/cvs-serv31341/dpkg

Modified Files:
	common config postinst postrm prerm 
Log Message:
uncommitted changes from a while back

Index: common
===================================================================
RCS file: /cvsroot/webapps-common/webapps-common/dpkg/common,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- common	17 Aug 2005 16:40:41 -0000	1.4
+++ common	17 Oct 2005 10:17:13 -0000	1.5
@@ -53,7 +53,17 @@
 ### dump global configuration to a config file
 ###
 wc_write_global_config(){
-	true
+	local tfile tfile2 vhost_list v
+	tfile=`_wc_mktmp`
+	tfile2=`_wc_mktmp`
+	# get the most recent version of the available virtualhosts
+	db_metaget webapps-common/httpd/virtualhost choices && vhost_list="$RET"
+	for v in `_wc_list_explode "\`_wc_list_remove \"$vhost_list\" '\[new vhost\]'\`"`; do
+		echo $v >> $tfile
+	done
+	sort "$tfile" > "$tfile2"
+	ucf "$tfile2" /etc/webapps-common/virtualhosts.conf
+	rm -f "$tfile" "$tfile2"
 }
 
 ###
@@ -79,10 +89,11 @@
 ### dump package configuration to a config file
 ###
 wc_write_package_config(){
-	local tmpconf
+	local tmpconf tmpconf2 siteconf output vhost dir httpds h clink do_conf reload_list
 
 	tmpconf=`_wc_mktmp`
-	chmod 644 "$tmpconf"
+
+	siteconf="$wc_confdir/siteids.d/${wc_package}.conf"
 
 	# detect what kind of install this is and copy/merge the correct file
 	case $wc_apache_conf_style in 
@@ -101,20 +112,93 @@
 	;;
 	esac
 
-	# now perform some substitutions on the file
-	sed -i -e "s,_WC_WEBSITE_SUBDIRECTORY_,$wc_website_subdirectory,g" "$tmpconf"
-	sed -i -e "s,_WC_WEBSITE_DOCUMENTROOT_,$wc_website_documentroot,g" "$tmpconf"
-	sed -i -e "s,_WC_WEBSITE_HOSTNAME_,$wc_website_hostname,g" "$tmpconf"
+	# now perform some substitutions on the file into the output files
+	grep -vE '^[[:space:]]*(#|$)' "$siteconf" | while read vhost dir httpds; do
+		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_confdir/httpd.d/${wc_package}_${h}_${vhost}_${dir}.conf"
 
-	# and register it via ucf
-	ucf $tmpconf $wc_package_confdir/apache.conf
-	wc_configure_httpds
+			# check to see if the file exists but the symlink was removed
+			clink="/etc/$h/conf.d/${wc_package}_${h}_${vhost}_${dir}.conf"
+			if [ -f "$output" -a ! -h "$clink" ]; then
+				do_conf="no"
+			fi
+				
+			# and register it via ucf
+			ucf "$tmpconf2" "$output"
+
+			# if they've manually removed the symlink, keep it that way
+         if [ -f "$output" -a ! -e "$clink" -a "$do_conf" != "no" ]; then
+				ln -s "$output" "$clink"
+				reload_list=`_wc_list_add "$reload_list" "$h"`
+				echo reload list is now "$reload_list"
+			fi
+
+			rm -f "$tmpconf2"
+		done
+	done
+	rm -f "$tmpconf"
+	echo need to reload "$reload_list"
 }
 
 ###
-### wc_configure_httpds:
+### wc_purge_httpd_conf
+###	purge package httpd configuration files
+###
+wc_purge_httpd_conf(){
+	local siteconf vhost dir httpds h cfile
+	siteconf="$wc_confdir/siteids.d/${wc_package}.conf"
+	grep -vE '^[[:space:]]*(#|$)' "$siteconf" | while read vhost dir httpds; do
+		for h in `_wc_list_explode "$httpds"`; do
+			cfile="/etc/webapps-common/httpd.d/${wc_package}_${h}_${vhost}_${dir}.conf"
+			rm -f "$cfile"
+			ucf --purge "$cfile"
+		done
+	done
+}
+
+###
+### wc_unconfigure_httpds
+###	remove package configuration from all httpds
+###
+wc_unconfigure_httpds(){
+	local siteconf vhost dir httpds h cfile clink
+	siteconf="$wc_confdir/siteids.d/${wc_package}.conf"
+	grep -vE '^[[:space:]]*(#|$)' "$siteconf" | while read vhost dir httpds; do
+		for h in `_wc_list_explode "$httpds"`; do
+			clink="/etc/$h/conf.d/${wc_package}_${h}_${vhost}_${dir}.conf"
+			if [ -L "$clink" ]; then
+				rm -f "$clink"
+			fi
+		done
+	done
+}
+
+###
+### wc_configure_httpds
+###	apply configurations to the selected webservers
+###
+#wc_configure_httpds(){
+#	local siteconf vhost dir httpds h cfile
+#	siteconf="$wc_confdir/siteids.d/${wc_package}.conf"
+#	grep -vE '^[[:space:]]*(#|$)' "$siteconf" | while read vhost dir httpds; do
+#		for h in `_wc_list_explode "$httpds"`; do
+#			cfile="$wc_confdir/httpd.d/${wc_package}_${h}_${vhost}_${dir}.conf"
+#			if [ -f "$cfile" ]; then
+#				ln -s "$cfile" "/etc/$h/conf.d/" || true
+#			fi
+#		done
+#	done
+#}
+
+
+
+###
+### wc_select_httpds:
 ###	choose the servers for the app
-wc_configure_httpds(){
+wc_select_httpds(){
 	local h instd_httpds chosen_httpds oldchoices debconf_dest
 
 	if [ "$1" ]; then
@@ -294,10 +378,14 @@
 ###	this should only be called in the config script, i guess
 ###
 wc_preseed_debconf_siteids(){
-	local siteconf vhost dir httpds debconf_dest choices vhost_list
+	local siteconf vhost dir httpds debconf_dest choices g_choices vhost_list vhost_list_d
 	siteconf="/etc/webapps-common/siteids.d/$wc_package.conf"
 	if [ ! -f "$siteconf" ]; then return 0; fi
 
+	if [ -f "/etc/webapps-common/virtualhosts.conf" ]; then
+		vhost_list=`cat /etc/webapps-common/virtualhosts.conf`
+	fi
+
 	# XXX
 	# this is a gross hack.  apparently you can't redirect stdin
 	# when calling debconf get/set/register commands???
@@ -310,8 +398,12 @@
 		db_set $debconf_dest/httpd/website_subdirectory "$dir"
 		db_set $debconf_dest/httpd/select_httpd "$httpds"
 		db_metaget $wc_package/httpd/virtualhost choices && choices="$RET"
+		db_metaget webapps-common/httpd/virtualhost g_choices && g_choices="$RET"
+		choices=`_wc_list_join "$g_choices" "$choices"`
 		db_subst $wc_package/httpd/virtualhost vhosts `_wc_list_add "$choices" "$vhost"`
-		db_get $wc_package/httpd/virtualhost && vhost_list="$RET"
+		db_subst webapps-common/httpd/virtualhost vhosts `_wc_list_add "$choices" "$vhost"`
+		db_get $wc_package/httpd/virtualhost && vhost_list_d="$RET"
+		vhost_list=`_wc_list_join "$vhost_list" "$vhost_list_d"`
 		db_set $wc_package/httpd/virtualhost `_wc_list_add "$vhost_list" "$vhost"`
 	done 
 	) 

Index: config
===================================================================
RCS file: /cvsroot/webapps-common/webapps-common/dpkg/config,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- config	17 Aug 2005 16:40:41 -0000	1.2
+++ config	17 Oct 2005 10:17:13 -0000	1.3
@@ -70,7 +70,7 @@
 	# state 4 - ask for the httpds/site directory for each virtualhost
 	for v in `_wc_list_explode "$vhosts_selected"`; do
 		db_input medium $wc_package/vhosts/$v/httpd/website_subdirectory || true
-		wc_configure_httpds "$v"
+		wc_select_httpds "$v"
 		db_input medium $wc_package/vhosts/$v/httpd/select_httpd || true
 	done
 

Index: postinst
===================================================================
RCS file: /cvsroot/webapps-common/webapps-common/dpkg/postinst,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- postinst	17 Aug 2005 16:40:41 -0000	1.3
+++ postinst	17 Oct 2005 10:17:13 -0000	1.4
@@ -18,6 +18,7 @@
 		if [ "$wc_install" != "true" ]; then return 0; fi
 
 		wc_write_package_config
+		wc_write_global_config
 	fi
 	#wc_update_apache_siteconf
 }

Index: postrm
===================================================================
RCS file: /cvsroot/webapps-common/webapps-common/dpkg/postrm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- postrm	17 Aug 2005 16:40:41 -0000	1.3
+++ postrm	17 Oct 2005 10:17:13 -0000	1.4
@@ -23,9 +23,6 @@
 
 	# actually remove the files only in purge
 	if [ "$wc_command" = "purge" ]; then
-		rm -f $wc_package_confdir/apache.conf || true	
-		ucf -p $wc_package_confdir/apache.conf || true	
-		rm -f $wc_confdir/siteids.d/${wc_package}.conf || true	
-		ucf -p $wc_confdir/siteids.d/${wc_package}.conf || true	
+		wc_purge_httpd_conf
 	fi
 }

Index: prerm
===================================================================
RCS file: /cvsroot/webapps-common/webapps-common/dpkg/prerm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- prerm	17 Aug 2005 16:40:41 -0000	1.1
+++ prerm	17 Oct 2005 10:17:13 -0000	1.2
@@ -4,6 +4,8 @@
 	. /usr/share/webapps-common/dpkg/common
 	wc_config $@
 
+	wc_unconfigure_httpds
+
 	if [ "$wc_command" = "purge" ]; then
 		wc_unregister_templates
 	fi




More information about the Webapps-common-discuss mailing list