Skip to content

Instantly share code, notes, and snippets.

@robbat2
Last active August 29, 2015 14:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robbat2/a4b02e87cc23282790b7 to your computer and use it in GitHub Desktop.
Save robbat2/a4b02e87cc23282790b7 to your computer and use it in GitHub Desktop.
Evergreen env setting magic
# PerlAddVar is only evaluated at apache startup time
# So you cannot dynamically build things like OILSWebTemplatePath in the apache config
# You could build it in a block of Perl, but that's not great when you have the rest of the config in Apache already
#
# Step 1.
# Add this to EGWeb.pm:
# Immediately below where it's being set already, before it's reversed and stored.
# @template_paths = split(/:/, $ENV{'OILSWebTemplatePath'}) if defined($ENV{'OILSWebTemplatePath'});
# In future, it might be handle to have similar functionality for other settings.
#
# Step 2. Apache 2.4 config
# Will NOT work on older versions of apache
Define eg_localstatedir /srv/openils/var
Define eg_sysconfdir /srv/openils/etc
Define eg_bindir /srv/openils/bin
<VirtualHost *:80>
ServerName catalogue.libraries.coop
ServerAlias *.catalogue.libraries.coop
# Base detection stuff
# You should probably tweak this, it's a simplified version for this Gist
SetEnvIfNoCase Host ^(?:(?:app|dev|testing|training|migration)[0-9]+\.)?catalogue\.libraries\.coop$ shortname=default
SetEnvIfNoCase Host ^(.+)(?:\.(?:app|dev|testing|training|migration)[0-9]+)\.catalogue\.libraries\.coop$ shortname=$1
# Extra detection, built from data
# You should probably tweak this, it's a simplified version for this Gist
SetEnvIfNoCase Host ^whistler.bc(?:\.(?:app|dev|testing|training|migration)[0-9]+)?\.catalogue\.libraries\.coop$
# ...
# Fallback
SetEnvIfNoCase shortname ^$ shortname=default
# The following blocks are built from data
SetEnvIfNoCase shortname ^default$ \
physical_loc=1 \
prov=bc \
orgid=1 \
skin=default \
shortname=default \
!locg \
bibliocommons=0 \
!bibc_hostname
SetEnvIfNoCase shortname ^ABLB$ \
physical_loc=1101 \
prov=mb \
orgid=1101 \
skin=ABLB \
shortname=ABLB \
!locg \
bibliocommons=0 \
!bibc_hostname
SetEnvIfNoCase shortname ^BW$ \
physical_loc=10 \
prov=bc \
orgid=10 \
skin=BW \
shortname=BW \
!locg \
bibliocommons=1 \
bibc_hostname=whistler \
OILS_NOVELIST_URL=https://... \
OILS_NOVELIST_PROFILE=... \
OILS_NOVELIST_PASSWORD=...
# ...
# End of built blocks
# This is the fallback case
SetEnvIf shortname ^default$ \
physical_loc=1 \
prov=bc \
orgid=1 \
skin=default \
shortname=default \
!locg \
bibliocommons=0 \
!bibc_hostname
# Include rewrites, that use the variables above
Include .../499.rewrites.conf-include
# Now include the vhost config, modified slightly to take variables
Include .../eg_vhost.conf-include
<Location /eg>
# We validate the the skin is actually a directory that exists before using it
# There is no trivial way to merge two settings, so sadly we have to write it out in full here.
<If "-n '%{reqenv:skin}' && -d '${eg_localstatedir}/skins/%{reqenv:skin}'">
SetEnvIfNoCase skin ^(.*)$ \
OILSWebTemplatePath=${eg_localstatedir}/templates:${eg_localstatedir}/templates_SITKA:${eg_localstatedir}/skins/$1
</If>
<Else>
SetEnvIfNoCase skin ^(.*)$ \
OILSWebTemplatePath=${eg_localstatedir}/templates:${eg_localstatedir}/templates_SITKA
</Else>
</Location>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment