Added better support for domain account migration
This commit is contained in:
parent
1b9007a1f1
commit
739fab2887
|
@ -1,9 +1,15 @@
|
||||||
import pkgutil
|
import pkgutil
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
from .. import settings
|
||||||
|
|
||||||
|
|
||||||
class WebAppServiceMixin(object):
|
class WebAppServiceMixin(object):
|
||||||
model = 'webapps.WebApp'
|
model = 'webapps.WebApp'
|
||||||
|
directive = None
|
||||||
|
|
||||||
|
def valid_directive(self, webapp):
|
||||||
|
return settings.WEBAPPS_TYPES[webapp.type]['directive'][0] == self.directive
|
||||||
|
|
||||||
def create_webapp_dir(self, context):
|
def create_webapp_dir(self, context):
|
||||||
self.append(textwrap.dedent("""
|
self.append(textwrap.dedent("""
|
||||||
|
|
|
@ -12,8 +12,11 @@ from .. import settings
|
||||||
class PHPFcgidBackend(WebAppServiceMixin, ServiceController):
|
class PHPFcgidBackend(WebAppServiceMixin, ServiceController):
|
||||||
""" Per-webapp fcgid application """
|
""" Per-webapp fcgid application """
|
||||||
verbose_name = _("PHP-Fcgid")
|
verbose_name = _("PHP-Fcgid")
|
||||||
|
directive = 'fcgi'
|
||||||
|
|
||||||
def save(self, webapp):
|
def save(self, webapp):
|
||||||
|
if not self.valid_directive(webapp):
|
||||||
|
return
|
||||||
context = self.get_context(webapp)
|
context = self.get_context(webapp)
|
||||||
self.create_webapp_dir(context)
|
self.create_webapp_dir(context)
|
||||||
self.append("mkdir -p %(wrapper_dir)s" % context)
|
self.append("mkdir -p %(wrapper_dir)s" % context)
|
||||||
|
@ -27,6 +30,8 @@ class PHPFcgidBackend(WebAppServiceMixin, ServiceController):
|
||||||
self.append("chown -R %(user)s.%(group)s %(wrapper_dir)s" % context)
|
self.append("chown -R %(user)s.%(group)s %(wrapper_dir)s" % context)
|
||||||
|
|
||||||
def delete(self, webapp):
|
def delete(self, webapp):
|
||||||
|
if not self.valid_directive(webapp):
|
||||||
|
return
|
||||||
context = self.get_context(webapp)
|
context = self.get_context(webapp)
|
||||||
self.append("rm '%(wrapper_path)s'" % context)
|
self.append("rm '%(wrapper_path)s'" % context)
|
||||||
self.delete_webapp_dir(context)
|
self.delete_webapp_dir(context)
|
||||||
|
|
|
@ -13,8 +13,11 @@ from .. import settings
|
||||||
class PHPFPMBackend(WebAppServiceMixin, ServiceController):
|
class PHPFPMBackend(WebAppServiceMixin, ServiceController):
|
||||||
""" Per-webapp php application """
|
""" Per-webapp php application """
|
||||||
verbose_name = _("PHP-FPM")
|
verbose_name = _("PHP-FPM")
|
||||||
|
directive = 'fpm'
|
||||||
|
|
||||||
def save(self, webapp):
|
def save(self, webapp):
|
||||||
|
if not self.valid_directive(webapp)
|
||||||
|
return
|
||||||
context = self.get_context(webapp)
|
context = self.get_context(webapp)
|
||||||
self.create_webapp_dir(context)
|
self.create_webapp_dir(context)
|
||||||
self.append(textwrap.dedent("""\
|
self.append(textwrap.dedent("""\
|
||||||
|
@ -39,6 +42,8 @@ class PHPFPMBackend(WebAppServiceMixin, ServiceController):
|
||||||
}"""))
|
}"""))
|
||||||
|
|
||||||
def get_context(self, webapp):
|
def get_context(self, webapp):
|
||||||
|
if not self.valid_directive(webapp):
|
||||||
|
return
|
||||||
context = super(PHPFPMBackend, self).get_context(webapp)
|
context = super(PHPFPMBackend, self).get_context(webapp)
|
||||||
context.update({
|
context.update({
|
||||||
'init_vars': self.get_php_init_vars(webapp),
|
'init_vars': self.get_php_init_vars(webapp),
|
||||||
|
|
|
@ -7,11 +7,16 @@ from . import WebAppServiceMixin
|
||||||
|
|
||||||
class StaticBackend(WebAppServiceMixin, ServiceController):
|
class StaticBackend(WebAppServiceMixin, ServiceController):
|
||||||
verbose_name = _("Static")
|
verbose_name = _("Static")
|
||||||
|
directive = 'static'
|
||||||
|
|
||||||
def save(self, webapp):
|
def save(self, webapp):
|
||||||
|
if not self.valid_directive(webapp):
|
||||||
|
return
|
||||||
context = self.get_context(webapp)
|
context = self.get_context(webapp)
|
||||||
self.create_webapp_dir(context)
|
self.create_webapp_dir(context)
|
||||||
|
|
||||||
def delete(self, webapp):
|
def delete(self, webapp):
|
||||||
|
if not self.valid_directive(webapp):
|
||||||
|
return
|
||||||
context = self.get_context(webapp)
|
context = self.get_context(webapp)
|
||||||
self.delete_webapp_dir(context)
|
self.delete_webapp_dir(context)
|
||||||
|
|
|
@ -42,7 +42,7 @@ class WebApp(models.Model):
|
||||||
|
|
||||||
def get_path(self):
|
def get_path(self):
|
||||||
context = {
|
context = {
|
||||||
'home': webapp.get_user().get_home(),
|
'home': self.get_user().get_home(),
|
||||||
'app_name': self.name,
|
'app_name': self.name,
|
||||||
}
|
}
|
||||||
return settings.WEBAPPS_BASE_ROOT % context
|
return settings.WEBAPPS_BASE_ROOT % context
|
||||||
|
|
Loading…
Reference in New Issue