@ -9,6 +9,7 @@ variables = {
' sogo_server ' : ' mail.server.local '
}
def install ( ) :
# Read local variables file if available
if isfile ( makepath ( programfiles32 , ' wapt ' , ' private ' , ' symetric.txt ' ) ) and isfile ( makepath ( programfiles32 , ' wapt ' , ' private ' , ' variables.txt ' ) ) :
print ( ' Reading local encrypted variables file ' )
@ -17,49 +18,63 @@ if isfile(makepath(programfiles32,'wapt','private','symetric.txt')) and isfile(m
f = Fernet ( open ( makepath ( programfiles32 , ' wapt ' , ' private ' , ' symetric.txt ' ) , ' r ' ) . read ( ) )
variables . update ( yaml . safe_load ( f . decrypt ( open ( makepath ( programfiles32 , ' wapt ' , ' private ' , ' variables.txt ' ) , ' r ' ) . read ( ) ) ) )
def install ( ) :
connector_version = control [ ' version ' ] . split ( ' - ' , 1 ) [ 0 ]
integrator_version = connector_version
major_version = control [ ' version ' ] . split ( ' . ' , 1 ) [ 0 ]
extension_dir = makepath ( programfiles , ' Mozilla Thunderbird ' , ' distribution ' , ' extensions ' )
for extension in [ ' connector ' , ' integrator ' ] :
if isdir ( makepath ( programfiles , ' Mozilla Thunderbird ' , ' distribution ' , ' extensions ' , ' sogo- %s @inverse.ca ' % extension ) ) :
remove_tree ( makepath ( programfiles , ' Mozilla Thunderbird ' , ' distribution ' , ' extensions ' , ' sogo- %s @inverse.ca ' % extension ) )
mkdirs ( makepath ( programfiles , ' Mozilla Thunderbird ' , ' distribution ' , ' extensions ' , ' sogo- %s @inverse.ca ' % extension ) )
if isdir ( makepath ( extension_dir , ' sogo- %s @inverse.ca ' % extension ) ) :
remove_tree ( makepath ( extension_dir , ' sogo- %s @inverse.ca ' % extension ) )
if isfile ( makepath ( extension_dir , ' sogo- %s @inverse.ca.xpi ' % extension ) ) :
remove_file ( makepath ( extension_dir , ' sogo- %s @inverse.ca.xpi ' % extension ) )
mkdirs ( makepath ( extension_dir , ' sogo-connector@inverse.ca ' ) )
# connector can be extracted as is
unzip ( ' sogo-connector- %s .xpi ' % connector_version , makepath ( programfiles , ' Mozilla Thunderbird ' , ' distribution ' , ' extensions ' , ' sogo-connector@inverse.ca ' ) )
# The extension must be customized, so first extract it
print ( ' Extraction demo extension ' )
unzip ( ' sogo-connector- %s -demo.xpi ' % connector_version , makepath ( extension_dir , ' sogo-connector@inverse.ca ' ) )
# Integrator must be customized, so first extract it
unzip ( ' sogo-integrator- %s -sogo-demo.xpi ' % integrator_version , makepath ( programfiles , ' Mozilla Thunderbird ' , ' distribution ' , ' extensions ' , ' sogo-integrator@inverse.ca ' ) )
# And replace the extensions.rdf content
print ( ' Customizing extension ' )
jinja2 = Environment (
loader = FileSystemLoader ( os . path . dirname ( os . path . abspath ( __file__ ) ) ) ,
trim_blocks = True
)
open ( makepath ( programfiles , ' Mozilla Thunderbird ' , ' distribution ' , ' extensions ' , ' sogo-integrator@inverse.ca ' , ' chrome ' , ' content ' , ' extensions.rdf ' ) , ' w ' ) . write (
open ( makepath ( extension_dir , ' sogo-connector@inverse.ca ' , ' chrome ' , ' content ' , ' sogo-connector ' , ' global ' , ' extensions.rdf ' ) , ' w ' ) . write (
jinja2 . get_template ( ' extensions.rdf.j2 ' ) . render (
sogo_server = variables [ ' sogo_server ' ]
)
)
# Also remove custom settings
os . unlink ( makepath ( programfiles , ' Mozilla Thunderbird ' , ' distribution ' , ' extensions ' , ' sogo-integra tor@inverse.ca ' , ' defaults ' , ' preferences ' , ' site.js ' ) )
os . unlink ( makepath ( extension_dir , ' sogo-connec tor@inverse.ca ' , ' defaults ' , ' preferences ' , ' site.js ' ) )
# Now create an XPI
print ( ' Creating XPI ' )
run ( r ' " %s " a -tzip " %s " " %s " ' % ( makepath ( programfiles , ' 7-Zip ' , ' 7z.exe ' ) , makepath ( extension_dir , ' sogo-connector@inverse.ca.xpi ' ) , makepath ( extension_dir , ' sogo-connector@inverse.ca ' , ' * ' ) ) )
# Note : we could remove the extension directory, but we keep it for easier auditing
# Script to reset extensions.json and addonStartup.json.lz4, those files need to be removed
# for sogo-connector to be correctly loaded. At least for the 60.x -> 68.x upgrade
print ( ' Deploy reset_addons.bat script ' )
open ( makepath ( programfiles , ' Mozilla Thunderbird ' , ' reset_addons.bat ' ) , ' w ' ) . write (
jinja2 . get_template ( ' reset_addons.bat.j2 ' ) . render (
tb_major_version = major_version
)
)
def uninstall ( ) :
print ( ' Removing SOGo extensions for Thunderbird ' )
for extension in [ ' connector ' , ' integrator ' ] :
remove_tree ( makepath ( programfiles , ' Mozilla Thunderbird ' , ' distribution ' , ' extensions ' , ' sogo- %s @inverse.ca ' % extension ) )
print ( ' Removing SOGo connector for Thunderbird ' )
remove_tree ( makepath ( programfiles , ' Mozilla Thunderbird ' , ' distribution ' , ' extensions ' , ' sogo-connector@inverse.ca ' % extension ) )
def session_setup ( ) :
print ( ' Reset Thunderbird addons settings on major upgrades ' )
run ( makepath ( programfiles , ' Mozilla Thunderbird ' , ' reset_addons.bat ' ) )
def audit ( ) :
connector_version = control [ ' version ' ] . split ( ' - ' , 1 ) [ 0 ]
integrator_version = connector_version
try :
run ( ' type " %s " | find /I " em:version= " | find " %s " ' % ( makepath ( programfiles , ' Mozilla Thunderbird ' , ' distribution ' , ' extensions ' , ' sogo-connector@inverse.ca ' , ' install.rdf ' ) , connector_version ) )
except :
print ( ' SOGO connector version check failed ' )
return " ERROR "
try :
run ( ' type " %s " | find /I " em:version= " | find " %s " ' % ( makepath ( programfiles , ' Mozilla Thunderbird ' , ' distribution ' , ' extensions ' , ' sogo-integrator@inverse.ca ' , ' install.rdf ' ) , integrator_version ) )
except :
print ( ' SOGO integrator version check failed ' )
return " ERROR "
return " OK "