Пример #1
0
class Nginx(WebserverPlugin):
    platforms = ['debian', 'centos', 'freebsd', 'arch', 'mageia', 'osx']
    service_name = platform_select(
        default='nginx',
        osx='org.macports.nginx',
    )
    service_buttons = [
        {
            'command': 'force-reload',
            'text': _('Reload'),
            'icon': 'reload',
        }
    ]
    hosts_available_dir = platform_select(
        debian='/etc/nginx/sites-available',
        centos='/etc/nginx/conf.d',
        mageia='/etc/nginx/conf.d',
        freebsd='/usr/local/etc/nginx/conf.d',
        arch='/etc/nginx/sites-available',
        osx='/opt/local/etc/nginx',
    )
    hosts_enabled_dir = '/etc/nginx/sites-enabled'
    supports_host_activation = platform_select(
        debian=True,
        arch=True,
        default=False,
    )

    configurable = True
    main_conf_files = platform_select(
        debian=['/etc/nginx/nginx.conf', '/etc/nginx/proxy_params', '/etc/nginx/fastcgi_params',
                '/etc/nginx/scgi_params', '/etc/nginx/uwsgi_params'],
        centos=['/etc/nginx/nginx.conf', '/etc/nginx/fastcgi_params',
                '/etc/nginx/scgi_params', '/etc/nginx/uwsgi_params'],
        default=[],
    )

    template = """server {
    server_name name;
    access_log /var/log/nginx/name.access.log;
    error_log  /var/log/nginx/name.error.log;

    listen 80;

    location / {
        root /var/www/name;
    }

    location ~ \.lang$ {
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:port;
        fastcgi_split_path_info ^()(.*)$;
    }
}
"""

    def init(self):
        self.title = 'NGINX'
        self.category = _('Software')
        self.icon = 'globe'
Пример #2
0
class Apache(WebserverPlugin):
    service_name = platform_select(default='apache2',
                                   osx='org.macports.apache2')
    service_buttons = [{
        'command': 'force-reload',
        'text': _('Reload'),
        'icon': 'step-forward',
    }]
    hosts_available_dir = platform_select(
        debian='/etc/apache2/sites-available',
        centos='/etc/httpd/conf.d',
        mageia='/etc/httpd/conf',
        freebsd='/usr/local/etc/apache/sites-available',
        osx='/opt/local/apache2/conf',
    )
    hosts_enabled_dir = platform_select(
        debian='/etc/apache2/sites-enabled',
        freebsd='/usr/local/etc/apache/sites-enabled')
    supports_host_activation = platform_select(
        debian=True,
        freebsd=True,
        default=False,
    )

    configurable = True
    main_conf_files = platform_select(
        debian=[
            '/etc/apache2/apache2.conf', '/etc/apache2/ports.conf',
            '/etc/apache2/envvars', '/etc/apache2/magic'
        ],
        centos=['/etc/httpd/conf/httpd.conf', '/etc/httpd/conf/magic'],
        default=[],
    )

    template = """<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>

    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>
</VirtualHost>
"""

    def init(self):
        self.title = 'Apache'
        self.category = _('Software')
        self.icon = 'globe'
        if ajenti.platform in ['centos', 'mageia']:
            self.service_name = 'httpd'
Пример #3
0
 def restart(self):
     ServiceMultiplexor.get().get_one(
         platform_select(debian="courier-imap", centos="courier-imap", default="courier-imapd")
     ).restart()
     if ajenti.platform != "centos":  # centos runs both
         ServiceMultiplexor.get().get_one(
             platform_select(debian="courier-imap-ssl", default="courier-imapd-ssl")
         ).restart()
Пример #4
0
 def restart(self):
     ServiceMultiplexor.get().get_one(platform_select(
         debian='courier-imap',
         centos='courier-imap',
         default='courier-imapd',
     )).restart()
     if ajenti.platform != 'centos':  # centos runs both
         ServiceMultiplexor.get().get_one(platform_select(
             debian='courier-imap-ssl',
             default='courier-imapd-ssl',
         )).restart()
Пример #5
0
 def restart(self):
     ServiceMultiplexor.get().get_one(platform_select(
         debian='courier-imap',
         centos='courier-imap',
         default='courier-imapd',
     )).restart()
     if ajenti.platform != 'centos':  # centos runs both
         ServiceMultiplexor.get().get_one(platform_select(
             debian='courier-imap-ssl',
             default='courier-imapd-ssl',
         )).restart()
Пример #6
0
    def init(self):
        self.title = 'Samba'
        self.icon = 'folder-close'
        self.category = _('Software')
        self.append(self.ui.inflate('samba:main'))

        self.find('servicebar').name = platform_select(
            debian='samba',
            ubuntu='smbd',
            mageia='smbd',
            centos='smb',
            default='samba',
        )
        self.find('servicebar').reload()

        self.binder = Binder(None, self.find('config'))
        self.find('shares').new_item = lambda c: ShareData()
        self.config = SambaConfig(path=platform_select(
            default='/etc/samba/smb.conf',
            freebsd='/usr/local/etc/smb.conf',
        ))

        def post_item_bind(object, collection, item, ui):
            ui.find('disconnect').on('click', self.on_disconnect, item)

        self.find('connections').post_item_bind = post_item_bind

        def post_user_bind(object, collection, item, ui):
            def delete_user():
                self.usermgr.delete(item.username)
                self.refresh()

            ui.find('delete').on('click', delete_user)

            def set_password():
                if self.usermgr.set_password(item.username,
                                             ui.find('password').value):
                    self.context.notify('info', _('Password updated'))
                    ui.find('password').value = ''
                else:
                    self.context.notify('error', _('Password update failed'))

            ui.find('password-set').on('click', set_password)

        self.find('user-list').post_item_bind = post_user_bind

        self.usermgr = SambaUsers()
        self.binder_u = Binder(self.usermgr, self.find('users'))

        self.monitor = SambaMonitor()
        self.binder_m = Binder(self.monitor, self.find('status'))
