local posix = require 'posix'
local TEMPL = [=[
Project !PROJ! is retired.
]=]
local PROG = '/scripts/add-banner.lua/' ;
local ATTIC_DIR = '/var/www/attic.apache.org/'
local ATTIC_PRJS = ATTIC_DIR .. 'flagged/'
function exists(f) return posix.stat(f) ~= nil end
function in_attic(p) return exists ( ATTIC_PRJS .. p ) end
function handle(r)
local get = r:parseargs()
local err = nil
local HOST = r.hostname
local PROJ, _ = string.gsub ( HOST, '.apache.org', '' )
local PATH = r.path_info
local TEST = false
r.content_type = "text/html"
-- r:puts ( r.unparsed_uri .. "
\n" )
-- for k, v in pairs ( get ) do
-- r:puts( string.format("arg [%s] [%s]
\n", k, v) )
-- end
if not TEST and not get.test and not in_attic(HOST) then
err = "project is not in attic"
.. " PROJ [" .. PROJ .. "]"
.. " HOST [" .. HOST .. "]"
.. " PATH [" .. PATH .. "]"
end
if err ~= nil then
r:puts(err)
else
local text = TEMPL
local subs =
{ ['!PROJ!'] = PROJ
, ['!HOST!'] = HOST
, ['!PATH!'] = PATH
}
for k, v in pairs ( subs ) do text, _ = string.gsub ( text, k, v ) end
r:puts(text)
end
return apache2.OK
end