Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Timothy Frew
Sympl
Commits
f6c2cfd6
Commit
f6c2cfd6
authored
Jul 07, 2009
by
Steve Kemp
Browse files
Added
parents
Changes
316
Expand all
Hide whitespace changes
Inline
Side-by-side
Makefile
0 → 100644
View file @
f6c2cfd6
#
# Makefile for people working with the bytemark-vhost packages.
#
# Steve
# --
#
SHELL
=
"/bin/bash"
a
:
@
echo
"Valid targets are:"
@
echo
" "
@
echo
"General:"
@
echo
" "
@
echo
" all - Generate all Debian packages [source + binary]."
@
echo
" clean - Clean the generated files."
@
echo
" "
@
echo
"Tests:"
@
echo
" "
@
echo
" linda - Run linda on the built packages."
@
echo
" lintian - Run lintian on the built packages."
@
echo
" "
@
echo
"Misc:"
@
echo
" pool - Builds a local pool structure handy for quick tests."
@
echo
" "
#
# Make all packages.
#
all
:
dependencies
for
i
in
*
/
;
do if
[
`
which sautobuild
`
]
;
then
sautobuild
$$
i
;
else
pushd
$$
i
;
debuild
--no-tgz-check
-sa
-us
-uc
;
popd
;
fi
;
done
-
touch
all
changelog
:
@
date
+%Y%m%d%H%M%S
#
# If we're using sautobuild, then there is no need to check for dependencies
#
dependencies
:
-
[
`
which sautobuild
`
]
||
./meta/dependencies
touch
dependencies
#
# Clean all auto-generated files from beneath the current directory
#
clean
:
-
rm
*
/build-stamp
-
rm
*
/configure-stamp
-
rm
-rf
*
/debian/bytemar
*
/
-
rm
bytemark-vhost[-_]
*
-
rm
all
-
rm
-rf
out/
-
rm
-rf
staging/
-
rm
*
.build
-
rm
dependencies
-
rm
libapache
*
-
find
.
-name
'*.bak'
-delete
-
rm
*
/
*
.1
for
i
in
*
/
;
do
pushd
$$
i
;
if
[
-e
Makefile
]
;
then
make clean
;
fi
;
popd
;
done
#
# Run "linda" on all binary packages to test for Debian policy violations.
#
linda
:
all
linda
*
.changes
#
# Run "lintian" on all binary packages to test for Debian policy violations.
#
lintian
:
all
lintian
*
.changes
#
# Create a suitable pool
#
pool
:
all
[
-d
out
]
||
mkdir
out
for
i
in
*
/debian/.package
;
do
mv
`
cat
$$
i
`
_
*
out
;
done
dpkg-scanpackages out /dev/null |
gzip
>
out/Packages.gz
dpkg-scansources out /dev/null |
gzip
>
out/Sources.gz
#
# Pull any changes from the remote mercurial repository.
#
update
:
hg pull
--update
etch
:
hg update
-C
etch
lenny
:
hg update
-C
lenny
README
0 → 100644
View file @
f6c2cfd6
README
------
This README is intentionally brief. All the details on the Bytemark
Virtual Hosting packages may be found online:
http://vhost.bytemark.co.uk/
Note that the repository has branches for etch + lenny.
Building The Packages
---------------------
You should be able to build all packages via :
make all
Once you're done you'll see a bunch of .deb files in the current
directory. Failures are going to be hard to spot, so do look over
the output to ensure that you see as many packages as you expect.
(Mostly failures will be due to lack of build-dependencies.)
Releasing
---------
To make a new release, visible on http://vhost.bytemark.co.uk/, you
need to run:
make sync-down
Once you've done that you'll find a local tree:
./releases
./releases/live/
./releases/staging/
Remove the obsolete packages and move your newly built ones into place.
Now run
make sync-up
This will copy the files to /staging and /incoming on the vhost machine.
This will place them correctly for releasing.
Finally ssh to vhost and run:
/home/www/vhost.bytemark.co.uk/htdocs/staging/build.sh
or
/home/www/vhost.bytemark.co.uk/htdocs/packages/build.sh
Steve
--
apache/Makefile
0 → 100644
View file @
f6c2cfd6
nop
:
@
echo
"Valid targets are (alphabetically) :"
@
echo
" "
@
echo
" all - Build the module"
@
echo
" install - Build *and* install the module"
@
echo
" "
@
echo
" clean - Remove bogus files."
@
echo
" commit - Commit changes, after running check."
@
echo
" diff - Run a 'cvs diff'."
@
echo
" install - Install the module"
@
echo
" update - Update from the CVS repository."
@
echo
" "
.PHONY
:
@
true
all
:
cd
src
&&
make
test
:
cd
src
&&
make
test
clean
:
cd
src
&&
make clean
@
find
.
-name
'.*~'
-exec
rm
\{\}
\;
@
find
.
-name
'.#*'
-exec
rm
\{\}
\;
@
find
.
-name
'configure-stamp'
-exec
rm
\{\}
\;
@
find
.
-name
'build-stamp'
-exec
rm
\{\}
\;
@
if
[
-d
debian/libapache2-mod-ifier
]
;
then
rm
-rf
debian/libapache2-mod-ifier
;
fi
commit
:
cvs
-z3
commit
diff
:
cvs diff
--unified
2>/dev/null
install
:
cd
src
&&
make
install
apache/README
0 → 100644
View file @
f6c2cfd6
mod_vhost_bytemark
------------------
This is a minimaly modified copy of mod_vhost_alias from the
Apache 2.x source tree.
There are only two minimal changes from the upstream version included
in Debian:
1. The inclusion of the following patch:
https://issues.apache.org/bugzilla/show_bug.cgi?id=26052
2. Updated handling to make /srv/foo.com & /srv/www.foo.com synonyms.
Steve
--
apache/bin/configure-additional
0 → 100755
View file @
f6c2cfd6
#!/usr/bin/perl
#
# This script is designed to configure additional IPs for Apache.
#
# 1. We find the primary IP of the system.
#
# 2. For each additional IP which is not claimed by SSL we configure
# Apache to listen on that too.
#
# Steve
# --
#
use
strict
;
use
warnings
;
use
Getopt::
Long
;
#
# Configuration variables
#
my
%CONFIG
;
#
# Parse command line
#
parseCommandLineArguments
();
#
# Find the IP addresses on the system.
#
my
%IPS
=
findIPs
();
#
# Read each enabled site
#
my
%ENABLED
=
findEnabled
();
#
# Now create files for the ones not listening.
#
foreach
my
$dev
(
keys
%IPS
)
{
my
$ip
=
$IPS
{
$dev
};
next
if
(
$ip
=~
/^127/
);
if
(
$ENABLED
{
$ip
}
)
{
$CONFIG
{'
verbose
'}
&&
print
"
Already enabled
$ip
\n
";
}
else
{
$CONFIG
{'
verbose
'}
&&
print
"
Should create site for:
$ip
\n
";
createSiteFor
(
$ip
);
}
}
#
# If we did create something we need to reload Apache2
#
if
(
$CONFIG
{'
created
'}
)
{
$CONFIG
{'
verbose
'}
&&
print
"
Restarting apache2
\n
";
system
(
"
/etc/init.d/apache2 restart >/dev/null 2>/dev/null
"
);
$CONFIG
{'
verbose
'}
&&
print
"
Done
\n
";
}
#
# All done.
#
exit
;
=begin doc
Parse any command line arguments which might be present.
=end doc
=cut
sub
parseCommandLineArguments
{
if
(
!
GetOptions
(
"
verbose
",
\
$CONFIG
{
'
verbose
'
},
"
prefix=s
",
\
$CONFIG
{
'
prefix
'
},
)
)
{
exit
;
}
}
=begin doc
Find the IP addresses on the system.
=end doc
=cut
sub
findIPs
{
my
$out
=
`
/sbin/ifconfig
`;
my
%results
;
my
$dev
=
undef
;
foreach
my
$line
(
split
(
/[\r\n]/
,
$out
)
)
{
if
(
$line
=~
/^([^ \t]+)[ \t]/
)
{
$dev
=
$
1
;
}
elsif
(
$line
=~
/inet addr:([0-9\.]+)/
)
{
$results
{
$dev
}
=
$
1
;
$dev
=
undef
;
}
}
return
(
%results
);
}
=begin doc
Find the sites which are enabled.
=end doc
=cut
sub
findEnabled
{
my
%listening
;
#
# Read each file.
#
foreach
my
$file
(
sort
(
glob
(
"
/etc/apache2/sites-enabled/*
"
)
)
)
{
open
(
FILE
,
"
<
",
$file
)
or
die
"
Failed to read file
$file
- $!
";
foreach
my
$line
(
<
FILE
>
)
{
if
(
$line
=~
/NameVirtualHost (.*):/
)
{
$listening
{
$
1
}
+=
1
;
}
}
close
(
FILE
);
}
return
(
%listening
);
}
=begin doc
Create the apache configuration file for the given IP.
=end doc
=cut
sub
createSiteFor
{
my
(
$ip
)
=
(
@
_
);
foreach
my
$file
(
qw! zz-mass-hosting zz-mass-hosting.ssl !
)
{
my
$input
=
"
/etc/apache2/sites-enabled/
$file
";
my
$output
=
"
/etc/apache2/sites-enabled/
$file
.
$ip
";
open
(
IN
,
"
<
",
$input
)
or
die
"
Failed to read input:
$input
- $!
";
open
(
OUT
,
"
>
",
$output
)
or
die
"
failed to write output:
$output
- $!
";
foreach
my
$line
(
<
IN
>
)
{
chomp
(
$line
);
if
(
$line
=~
/(.*) ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)(.*)/
)
{
$line
=
$
1
.
"
"
.
$ip
.
$
3
;
}
print
OUT
$line
.
"
\n
";
}
close
(
IN
);
close
(
OUT
);
}
}
apache/bin/create-ssl-sites
0 → 100755
View file @
f6c2cfd6
#!/usr/bin/perl -w
use
strict
;
use
warnings
;
use
Getopt::
Long
;
#
# Configuration variables.
#
my
%CONFIG
;
#
# Default prefix
#
$CONFIG
{
'
prefix
'
}
=
"
/srv
";
#
# Parse any command line arguments.
#
parseCommandLineArguments
();
#
# Now look for domains
#
my
@domains
=
findAllWebDomains
(
$CONFIG
{
'
prefix
'
}
);
#
# Process each domain
#
foreach
my
$domain
(
@domains
)
{
$CONFIG
{
'
verbose
'
}
&&
print
"
Testing
$domain
\n
";
#
# Test and handle the domain.
#
$CONFIG
{
'
changed
'
}
+=
testDomain
(
$domain
);
$CONFIG
{
'
verbose
'
}
&&
print
"
done
\n
";
}
#
# Did we make any changes, if so reload Apache
#
if
(
$CONFIG
{
'
changed
'
}
)
{
$CONFIG
{
'
verbose
'
}
&&
print
"
Reloading Apache
\n
";
system
("
/etc/init.d/apache2 reload
");
}
=begin doc
Parse any command line arguments which might be present.
=end doc
=cut
sub
parseCommandLineArguments
{
if
(
!
GetOptions
(
"
verbose
",
\
$CONFIG
{
'
verbose
'
},
"
prefix=s
",
\
$CONFIG
{
'
prefix
'
},
)
)
{
exit
;
}
}
=begin doc
Find all domains that have a public/htdocs/ directory
=end doc
=cut
sub
findAllWebDomains
{
my
(
$prefix
)
=
(
@
_
);
my
@results
;
foreach
my
$entry
(
sort
(
glob
(
$prefix
.
"
/*/public/htdocs
"
)
)
)
{
if
(
-
d
$entry
)
{
#
# We only care about the domain name.
#
if
(
$entry
=~
/[\\\/]([^\\\/]+)\/public\/htdocs/
)
{
push
(
@results
,
$
1
);
}
}
}
return
(
@results
);
}
=begin doc
Test the domain specified to see if it has:
1. An SSL key.
2. A non-default IP address.
If so create a new apache SSL configuration file for it, and return 1
so that apache is restarted.
=end doc
=cut
sub
testDomain
{
my
(
$domain
)
=
(
@
_
);
#
# We need to look for:
#
# /srv/$domain/config/ssl.key
# /srv/$domain/config/ip
#
# If they are not present then we're not going to even think about
# being SSL-aware.
#
return
0
if
(
!-
e
$CONFIG
{
'
prefix
'
}
.
"
/
$domain
/config/ssl.key
"
);
return
0
if
(
!-
e
$CONFIG
{
'
prefix
'
}
.
"
/
$domain
/config/ip
"
);
#
# OK we have an SSL Key - we also have an IP.
#
# So we need to check:
#
# 1. Is this IP different from the primary IP?
# 2. Is there already an SSL site available for this domain
#
return
0
if
(
-
e
"
/etc/apache2/sites-enabled/
$domain
.ssl
"
);
#
# Get the IP from the file
#
open
(
IP
,
"
<
",
"
$CONFIG
{'prefix'}/
$domain
/config/ip
"
)
or
die
"
Failed to read file - $!
";
my
$ip
=
<
IP
>
;
close
(
IP
);
chomp
(
$ip
);
#
# Get the primary IP of the system to see if the IP matches.
#
my
$host
=
findHostDetails
();
if
(
$host
eq
$ip
)
{
return
0
;
}
my
$bundle
=
"";
if
(
-
e
$CONFIG
{
'
prefix
'
}
.
"
/
$domain
/config/ssl.bundle
"
)
{
$bundle
=
"
SSLCertificateChainFile
$CONFIG
{'prefix'}/
$domain
/config/ssl.bundle
";
}
#
# Now we have all the details we need.
#
open
(
CONFIG
,
"