Пример #7
0
    def __init__(self):
        self.basedir = platform_select(
            debian='/etc/dehydrated/',
            centos='/etc/dehydrated/',
            mageia='/etc/dehydrated/',
            freebsd='/usr/local/etc/dehydrated/',
            arch='/etc/dehydrated/',
            osx='/opt/local/etc/dehydrated/',
        )
 
        self.nginx_sites_available = platform_select(
            debian='/etc/nginx/sites-available/',
            centos='/etc/nginx.custom.d/',
            mageia='/etc/nginx.custom.d/',
            freebsd='/usr/local/etc/nginx.custom.d/',
            arch='/etc/nginx/sites-available/',
            osx='/opt/local/etc/nginx/',
        )

        self.nginx_sites_enabled = platform_select(
            debian='/etc/nginx/sites-enabled/',
            centos='/etc/nginx.custom.d/',
            mageia='/etc/nginx.custom.d/',
            freebsd='/usr/local/etc/nginx.custom.d/',
            arch='/etc/nginx/sites-available/',
            osx='/opt/local/etc/nginx/',
        )
        
        self.crontab_dir = platform_select(
            debian='/etc/cron.d/',
            centos='/etc/cron.d/',
            mageia='/etc/cron.d/',
            freebsd='/usr/local/etc/cron.d/',
            arch='/etc/cron.d/',
            osx='/opt/local/etc/cron.d/',
        )
         
        self.scriptname = 'dehydrated'
        self.wellknown = '/var/www/dehydrated/'
        self.cronjob = False
        self.output = "IT WORKS MOFO"
        self.dependencies_met = False
        self.certs = []
        self.domains = []
        self.cronfile = 'dehydrated'
        self.results = ''
        self.configname = 'config'
        self.domainfile = 'domains.txt'
        self.nginx_config = 'letsencrypt_check.conf'
Пример #8
0
    def init(self):
        self.title = 'Samba'
        self.icon = 'folder-close'
        self.category = _('Software')
        self.append(self.ui.inflate('samba:main'))

        self.find('servicebar').name = platform_select(
            debian='samba',
            ubuntu='smbd',
            mageia='smbd',
            centos='smb',
            default='samba',
        )
        self.find('servicebar').reload()

        self.binder = Binder(None, self.find('config'))
        self.find('shares').new_item = lambda c: ShareData()
        self.config = SambaConfig(path=platform_select(
            default='/etc/samba/smb.conf',
            freebsd='/usr/local/etc/smb.conf',
        ))

        def post_item_bind(object, collection, item, ui):
            ui.find('disconnect').on('click', self.on_disconnect, item)

        self.find('connections').post_item_bind = post_item_bind

        def post_user_bind(object, collection, item, ui):
            def delete_user():
                self.usermgr.delete(item.username)
                self.refresh()
            ui.find('delete').on('click', delete_user)

            def set_password():
                if self.usermgr.set_password(item.username, ui.find('password').value):
                    self.context.notify('info', _('Password updated'))
                    ui.find('password').value = ''
                else:
                    self.context.notify('error', _('Password update failed'))
            ui.find('password-set').on('click', set_password)

        self.find('user-list').post_item_bind = post_user_bind

        self.usermgr = SambaUsers()
        self.binder_u = Binder(self.usermgr, self.find('users'))

        self.monitor = SambaMonitor()
        self.binder_m = Binder(self.monitor, self.find('status'))
Пример #9
0
    def create_configuration(self, config):
        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in sup.tree.programs:
            if p.command and p.command.startswith('node '):
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                i = 0
                for location in website.locations:
                    if location.backend.type == 'nodejs':
                        i += 1
                        location.backend.id = website.slug + '-nodejs-' + str(
                            i)
                        p = ProgramData()
                        p.name = location.backend.id
                        p.command = 'node %s' % location.backend.params.get(
                            'path', '/')
                        sup.tree.programs.append(p)

        sup.save()
Пример #10
0
    def restart(self):
        open(self.paniclog, 'w').close()

        ServiceMultiplexor.get().get_one(platform_select(
            debian='exim4',
            default='exim',
        )).command('restart')
Пример #11
0
    def init(self):
        self.title = _('Date & Time')
        self.icon = 'time'
        self.category = _('System')

        self.append(self.ui.inflate('ntpd:main'))

        self.find('servicebar').name = self.service_name
        self.find('servicebar').reload()

        self.config = NTPDConfig(path=platform_select(
            default=open_ntpd_conf if self.openntpd else ntpd_conf,
            centos='/usr/local/etc/ntpd.conf',
            freebsd='/usr/local/etc/ntpd.conf' if self.openntpd else ntpd_conf
        ))

        self.binder = Binder(None, self)

        self.available_zones = []
        for d, dirs, files in os.walk('/usr/share/zoneinfo', followlinks=False):
            for f in files:
                if f != 'zone.tab':
                    self.available_zones.append(os.path.join(d, f))
        self.available_zones = [x[len('/usr/share/zoneinfo/'):] for x in self.available_zones]
        self.available_zones.sort()

        self.find('servers').new_item = lambda c: ServerData()
Пример #12
0
    def init(self):
        self.title = _('Date & Time')
        self.icon = 'time'
        self.category = _('System')

        self.append(self.ui.inflate('ntpd:main'))

        self.find('servicebar').name = self.service_name
        self.find('servicebar').reload()

        self.config = NTPDConfig(path=platform_select(
            default=open_ntpd_conf if self.openntpd else ntpd_conf,
            centos='/usr/local/etc/ntpd.conf' if self.openntpd else ntpd_conf,
            freebsd='/usr/local/etc/ntpd.conf' if self.openntpd else ntpd_conf,
        ))

        self.binder = Binder(None, self)

        self.available_zones = []
        for d, dirs, files in os.walk('/usr/share/zoneinfo',
                                      followlinks=False):
            for f in files:
                if f != 'zone.tab':
                    self.available_zones.append(os.path.join(d, f))
        self.available_zones = [
            x[len('/usr/share/zoneinfo/'):] for x in self.available_zones
        ]
        self.available_zones.sort()

        self.find('servers').new_item = lambda c: ServerData()
