From 3045436a1e737367f61c6b912d38e97b1e41a2e8 Mon Sep 17 00:00:00 2001 From: Arno Töll Date: Tue, 3 Apr 2012 23:06:42 +0200 Subject: Add a helper script to rename sites following our .conf suffix requirement --- debian/apache2.NEWS | 13 +++++++---- debian/apache2.docs | 1 + debian/changelog | 4 +++- debian/migrate-sites.pl | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 debian/migrate-sites.pl diff --git a/debian/apache2.NEWS b/debian/apache2.NEWS index 68586461..3f5f39b6 100644 --- a/debian/apache2.NEWS +++ b/debian/apache2.NEWS @@ -26,16 +26,21 @@ apache2 (2.4.1-1) experimental; urgency=low supported anymore and works just like {sites,mods}-{available,enabled} by using the "a2enconf" tool. The upgrade tries to migrate known configuration files from /etc/apache2/conf.d/ to /etc/apache2/conf-available/ - please - review this changes. In addition, the default site was renamed to - 000-default to avoid naming confusions. The rename of the config files to - *.conf makes the special handling inside apache2 to ignore *.dpkg-* backup - files obsolete. This special handling has been removed. + review this changes. + Note this means all existing sites are ignored until they get a ".conf" suffix + and are being re-enabled by the use of a2ensite. The script in [3] can + automate that for simple cases. This change also includes Debian default + sites, hence the default site was renamed to 000-default to avoid naming + confusions. The rename of the config files to *.conf makes the special + handling inside apache2 to ignore *.dpkg-* backup files obsolete. This special + handling has been removed. Packagers are advised to review their packages whether they comply with this new version. Please see [2] for detailed documentation and instructions [1] http://httpd.apache.org/docs/2.4/howto/auth.html [2] + [3] -- Arno Töll Fri, 02 Mar 2012 17:38:23 +0100 diff --git a/debian/apache2.docs b/debian/apache2.docs index 6de97478..5000c3b4 100644 --- a/debian/apache2.docs +++ b/debian/apache2.docs @@ -1,3 +1,4 @@ debian/README.backtrace debian/README.multiple-instances debian/PACKAGING +debian/migrate-sites.pl diff --git a/debian/changelog b/debian/changelog index 27352947..f4297560 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,8 +7,10 @@ apache2 (2.4.1-4) experimental; urgency=low * Fix "dh_apache2 does not set "x" bits on /usr/lib/apache2/modules/" Set directory permissions to 755 by default (Closes: #666875). Thanks Axel Beckert for the hint. + * Add /usr/share/doc/apache2/migrate-sites.pl, a script to assist users to + give sites a .conf suffix, add a hint to the NEWS file. - -- Arno Töll Mon, 02 Apr 2012 10:49:09 +0200 + -- Arno Töll Tue, 03 Apr 2012 22:47:47 +0200 apache2 (2.4.1-3) experimental; urgency=low diff --git a/debian/migrate-sites.pl b/debian/migrate-sites.pl new file mode 100644 index 00000000..82968448 --- /dev/null +++ b/debian/migrate-sites.pl @@ -0,0 +1,62 @@ +#! /usr/bin/perl + +# +# Rename existing sites in $SITES_AVAILABLE to make sure they have a +# .conf suffix. update symlinks in $SITES_ENABLED if necessary +# +# Warning: This script does not work if you didn't use a2ensite/a2dissite to +# manage your sites +# + +use strict; +use File::Copy; +use File::Spec; +use File::Basename; + +my $SITES_AVAILABLE = "/etc/apache2/sites-available"; +my $SITES_ENABLED = "/etc/apache2/sites-enabled"; + +my %SITES = ( + "$SITES_AVAILABLE" => [], + "$SITES_ENABLED" => [] +); + +sub error +{ + my $reason = shift; + print STDERR "$reason\n"; + exit 1; +} + +foreach my $key (keys %SITES) +{ + error("No such directory: $key") unless -d $key; + + opendir(DIR, $key) || error("$key: $!"); + push $SITES{$key}, grep { m#^[^\.]# && $_ !~ m/default|default-ssl/ && $_ !~ m#\.conf$# } readdir(DIR); + closedir(DIR); +} + +foreach my $site (@{ $SITES{$SITES_AVAILABLE} }) +{ + print("rename $site -> $site.conf\n"); + my $curname = $SITES_AVAILABLE . "/" . $site; + my $newname = $curname . ".conf"; + my $curlink = $SITES_ENABLED . "/" . $site; + my $newlink = $curlink . ".conf"; + + if (-e $curname) + { + move($curname, $newname) || error("Could not rename file $curname: $!"); + if ( grep { $_ eq $site && -l $SITES_ENABLED . "/" . $_ } @{ $SITES{$SITES_ENABLED} } ) + { + print("re-enable site: $site as $site.conf\n"); + symlink( File::Spec->abs2rel( $newname, dirname($newlink)), $newlink ) || error("Could not create link $newlink: $1"); + if ( -l $curlink ) + { + unlink($curlink) + } + } + } +} + -- cgit v1.2.3