Hi!

> As I am testing this also at the moment.
> How do people handle the upgrade? As the version 60 plug-in doesn't work
> on TB version 52 and the version 31 plug-in does not pull the update if
> it is running on a version 60 Thunderbird.
> I would hate to manually install the plug-in for >100 Users.
We've been using a simple python cgi script for ages that evolved out
of updates.php (we rather don't feel too comfortable with having php
installed on our servers).
Find a version of this script attached that has some of our more
specific adaptions ripped out and does just a versioned delivery of
plugins based on the HTTP_USER_AGENT variable which contains the
Thunderbird version.
The script could be extended to selectively update the plugin for
certain ip ranges in your network to allow more fine grained control
over which departments do get an update and so on. That way you could
do some more field testing before rolling out a release.

Hope this helps...

-- Adi

PS: Although I added TB60 to the script, the update isn't working for us
either with TB60 and we'd be happy if someone could help us find a
solution... :-)
-- 
users@sogo.nu
https://inverse.ca/sogo/lists
#!/usr/bin/env python

import os
import cgi
import sys
import re
try:
    from urllib import unquote
except:
    from urllib.parse import unquote

TBVersion = os.environ.get("HTTP_USER_AGENT")

# current plugin versions and filenames
if "Thunderbird/24." in TBVersion or "Icedove/24." in TBVersion:
    plugins = {
        "sogo-connec...@inverse.ca": {
            "version": "24.0.7",
            "filename": "sogo-connector-24.0.7.xpi"
        },
        "sogo-integra...@inverse.ca": {
            "version": "24.0.7-0-ourcorp",
            "filename": "sogo-integrator-24.0.7-0-ourcorp.xpi"
        },
    }
elif "Thunderbird/31." in TBVersion or "Icedove/31." in TBVersion:
    plugins = {
        "sogo-connec...@inverse.ca": {
            "version": "31.0.1",
            "filename": "sogo-connector-31.0.1.xpi"
        },
        "sogo-integra...@inverse.ca": {
            "version": "31.0.0-0-ourcorp",
            "filename": "sogo-integrator-31.0.0-0-ourcorp.xpi"
        },
    }
elif "Thunderbird/45." in TBVersion or "Icedove/45." in TBVersion:
    plugins = {
        "sogo-connec...@inverse.ca": {
            "version": "31.0.4",
            "filename": "sogo-connector-31.0.4.xpi"
        },
        "sogo-integra...@inverse.ca": {
            "version": "31.0.4-0-ourcorp",
            "filename": "sogo-integrator-31.0.4-0-ourcorp.xpi"
        },
    }
elif "Thunderbird/60." in TBVersion:
    plugins = {
        "sogo-connec...@inverse.ca": {
            "version": "60.0.0pre3",
            "filename": "sogo-connector-60.0.0pre3.xpi"
        },
        "sogo-integra...@inverse.ca": {
            "version": "60.0.0pre3",
            "filename": "sogo-integrator-60.0.0pre3.xpi"
        },
    }
else:
    # current TB: 52
    plugins = {
        "sogo-connec...@inverse.ca": {
            "version": "31.0.6-1",
            "filename": "sogo-connector-31.0.6-1.xpi"
        },
        "sogo-integra...@inverse.ca": {
            "version": "31.0.6-1-ourcorp",
            "filename": "sogo-integrator-31.0.6-1-ourcorp.xpi"
        },
    }

# form data - convert to simple dictionary
formFS = cgi.FieldStorage()
form = dict((key, formFS.getvalue(key)) for key in formFS.keys())


# validate input and return either safe or empty string
def checkInput(unsafeInput):
    # safe input may consist of only A-Za-z0-9_-.@{}
    return unsafeInput if re.match("^[A-Za-z0-9.\-_@{}]+$", unsafeInput) \
                       else ""


# error handler
def exitWith404():
    print("Status: 404 Not found")
    print("Content-type: text/plain\n")
    print("Plugin not found")
    sys.exit(0)


# send back XML answer
def deliverPluginRDF(answer):
    print("Content-type: text/xml; charset=utf-8\n")
    print("""<?xml version="1.0"?>
<!DOCTYPE RDF>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
  xmlns:em="http://www.mozilla.org/2004/em-rdf#";>
  <Description about="urn:mozilla:extension:%(name)s">
    <em:updates>
      <Seq>
        <li>
          <Description>
            <em:version>%(version)s</em:version>
            <em:targetApplication>
              <Description><em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
                <em:minVersion>24.0</em:minVersion>
                <em:maxVersion>60.*</em:maxVersion>
                <em:updateLink>https://sogo.ourcorp.com/%(filename)s</em:updateLink>
          </Description>
            </em:targetApplication>
          </Description>
        </li>
      </Seq>
    </em:updates>
  </Description>
</RDF>
""" % answer)
    sys.exit(0)


# get user request
req = {
    'name': checkInput(unquote(form.get("plugin", ""))),
    'platform': checkInput(unquote(form.get("platform", "")))
}

# construct path to plugin
if req.get("name") in plugins:
    plugin_path = "plugins" + "/" + req.get("platform") + "/" + \
                  plugins.get(req.get("name")).get("filename")
else:
    exitWith404()

# check request
if os.path.isfile(plugin_path):
    answer = {
        "name": req.get("name"),
        "version": plugins.get(req.get("name")).get("version"),
        "filename": plugin_path
    }
    deliverPluginRDF(answer)
else:
    exitWith404()

Reply via email to