Пример #13
0
    def restart(self):
        open(self.paniclog, 'w').close()

        ServiceMultiplexor.get().get_one(platform_select(
            debian='exim4',
            default='exim',
        )).command('restart')
Пример #14
0
    def create_configuration(self, config):
        self.checks = []

        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in list(sup.tree.programs):
            if p.comment and p.comment == self.COMMENT:
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                cfg = website.extension_configs.get(ProcessesExtension.classname) or {}
                for process in cfg.get('processes', []):
                    p = ProgramData()
                    p.comment = self.COMMENT
                    p.name = '%s-%s' % (website.slug, process['name'])
                    p.command = process['command']
                    p.environment = process['environment']
                    p.directory = process['directory'] or website.root
                    p.user = process['user'] or 'www-data'
                    p.stopasgroup = True
                    p.killasgroup = True
                    sup.tree.programs.append(p)
                    self.checks.append(ProcessTest(p.name))

        sup.save()
Пример #15
0
    def create_configuration(self, config):
        self.checks = []
        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in sup.tree.programs:
            if p.command.startswith('puma') or p.command.startswith('bundle exec puma'):
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == 'ruby-puma':
                        self.checks.append(PumaServerTest(location.backend))
                        p = ProgramData()
                        p.name = location.backend.id
                        bundler = location.backend.params.get('bundler', True)
                        workers = location.backend.params.get('workers', 4)
                        environment = location.backend.params.get('environment', 4)
                        p.command = 'puma -e %s -t %i -b unix:///var/run/puma-%s.sock' % (
                            environment, workers or 4, location.backend.id
                        )
                        if bundler:
                            p.command = 'bundle exec ' + p.command
                        p.environment = 'HOME="%s"' % website.root
                        p.directory = website.root
                        sup.tree.programs.append(p)

        sup.save()
Пример #16
0
    def create_configuration(self, config):
        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in sup.tree.programs:
            if p.command.startswith('puma') or p.command.startswith(
                    'bundle exec puma'):
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == 'ruby-puma':
                        self.__generate_website(website)
                        p = ProgramData()
                        p.name = location.backend.id
                        bundler = location.backend.params.get('bundler', True)
                        workers = location.backend.params.get('workers', 4)
                        environment = location.backend.params.get(
                            'environment', 4)
                        p.command = 'puma -e %s -t %i -b unix:///var/run/puma-%s.sock' % (
                            environment, workers, location.backend.id)
                        if bundler:
                            p.command = 'bundle exec ' + p.command
                        p.environment = 'HOME="%s"' % website.root
                        p.directory = website.root
                        sup.tree.programs.append(p)

        sup.save()
Пример #17
0
    def create_configuration(self, config):
        if os.path.exists(self.config_dir):
            shutil.rmtree(self.config_dir)
        os.mkdir(self.config_dir)

        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in sup.tree.programs:
            if p.command and p.command.startswith('unicorn'):
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == 'ruby-unicorn':
                        self.__generate_website(website)
                        p = ProgramData()
                        p.name = location.backend.id
                        p.command = 'unicorn_rails -E production -c %s/%s.rb' % (self.config_dir, location.backend.id)
                        sup.tree.programs.append(p)

        sup.save()
Пример #18
0
    def create_configuration(self, config):
        self.checks = []

        node_bin = 'node'
        try:
            subprocess.call(['which', 'node'])
        except:
            node_bin = 'nodejs'

        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in sup.tree.programs:
            if p.command and p.command.startswith('node '):
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == 'nodejs':
                        self.checks.append(NodeServerTest(location.backend))
                        p = ProgramData()
                        p.name = location.backend.id
                        p.command = '%s %s' % (
                            node_bin,
                            location.backend.params.get('script', None) or '.'
                        )
                        p.user = location.backend.params.get('user', None) or 'www-data'
                        p.environment = location.backend.params.get('environment', None) or ''
                        p.directory = location.path or website.root
                        sup.tree.programs.append(p)

        sup.save()
Пример #19
0
    def create_configuration(self, config):
        self.checks = []

        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in list(sup.tree.programs):
            if p.comment and p.comment == self.COMMENT:
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                cfg = website.extension_configs.get(
                    ProcessesExtension.classname) or {}
                for process in cfg.get('processes', []):
                    p = ProgramData()
                    p.comment = self.COMMENT
                    p.name = '%s-%s' % (website.slug, process['name'])
                    p.command = process['command']
                    p.environment = process['environment']
                    p.directory = process['directory'] or website.root
                    p.user = process['user'] or 'www-data'
                    p.stopasgroup = True
                    p.killasgroup = True
                    sup.tree.programs.append(p)
                    self.checks.append(ProcessTest(p.name))

        sup.save()
Пример #20
0
 def init(self):
     self.title = 'Supervisor'
     self.icon = 'play'
     self.category = _('Software')
     self.append(self.ui.inflate('supervisor:main'))
     self.mgr = SupervisorServiceManager.get()
     self.binder = Binder(None, self.find('main'))
     self.find('programs').new_item = lambda c: ProgramData()
     self.config = SupervisorConfig(path=platform_select(
         default='/etc/supervisor/supervisord.conf',
         centos='/etc/supervisord.conf',
     ))
     self.find('servicebar').name = platform_select(
         centos='supervisord',
         default='supervisor',
     )
     self.find('servicebar').reload()
Пример #21
0
 def init(self):
     self.title = 'Supervisor'
     self.icon = 'play'
     self.category = _('Software')
     self.append(self.ui.inflate('supervisor:main'))
     self.mgr = SupervisorServiceManager.get()
     self.binder = Binder(None, self.find('main'))
     self.find('programs').new_item = lambda c: ProgramData()
     self.config = SupervisorConfig(path=platform_select(
         default='/etc/supervisor/supervisord.conf',
         centos='/etc/supervisord.conf',
     ))
     self.find('servicebar').name = platform_select(
         centos='supervisord',
         default='supervisor',
     )
     self.find('servicebar').reload()
