Changeset View
Changeset View
Standalone View
Standalone View
pykolab/setup/setup_roundcube.py
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | rc_settings = { | ||||
'ldap_service_bind_pw': conf.get('ldap', 'service_bind_pw'), | 'ldap_service_bind_pw': conf.get('ldap', 'service_bind_pw'), | ||||
'ldap_user_base_dn': conf.get('ldap', 'user_base_dn'), | 'ldap_user_base_dn': conf.get('ldap', 'user_base_dn'), | ||||
'ldap_user_filter': conf.get('ldap', 'user_filter'), | 'ldap_user_filter': conf.get('ldap', 'user_filter'), | ||||
'primary_domain': conf.get('kolab','primary_domain'), | 'primary_domain': conf.get('kolab','primary_domain'), | ||||
'mysql_uri': 'mysqli://roundcube:%s@localhost/roundcube' % (mysql_roundcube_password), | 'mysql_uri': 'mysqli://roundcube:%s@localhost/roundcube' % (mysql_roundcube_password), | ||||
'conf': conf | 'conf': conf | ||||
} | } | ||||
if os.access('/usr/share/roundcubemail/skins/enterprise/', os.R_OK): | rc_paths = [ | ||||
"/usr/share/roundcubemail/", | |||||
"/usr/share/roundcube/", | |||||
"/srv/www/roundcubemail/", | |||||
"/var/www/roundcubemail/" | |||||
] | |||||
rcpath = '' | |||||
for rc_path in rc_paths: | |||||
if os.path.isdir(rc_path): | |||||
rcpath = rc_path | |||||
break | |||||
if not os.path.isdir(rcpath): | |||||
log.error(_("Roundcube installation path not found.")) | |||||
return | |||||
if os.access(rcpath + 'skins/enterprise/', os.R_OK): | |||||
rc_settings['skin'] = 'enterprise' | rc_settings['skin'] = 'enterprise' | ||||
elif os.access('/usr/share/roundcubemail/skins/chameleon/', os.R_OK): | elif os.access(rcpath + 'skins/chameleon/', os.R_OK): | ||||
rc_settings['skin'] = 'chameleon' | rc_settings['skin'] = 'chameleon' | ||||
else: | else: | ||||
rc_settings['skin'] = 'larry' | rc_settings['skin'] = 'larry' | ||||
want_files = [ | want_files = [ | ||||
'acl.inc.php', | 'acl.inc.php', | ||||
'calendar.inc.php', | 'calendar.inc.php', | ||||
'config.inc.php', | 'config.inc.php', | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | for root, directories, filenames in os.walk('/usr/share/doc/'): | ||||
schema_filepath = os.path.join(nested_root,filename) | schema_filepath = os.path.join(nested_root,filename) | ||||
if not schema_filepath in schema_files: | if not schema_filepath in schema_files: | ||||
schema_files.append(schema_filepath) | schema_files.append(schema_filepath) | ||||
if len(schema_files) > 0: | if len(schema_files) > 0: | ||||
break | break | ||||
break | break | ||||
if os.path.isdir('/usr/share/roundcubemail'): | |||||
rcpath = '/usr/share/roundcubemail/' | |||||
elif os.path.isdir('/usr/share/roundcube'): | |||||
rcpath = '/usr/share/roundcube/' | |||||
else: | |||||
log.error(_("Roundcube installation path not found.")) | |||||
return | |||||
for root, directories, filenames in os.walk(rcpath + 'plugins/calendar/drivers/kolab/'): | for root, directories, filenames in os.walk(rcpath + 'plugins/calendar/drivers/kolab/'): | ||||
for filename in filenames: | for filename in filenames: | ||||
if filename.startswith('mysql') and filename.endswith('.sql'): | if filename.startswith('mysql') and filename.endswith('.sql'): | ||||
schema_filepath = os.path.join(root,filename) | schema_filepath = os.path.join(root,filename) | ||||
if not schema_filepath in schema_files: | if not schema_filepath in schema_files: | ||||
schema_files.append(schema_filepath) | schema_files.append(schema_filepath) | ||||
for root, directories, filenames in os.walk(rcpath + 'plugins/libkolab/'): | for root, directories, filenames in os.walk(rcpath + 'plugins/libkolab/'): | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | """ % (mysql_root_password) | ||||
elif os.path.isdir('/etc/roundcube/'): | elif os.path.isdir('/etc/roundcube/'): | ||||
rccpath = "/etc/roundcube" | rccpath = "/etc/roundcube" | ||||
else: | else: | ||||
log.warning(_("Cannot find the configuration directory for roundcube.")) | log.warning(_("Cannot find the configuration directory for roundcube.")) | ||||
rccpath = None | rccpath = None | ||||
root_uid = 0 | root_uid = 0 | ||||
for webserver_group in [ 'apache', 'www-data' ]: | for webserver_group in [ 'apache', 'www-data', 'www' ]: | ||||
try: | try: | ||||
(a,b,webserver_gid,c) = grp.getgrnam(webserver_group) | (a,b,webserver_gid,c) = grp.getgrnam(webserver_group) | ||||
break | break | ||||
except Exception, errmsg: | except Exception, errmsg: | ||||
pass | pass | ||||
if not rccpath == None: | if not rccpath == None: | ||||
for root, directories, filenames in os.walk(rccpath): | for root, directories, filenames in os.walk(rccpath): | ||||
for filename in filenames: | for filename in filenames: | ||||
os.chown(os.path.join(root, filename), root_uid, webserver_gid) | os.chown(os.path.join(root, filename), root_uid, webserver_gid) | ||||
httpservice = 'httpd.service' | |||||
if os.path.isfile('/usr/lib/systemd/system/apache2.service'): | |||||
httpservice = 'apache2.service' | |||||
if os.path.isfile('/bin/systemctl'): | if os.path.isfile('/bin/systemctl'): | ||||
if os.path.isfile('/etc/debian_version'): | subprocess.call(['/bin/systemctl', 'restart', httpservice]) | ||||
subprocess.call(['/bin/systemctl', 'restart', 'apache2.service']) | |||||
else: | |||||
subprocess.call(['/bin/systemctl', 'restart', 'httpd.service']) | |||||
elif os.path.isfile('/sbin/service'): | elif os.path.isfile('/sbin/service'): | ||||
subprocess.call(['/sbin/service', 'httpd', 'restart']) | subprocess.call(['/sbin/service', 'httpd', 'restart']) | ||||
elif os.path.isfile('/usr/sbin/service'): | elif os.path.isfile('/usr/sbin/service'): | ||||
subprocess.call(['/usr/sbin/service','apache2','restart']) | subprocess.call(['/usr/sbin/service','apache2','restart']) | ||||
else: | else: | ||||
log.error(_("Could not start the webserver server service.")) | log.error(_("Could not start the webserver server service.")) | ||||
if os.path.isfile('/bin/systemctl'): | if os.path.isfile('/bin/systemctl'): | ||||
if os.path.isfile('/etc/debian_version'): | subprocess.call(['/bin/systemctl', 'enable', httpservice]) | ||||
subprocess.call(['/bin/systemctl', 'enable', 'apache2.service']) | |||||
else: | |||||
subprocess.call(['/bin/systemctl', 'enable', 'httpd.service']) | |||||
elif os.path.isfile('/sbin/chkconfig'): | elif os.path.isfile('/sbin/chkconfig'): | ||||
subprocess.call(['/sbin/chkconfig', 'httpd', 'on']) | subprocess.call(['/sbin/chkconfig', 'httpd', 'on']) | ||||
elif os.path.isfile('/usr/sbin/update-rc.d'): | elif os.path.isfile('/usr/sbin/update-rc.d'): | ||||
subprocess.call(['/usr/sbin/update-rc.d', 'apache2', 'defaults']) | subprocess.call(['/usr/sbin/update-rc.d', 'apache2', 'defaults']) | ||||
else: | else: | ||||
log.error(_("Could not configure to start on boot, the " + \ | log.error(_("Could not configure to start on boot, the " + \ | ||||
"webserver server service.")) | "webserver server service.")) | ||||