Пример #22
0
class NTPDPlugin(SectionPlugin):
    service_name = platform_select(
        default='ntp',
        centos='ntpd',
    )

    def init(self):
        self.title = _('Date & Time')
        self.icon = 'time'
        self.category = _('Software')

        self.append(self.ui.inflate('ntpd:main'))

        self.find('servicebar').name = self.service_name
        self.find('servicebar').reload()

        self.config = NTPDConfig(
            path=platform_select(default='/etc/ntp.conf', ))

        self.binder = Binder(None, self)

        self.find('servers').new_item = lambda c: ServerData()

    def on_page_load(self):
        self.refresh()

    def refresh(self):
        self.config.load()
        self.now = int(time.time())
        self.binder.setup(self).populate()

    @on('set', 'click')
    def on_set(self):
        self.binder.update()
        d = datetime.fromtimestamp(self.now)
        s = d.strftime('%m%d%H%M%Y')
        subprocess.call(['date', s])
        self.refresh()

    @on('sync', 'click')
    def on_sync(self):
        self.binder.update()
        if len(self.config.tree.servers) == 0:
            self.context.notify('error', _('No servers defined'))
            return
        server = self.config.tree.servers[0].address
        output = subprocess.check_output(['ntpdate', '-u', server])
        self.context.notify('info', _('Done'))
        self.context.notify('info', output)
        self.refresh()

    @on('save', 'click')
    def save(self):
        self.binder.update()
        self.config.save()
        self.refresh()
        self.context.notify('info', _('Saved'))
        ServiceMultiplexor.get().get_one(self.service_name).restart()
Пример #23
0
 def apply_configuration(self):
     s = ServiceMultiplexor.get().get_one(platform_select(
         debian='php5-fpm',
         centos='php-fpm',
     ))
     if not s.running:
         s.start()
     else:
         s.command('reload')
Пример #24
0
 def apply_configuration(self):
     s = ServiceMultiplexor.get().get_one(platform_select(
         debian='supervisor',
         centos='supervisord',
     ))
     if not s.running:
         s.start()
     else:
         subprocess.call(['supervisorctl', 'reload'])
Пример #25
0
 def apply_configuration(self):
     s = ServiceMultiplexor.get().get_one(platform_select(
         debian='supervisor',
         centos='supervisord',
     ))
     if not s.running:
         s.start()
     else:
         subprocess.call(['supervisorctl', 'reload'])
Пример #26
0
class Nginx(WebserverPlugin):
    service_name = 'nginx'
    service_buttons = [{
        'command': 'force-reload',
        'text': _('Reload'),
        'icon': 'step-forward',
    }]
    hosts_available_dir = platform_select(
        debian='/etc/nginx/sites-available',
        centos='/etc/nginx/conf.d',
        freebsd='/usr/local/etc/nginx/conf.d',
        arch='/etc/nginx/sites-available',
    )
    hosts_enabled_dir = '/etc/nginx/sites-enabled'
    supports_host_activation = platform_select(
        debian=True,
        arch=True,
        default=False,
    )

    template = """server {
    server_name name;
    access_log /var/log/nginx/name.access.log;
    error_log  /var/log/nginx/name.error.log;

    listen 80;

    location / {
        root /var/www/name;
    }

    location ~ \.lang$ {
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:port;
        fastcgi_split_path_info ^()(.*)$;
    }
}
"""

    def init(self):
        self.title = 'NGINX'
        self.category = _('Software')
        self.icon = 'globe'
Пример #27
0
 def apply_configuration(self):
     s = ServiceMultiplexor.get().get_one(
         platform_select(
             debian='php5-fpm',
             centos='php-fpm',
         ))
     if not s.running:
         s.start()
     else:
         s.command('reload')
Пример #28
0
    def init(self):
        self.title = 'SNMP'
        self.icon = 'exchange'
        self.category = _('Software')

        self.append(self.ui.inflate('snmpd:main'))

        self.find('servicebar').name = self.service_name
        self.find('servicebar').reload()

        self.snmp_config = SNMPConfig(
            path=platform_select(default='/etc/snmp/snmp.conf', ))
        self.snmpd_config = SNMPDConfig(
            path=platform_select(default='/etc/snmp/snmpd.conf', ))

        self.find('rocommunities').new_item = lambda c: ROCommunityData()
        self.find('rwcommunities').new_item = lambda c: RWCommunityData()

        self.binder = Binder(None, self)
Пример #29
0
 def create_configuration(self, config):
     if os.path.exists(self.config_file):
         os.unlink(self.config_file)
     cfg = TEMPLATE_CONFIG_FILE % {
         'pidfile': platform_select(
             debian='/var/run/php5-fpm.pid',
             centos='/var/run/php-fpm/php-fpm.pid',
         ),
         'pools': '\n'.join(self.__generate_website(_) for _ in config.websites if _.enabled)
     }
     open(self.config_file, 'w').write(cfg)
Пример #30
0
    def create_configuration(self, config):
        self.checks = []

        node_bin = 'node'
        try:
            subprocess.call(['which', 'node'])
        except:
            node_bin = 'nodejs'

        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in sup.tree.programs:
            if p.command and p.command.startswith('node '):
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == 'nodejs':
                        self.checks.append(NodeServerTest(location.backend))
                        p = ProgramData()
                        p.name = location.backend.id

                        command = location.backend.params.get('script', None)
                        if command.find("npm ") == -1:
                            command = '%s %s' % (node_bin,
                                                 location.backend.params.get(
                                                     'script', None) or '.')

                        p.user = location.backend.params.get(
                            'user', None) or 'www-data'
                        p.directory = location.path or website.root

                        p.environment = location.backend.params.get(
                            'environment', None) or ''
                        virtualenv = location.backend.params.get('venv', None)
                        if virtualenv:
                            p.environment = '; '.join([
                                p.environment,
                                'PATH="%s:%s"' % (os.path.join(
                                    virtualenv, 'bin'), os.environ['PATH'])
                            ])
                            p.command = os.path.join(virtualenv,
                                                     'bin') + '/' + command
                        else:
                            p.command = command

                        sup.tree.programs.append(p)

        sup.save()
Пример #31
0
    def init(self):
        self.title = 'SNMP'
        self.icon = 'exchange'
        self.category = _('Software')

        self.append(self.ui.inflate('snmpd:main'))

        self.find('servicebar').name = self.service_name
        self.find('servicebar').reload()

        self.snmp_config = SNMPConfig(path=platform_select(
            default='/etc/snmp/snmp.conf',
        ))
        self.snmpd_config = SNMPDConfig(path=platform_select(
            default='/etc/snmp/snmpd.conf',
        ))

        self.find('rocommunities').new_item = lambda c: ROCommunityData()
        self.find('rwcommunities').new_item = lambda c: RWCommunityData()

        self.binder = Binder(None, self)
Пример #32
0
 def create_configuration(self, config):
     if os.path.exists(self.config_file):
         os.unlink(self.config_file)
     cfg = TEMPLATE_CONFIG_FILE % {
         'pidfile': platform_select(
             debian='/var/run/php5-fpm.pid',
             arch='/var/run/php-fpm.pid',
             centos='/var/run/php-fpm/php-fpm.pid',
         ),
         'pools': '\n'.join(self.__generate_website(_) for _ in config.websites if _.enabled)
     }
     open(self.config_file, 'w').write(cfg)
Пример #33
0
    def init(self):
        self.exim_cfg_path = platform_select(
            debian="/etc/exim4/exim4.conf", centos="/etc/exim/exim.conf", arch="/etc/mail/exim.conf"
        )

        for d in ["/etc/courier", "/var/run/courier"]:
            if not os.path.exists(d):
                os.makedirs(d)

        self.courier_authdaemonrc = platform_select(
            debian="/etc/courier/authdaemonrc", centos="/etc/authlib/authdaemonrc", arch="/etc/authlib/authdaemonrc"
        )
        self.courier_imaprc = platform_select(
            debian="/etc/courier/imapd", centos="/usr/lib/courier-imap/etc/imapd", arch="/etc/courier-imap/imapd"
        )
        self.courier_imapsrc = platform_select(
            debian="/etc/courier/imapd-ssl",
            centos="/usr/lib/courier-imap/etc/imapd-ssl",
            arch="/etc/courier-imap/imapd-ssl",
        )
        self.courier_userdb = platform_select(
            debian="/etc/courier/userdb", centos="/etc/authlib/userdb", arch="/etc/authlib/userdb"
        )
        self.courier_authsocket = platform_select(
            debian="/var/run/courier/authdaemon/socket",
            centos="/var/spool/authdaemon/socket",
            arch="/var/run/authdaemon/socket",
        )

        self.maildomains = "/etc/exim.domains"
        self.mailforward = "/etc/exim.forward"
        self.mailuid = pwd.getpwnam("mail").pw_uid
        self.mailgid = grp.getgrnam("mail").gr_gid
Пример #34
0
    def init(self):
        self.exim_cfg_path = platform_select(
            debian='/etc/exim4/exim4.conf',
            centos='/etc/exim/exim.conf',
        )

        for d in ['/etc/courier', '/var/run/courier']:
            if not os.path.exists(d):
                os.mkdir(d)

        self.courier_authdaemonrc = platform_select(
            debian='/etc/courier/authdaemonrc',
            centos='/etc/authlib/authdaemonrc',
        )
        self.courier_imaprc = platform_select(
            debian='/etc/courier/imapd',
            centos='/usr/lib/courier-imap/etc/imapd',
        )
        self.courier_imapsrc = platform_select(
            debian='/etc/courier/imapd-ssl',
            centos='/usr/lib/courier-imap/etc/imapd-ssl',
        )
        self.courier_userdb = platform_select(
            debian='/etc/courier/userdb',
            centos='/etc/authlib/userdb',
        )
        self.courier_authsocket = platform_select(
            debian='/var/run/courier/authdaemon/socket',
            centos='/var/spool/authdaemon/socket',
        )

        self.maildomains = '/etc/exim.domains'
        self.mailforward = '/etc/exim.forward'
        self.mailuid = pwd.getpwnam('mail').pw_uid
        self.mailgid = grp.getgrnam('mail').gr_gid
Пример #35
0
class EximRestartable (Restartable):
    paniclog = platform_select(
        debian='/var/log/exim4/paniclog',
        default='/var/log/exim/paniclog',
    )

    def restart(self):
        open(self.paniclog, 'w').close()

        ServiceMultiplexor.get().get_one(platform_select(
            debian='exim4',
            default='exim',
        )).command('restart')
Пример #36
0
    def init(self):
        self.title = 'SNMP'
        self.icon = 'exchange'
        self.category = _('Software')

        self.append(self.ui.inflate('snmpd:main'))

        self.find('servicebar').name = self.service_name
        self.find('servicebar').reload()

        self.snmp_config = SNMPConfig(path=platform_select(
            default='/etc/snmp/snmp.conf',
        ))

        self.binder = Binder(None, self)
Пример #37
0
    def init(self):
        self.title = _("Date & Time")
        self.icon = "time"
        self.category = _("Software")

        self.append(self.ui.inflate("ntpd:main"))

        self.find("servicebar").name = self.service_name
        self.find("servicebar").reload()

        self.config = NTPDConfig(path=platform_select(default="/etc/ntp.conf"))

        self.binder = Binder(None, self)

        self.find("servers").new_item = lambda c: ServerData()
Пример #38
0
    def create_configuration(self, config):
        self.checks = []

        node_bin = 'node'
        try:
            subprocess.call(['which', 'node'])
        except:
            node_bin = 'nodejs'

        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in sup.tree.programs:
            if p.command and p.command.startswith('node '):
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == 'nodejs':
                        self.checks.append(NodeServerTest(location.backend))
                        p = ProgramData()
                        p.name = location.backend.id

             		command = location.backend.params.get('script', None)
                        if command.find("npm ") == -1 :
                            command = '%s %s' % (
                                node_bin,
                                location.backend.params.get('script', None) or '.'
                            )

                        p.user = location.backend.params.get('user', None) or 'www-data'
                        p.directory = location.path or website.root

                        p.environment = location.backend.params.get('environment', None) or ''
                        virtualenv = location.backend.params.get('venv', None)
                        if virtualenv:
                            p.environment = '; '.join([p.environment, 'PATH="%s:%s"' % (os.path.join(virtualenv, 'bin'), os.environ['PATH'])])
                            p.command = os.path.join(virtualenv, 'bin') + '/' + command
                        else:
                            p.command = command


                        sup.tree.programs.append(p)

        sup.save()
Пример #39
0
    def apply_configuration(self):
        log_dir = "/var/log/unicorn"
        if not os.path.exists(log_dir):
            os.makedirs(log_dir)

        s = ServiceMultiplexor.get().get_one("unicorn")
        if not s.running:
            s.start()
        else:
            s.command("reload")

        s = ServiceMultiplexor.get().get_one(platform_select(debian="supervisor", centos="supervisord"))
        if not s.running:
            s.start()
        else:
            subprocess.call(["supervisorctl", "reload"])
Пример #40
0
    def init(self):
        self.title = _('Date & Time')
        self.icon = 'time'
        self.category = _('Software')

        self.append(self.ui.inflate('ntpd:main'))

        self.find('servicebar').name = self.service_name
        self.find('servicebar').reload()

        self.config = NTPDConfig(
            path=platform_select(default='/etc/ntp.conf', ))

        self.binder = Binder(None, self)

        self.find('servers').new_item = lambda c: ServerData()
Пример #41
0
    def init(self):
        self.title = 'NSD'
        self.icon = 'globe'
        self.category = _('Software')

        self.append(self.ui.inflate('nsd:main'))

        self.config = NSDConfig(path=platform_select(
            default='/etc/nsd3/nsd.conf',
            arch='/etc/nsd/nsd.conf',
        ))

        self.binder = Binder(None, self)
        self.find('zones').new_item = lambda c: ZoneData()

        def post_zone_bind(o, c, i, u):
            path = i.file
            if not path.startswith('/'):
                path = '/etc/nsd3/' + path
            exists = os.path.exists(path)
            u.find('no-file').visible = not exists
            u.find('file').visible = exists
            if exists:
                u.find('editor').value = open(path).read()

            def on_save_zone():
                open(path, 'w').write(u.find('editor').value)
                self.context.notify('info', _('Zone saved'))

            def on_create_zone():
                open(path, 'w').write("""$TTL    604800
@       IN      SOA     ns. root.ns. (
                              1         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@                   IN      NS      ns.
example.com.        IN      A       127.0.0.1
example.com.        IN      AAAA    ::1
""")
                post_zone_bind(o, c, i, u)

            u.find('save-zone').on('click', on_save_zone)
            u.find('create-zone').on('click', on_create_zone)
        self.find('zones').post_item_bind = post_zone_bind
Пример #42
0
class VSFTPD(MiscComponent):
    config_root = '/etc/vsftpd'
    config_root_users = '/etc/vsftpd.users.d'
    config_file = platform_select(
        debian='/etc/vsftpd.conf',
        arch='/etc/vsftpd.conf',
        centos='/etc/vsftpd/vsftpd.conf',
    )
    userdb_path = '/etc/vsftpd/users.db'
    pam_path = '/etc/pam.d/vsftpd_virtual'

    def create_configuration(self, config):
        if not os.path.exists(self.config_root):
            os.mkdir(self.config_root)
        if os.path.exists(self.config_root_users):
            shutil.rmtree(self.config_root_users)
        os.mkdir(self.config_root_users)

        pwfile = tempfile.NamedTemporaryFile(delete=False)
        pwpath = pwfile.name
        for website in config.websites:
            subprocess.call(['chgrp', 'ftp', website.root])
            subprocess.call(['chmod', 'g+w', website.root])
            if website.enabled:
                cfg = website.extension_configs.get(VSFTPDExtension.classname)
                if cfg and cfg['created']:
                    pwfile.write('%s\n%s\n' %
                                 (cfg['username'], cfg['password']))
                    open(os.path.join(self.config_root_users, cfg['username']),
                         'w').write(TEMPLATE_USER % {
                             'root': website.root,
                         })
        pwfile.close()

        subprocess.call(
            ['db_load', '-T', '-t', 'hash', '-f', pwpath, self.userdb_path])
        os.unlink(pwpath)
        open(self.pam_path, 'w').write(TEMPLATE_PAM)
        open(self.config_file,
             'w').write(TEMPLATE_CONFIG % self.config_root_users)

        if not os.path.exists('/var/www'):
            os.mkdir('/var/www')
        subprocess.call(['chown', 'www-data:', '/var/www'])

    def apply_configuration(self):
        ServiceMultiplexor.get().get_one('vsftpd').restart()
Пример #43
0
   def __init__(self):
      self.basedir = platform_select(
          debian='/etc/letsencrypt.sh/',
          centos='/etc/letsencrypt.sh/',
          mageia='/etc/letsencrypt.sh/',
          freebsd='/usr/local/etc/letsencrypt.sh/',
          arch='/etc/letsencrypt.sh/',
          osx='/opt/local/etc/letsencrypt.sh/',
      )

      self.wellknown = '/var/www/letsencrypt.sh/'
      self.domains = 'example.com sub.example.com'
      self.cronjob = False
      self.cronfile = 'letsencrypt'
      self.results = ''
      self.domainfile = 'domains.txt'
      self.nginx_config = '00_letsencrypt.conf'
Пример #44
0
   def __init__(self):
      self.basedir = platform_select(
          debian='/etc/letsencrypt.sh/',
          centos='/etc/letsencrypt.sh/',
          mageia='/etc/letsencrypt.sh/',
          freebsd='/usr/local/etc/letsencrypt.sh/',
          arch='/etc/letsencrypt.sh/',
          osx='/opt/local/etc/letsencrypt.sh/',
      )

      self.wellknown = '/var/www/letsencrypt.sh/'
      self.domains = 'example.com sub.example.com'
      self.cronjob = False
      self.cronfile = 'letsencrypt'
      self.results = ''
      self.domainfile = 'domains.txt'
      self.nginx_config = '00_letsencrypt.conf'
Пример #45
0
    def create_configuration(self, config):
        self.checks = []
        if os.path.exists(self.config_dir):
            shutil.rmtree(self.config_dir)
        os.mkdir(self.config_dir)

        for website in config.websites:
            if website.enabled:
                self.__generate_website(website)

        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()

        COMMENT = 'Generated by Ajenti-V'

        for p in sup.tree.programs:
            if p.comment == COMMENT:
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == 'python-wsgi':
                        self.checks.append(GUnicornServerTest(
                            location.backend))
                        self.__generate_website(website)
                        p = ProgramData()
                        p.name = location.backend.id
                        p.comment = COMMENT
                        p.command = 'gunicorn -c %s/%s "%s"' % (
                            self.config_dir, location.backend.__config_name,
                            location.backend.params['module'])
                        p.directory = location.path or website.root
                        virtualenv = location.backend.params.get('venv', None)
                        if virtualenv:
                            p.environment = 'PATH="%s:%s"' % (os.path.join(
                                virtualenv, 'bin'), os.environ['PATH'])
                            p.command = os.path.join(virtualenv,
                                                     'bin') + '/' + p.command

                        sup.tree.programs.append(p)

        sup.save()
Пример #46
0
    def restart(self):
        s = ServiceMultiplexor.get().get_one(platform_select(
            debian='supervisor',
            default='supervisord',
        ))
        if not s.running:
            s.start()
        else:
            subprocess_call_background(['supervisorctl', 'reload'])

        # Await restart
        retries = 10
        while retries:
            retries -= 1
            if subprocess_call_background(['supervisorctl', 'status']) == 0:
                break
            gevent.sleep(1)
Пример #47
0
    def restart(self):
        s = ServiceMultiplexor.get().get_one(
            platform_select(
                debian='supervisor',
                default='supervisord',
            ))
        if not s.running:
            s.start()
        else:
            subprocess_call_background(['supervisorctl', 'reload'])

        # Await restart
        retries = 10
        while retries:
            retries -= 1
            if subprocess_call_background(['supervisorctl', 'status']) == 0:
                break
            gevent.sleep(1)
Пример #48
0
class MySQLPlugin(DBPlugin):
    config_class = MySQLDB

    service_name = platform_select(
        debian='mysql',
        osx='org.macports.mysql56-server',
        default='mysqld',
    )

    service_buttons = [{
        'command': 'reload',
        'text': _('Reload'),
        'icon': 'step-forward',
    }]

    def init(self):
        self.title = 'MySQL'
        self.category = _('Software')
        self.icon = 'table'
        self.db = MySQLDB.get()

    def query_sql(self, db, sql):
        return self.db.query_sql(db, sql)

    def query_databases(self):
        return self.db.query_databases()

    def query_drop(self, db):
        return self.db.query_drop(db)

    def query_create(self, name):
        return self.db.query_create(name)

    def query_users(self):
        return self.db.query_users()

    def query_create_user(self, user):
        return self.db.query_create_user(user)

    def query_drop_user(self, user):
        return self.db.query_drop_user(user)

    def query_grant(self, user, db):
        return self.db.query_grant(user, db)
Пример #49
0
    def create_configuration(self, config):
        self.checks = []
        if os.path.exists(self.config_dir):
            shutil.rmtree(self.config_dir)
        os.mkdir(self.config_dir)

        for website in config.websites:
            if website.enabled:
                self.__generate_website(website)

        sup = SupervisorConfig(
            path=platform_select(debian="/etc/supervisor/supervisord.conf", centos="/etc/supervisord.conf")
        )
        sup.load()

        COMMENT = "Generated by Ajenti-V"

        for p in sup.tree.programs:
            if p.comment == COMMENT:
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == "python-wsgi":
                        self.checks.append(GUnicornServerTest(location.backend))
                        self.__generate_website(website)
                        p = ProgramData()
                        p.name = location.backend.id
                        p.comment = COMMENT
                        p.command = 'gunicorn -c %s/%s "%s"' % (
                            self.config_dir,
                            location.backend.id,
                            location.backend.params["module"],
                        )
                        p.directory = location.path or website.root
                        virtualenv = location.backend.params.get("venv", None)
                        if virtualenv:
                            p.environment = 'PATH="%s"' % os.path.join(virtualenv, "bin")
                            p.command = os.path.join(virtualenv, "bin") + "/" + p.command

                        sup.tree.programs.append(p)

        sup.save()
Пример #50
0
    def init(self):
        self.title = _('DHCP Server')
        self.icon = 'sitemap'
        self.category = _('Software')

        self.append(self.ui.inflate('dhcpd:main'))

        self.config = DHCPDConfig(path=platform_select(
            default='/etc/dhcp/dhcpd.conf',
            arch='/etc/dhcpd.conf',
        ))

        self.binder = Binder(None, self)

        for x in self.nearest(lambda x: x.bind == 'ranges'):
            x.new_item = lambda c: RangeData()
        for x in self.nearest(lambda x: x.bind == 'options'):
            x.new_item = lambda c: OptionData()
        self.find('subnets').new_item = lambda c: SubnetData()
Пример #51
0
    def init(self):
        self.title = 'Squid'
        self.icon = 'exchange'
        self.category = _('Software')
        self.append(self.ui.inflate('squid:main'))

        self.find('servicebar').name = platform_select(
            debian='squid3',
            centos='squid',
            default='squid',
        )
        self.find('servicebar').reload()

        self.binder = Binder(None, self.find('config'))
        self.find('acl').new_item = lambda c: ACLData('new')
        self.find('http_access').new_item = lambda c: HTTPAccessData()
        self.find('http_port').new_item = lambda c: HTTPPortData()
        self.find('https_port').new_item = lambda c: HTTPSPortData()
        self.config = SquidConfig(path='/etc/squid3/squid.conf')
Пример #52
0
    def init(self):
        self.title = _('DHCP Server')
        self.icon = 'sitemap'
        self.category = _('Software')

        self.append(self.ui.inflate('dhcpd:main'))

        self.config = DHCPDConfig(path=platform_select(
            default='/etc/dhcp/dhcpd.conf',
            arch='/etc/dhcpd.conf',
        ))

        self.binder = Binder(None, self)

        for x in self.nearest(lambda x: x.bind == 'ranges'):
            x.new_item = lambda c: RangeData()
        for x in self.nearest(lambda x: x.bind == 'options'):
            x.new_item = lambda c: OptionData()
        self.find('subnets').new_item = lambda c: SubnetData()
Пример #53
0
    def init(self):
        self.title = 'Squid'
        self.icon = 'exchange'
        self.category = _('Software')
        self.append(self.ui.inflate('squid:main'))

        self.find('servicebar').name = platform_select(
            debian='squid3',
            centos='squid',
            default='squid',
        )
        self.find('servicebar').reload()

        self.binder = Binder(None, self.find('config'))
        self.find('acl').new_item = lambda c: ACLData()
        self.find('http_access').new_item = lambda c: HTTPAccessData()
        self.find('http_port').new_item = lambda c: HTTPPortData()
        self.find('https_port').new_item = lambda c: HTTPSPortData()
        self.config = SquidConfig(path='/etc/squid3/squid.conf')
Пример #54
0
    def create_configuration(self, config):
        self.checks = []
        if os.path.exists(self.config_dir):
            shutil.rmtree(self.config_dir)
        os.mkdir(self.config_dir)

        for website in config.websites:
            if website.enabled:
                self.__generate_website(website)

        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()

        COMMENT = 'Generated by Ajenti-V'

        for p in sup.tree.programs:
            if p.comment == COMMENT:
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == 'python-wsgi':
                        self.checks.append(GUnicornServerTest(location.backend))
                        self.__generate_website(website)
                        p = ProgramData()
                        p.name = location.backend.id
                        p.user = location.backend.params.get('user', None) or 'www-data'
                        p.comment = COMMENT
                        p.command = 'gunicorn -c %s/%s "%s"' % (self.config_dir, location.backend.__config_name, location.backend.params['module'])
                        p.directory = location.path or website.root
                        virtualenv = location.backend.params.get('venv', None)
                        if virtualenv:
                            p.environment = 'PATH="%s"' % os.path.join(virtualenv, 'bin')
                            p.command = os.path.join(virtualenv, 'bin') + '/' + p.command

                        sup.tree.programs.append(p)

        sup.save()
Пример #55
0
    def apply_configuration(self):
        log_dir = '/var/log/unicorn'
        if not os.path.exists(log_dir):
            os.makedirs(log_dir)

        s = ServiceMultiplexor.get().get_one('unicorn')
        if not s.running:
            s.start()
        else:
            s.command('reload')

        s = ServiceMultiplexor.get().get_one(
            platform_select(
                debian='supervisor',
                centos='supervisord',
            ))
        if not s.running:
            s.start()
        else:
            subprocess.call(['supervisorctl', 'reload'])
Пример #56
0
class PureFTPD(MiscComponent):
    userdb_path = '/etc/pure-ftpd/pureftpd.passwd'
    config_path = platform_select(
        centos='/etc/pure-ftpd/pure-ftpd.conf',
        arch='/etc/pure-ftpd.conf',
    )

    def create_configuration(self, config):
        open(self.userdb_path, 'w').close()
        for website in config.websites:
            if website.enabled:
                cfg = website.extension_configs.get(
                    PureFTPDExtension.classname)
                if cfg and cfg['created']:
                    p = subprocess.Popen([
                        'pure-pw',
                        'useradd',
                        cfg['username'],
                        '-u',
                        cfg.get('system_user') or 'www-data',
                        '-g',
                        cfg.get('system_group') or 'www-data',
                        '-d',
                        cfg.get('path', None) or website.root,
                    ],
                                         stdin=subprocess.PIPE)
                    p.communicate('%s\n%s\n' %
                                  (cfg['password'], cfg['password']))

        subprocess.call(['pure-pw', 'mkdb'])

        if ajenti.platform == 'debian':
            open('/etc/pure-ftpd/conf/MinUID', 'w').write('1')
            authfile = '/etc/pure-ftpd/auth/00puredb'
            if not os.path.exists(authfile):
                os.symlink('/etc/pure-ftpd/conf/PureDB', authfile)
        if ajenti.platform in ['arch', 'centos']:
            open(self.config_path, 'w').write(CENTOS_CONFIG)

    def apply_configuration(self):
        ServiceMultiplexor.get().get_one('pure-ftpd').restart()
Пример #57
0
    def create_configuration(self, config):
        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in sup.tree.programs:
            if p.command and p.command.startswith('node '):
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                i = 0
                for location in website.locations:
                    if location.backend.type == 'nodejs':
                        i += 1
                        location.backend.id = website.slug + '-nodejs-' + str(i)
                        p = ProgramData()
                        p.name = location.backend.id
                        p.command = 'node %s' % location.backend.params.get('path', '/')
                        sup.tree.programs.append(p)

        sup.save()
Пример #58
0
 def restart(self):
     ServiceMultiplexor.get().get_one(platform_select(
         debian='exim4',
         default='exim',
     )).command('restart')
Пример #59
0
 def restart(self):
     ServiceMultiplexor.get().get_one(platform_select(
         debian='courier-authdaemon',
         centos='courier-authlib',
     )).restart()