Esempio n. 1
0
 def _occ_set_config(self, app, key, value):
     """
     Sets OCC config value
     :param key: 
     :param value: 
     :return: 
     """
     cmd = 'config:app:set --value %s %s %s' \
           % (util.escape_shell(value), util.escape_shell(app), util.escape_shell(key))
     self._occ_cmd(cmd)
Esempio n. 2
0
 def _occ_get_config(self, app, key):
     """
     Gets OCC config value
     :param key: 
     :return: 
     """
     cmd = 'config:app:get %s %s' % (util.escape_shell(app),
                                     util.escape_shell(key))
     ret, out, err = self._occ_cmd(cmd, require_zero_result=False)
     if ret != 0:
         return None
     return out.strip()
Esempio n. 3
0
    def _config_server(self):
        """
        Server configuration - rosters, groups.
        :return: 
        """
        # Create shared roster group via ejabberctl.
        cmd = 'srg_create %s %s %s %s %s' % (util.escape_shell(
            self._shared_group), util.escape_shell(
                self.hostname), util.escape_shell(
                    self._shared_group), util.escape_shell(self._shared_group),
                                             util.escape_shell(
                                                 self._shared_group))
        self._ctl_cmd(cmd, False)

        cmd = 'srg_user_add \'@all@\' \'\' %s %s' % (self._shared_group,
                                                     self.hostname)
        self._ctl_cmd(cmd, False)
Esempio n. 4
0
    def add_tile(self, name, icon, link):
        """
        Adds a new tile to the page
        :param name: 
        :param icon: 
        :param link: 
        :return: 
        """
        cmd = 'sudo -u %s php artisan tiles:add %s %s %s' \
              % (self.user,
                 util.escape_shell(name),
                 util.escape_shell(icon),
                 util.escape_shell(link))

        ret, out, err = self.sysconfig.cli_cmd_sync(cmd, cwd=self.webroot)
        if ret != 0:
            raise errors.SetupError('Could not add an application tile')
Esempio n. 5
0
    def _deploy_downloaded(self, archive_path, basedir):
        """
        Analyzes downloaded file, deploys to the webroot
        :param archive_path:
        :param basedir:
        :return:
        """
        cmd_exec = None
        pkg = self.sysconfig.get_packager()
        if pkg == osutil.PKG_YUM:
            cmd_exec = 'sudo yum localinstall enablerepo=epel -y %s' % util.escape_shell(
                archive_path)
        elif pkg == osutil.PKG_APT:
            cmd_exec = 'sudo dpkg -i %s' % util.escape_shell(archive_path)

        ret = self.sysconfig.exec_shell(cmd_exec, write_dots=self.write_dots)
        if ret != 0:
            raise errors.SetupError('Could not install ejabberd server')
Esempio n. 6
0
 def ctl_stop(self, cmd):
     """
     :return:
     """
     ret = self.sysconfig.exec_shell(
         'sudo %s supervisorctl stop %s' %
         (self.sysconfig.epiper_path(), util.escape_shell(cmd)))
     if ret != 0:
         raise errors.SetupError('Could not exec supervisorctl stop')
Esempio n. 7
0
    def _deploy_downloaded(self, archive_path, basedir):
        """
        Analyzes downloaded file, deploys to the install dir
        :param archive_path:
        :param basedir:
        :return:
        """
        cmd = 'sudo tar -xzvf %s' % util.escape_shell(archive_path)
        ret, out, err = self.sysconfig.cli_cmd_sync(cmd,
                                                    write_dots=True,
                                                    cwd=basedir)
        if ret != 0:
            raise errors.SetupError('Could not extract update archive')

        folders = [
            f for f in os.listdir(basedir)
            if not os.path.isfile(os.path.join(basedir, f)) and f != '.'
            and f != '..'
        ]

        if len(folders) != 1:
            raise errors.SetupError(
                'Invalid folder structure after update extraction')

        archive_dir = os.path.join(basedir, folders[0])
        if not os.path.exists(archive_dir):
            raise errors.SetupError(
                'Directory with jboss not found in the install archive: %s' %
                archive_dir)

        archive_slash = util.add_ending_slash(archive_dir)
        dest_slash = util.add_ending_slash(self.get_jboss_home())

        # reinstall - preserve user data
        excludes = ''
        cmd = 'sudo rsync -av --delete %s %s %s' \
              % (excludes, util.escape_shell(archive_slash), util.escape_shell(dest_slash))
        ret, out, err = self.sysconfig.cli_cmd_sync(cmd,
                                                    write_dots=True,
                                                    cwd=basedir)
        if ret != 0:
            raise errors.SetupError('jboss sync failed')

        self.fix_privileges()
Esempio n. 8
0
    def _deploy_downloaded(self, archive_path, basedir):
        """
        Analyzes downloaded file, deploys to the webroot
        :param archive_path:
        :param basedir:
        :return:
        """
        cmd = 'sudo unzip %s' % util.escape_shell(archive_path)
        ret, out, err = self.sysconfig.cli_cmd_sync(cmd,
                                                    write_dots=True,
                                                    cwd=basedir)
        if ret != 0:
            raise errors.SetupError('Could not extract update archive')

        folders = [
            f for f in os.listdir(basedir)
            if not os.path.isfile(os.path.join(basedir, f)) and f != '.'
            and f != '..'
        ]

        if len(folders) != 1:
            raise errors.SetupError(
                'Invalid folder structure after update extraction')

        archive_dir = os.path.join(basedir, folders[0])
        if not os.path.exists(archive_dir):
            raise errors.SetupError(
                'Directory with nextcloud not found in the update archive: %s'
                % archive_dir)
        if not os.path.exists(os.path.join(archive_dir, 'robots.txt')):
            raise errors.SetupError(
                'Invalid update archive, robots.txt not found in %s' %
                archive_dir)

        archive_slash = util.add_ending_slash(archive_dir)
        dest_slash = util.add_ending_slash(self.webroot)

        # reinstall - preserve user data
        excludes = ''
        if self.doing_reinstall:
            full_excludes = [
                os.path.join(dest_slash, x) for x in self.EXCLUDE_REINSTALL
            ]
            if os.path.exists(dest_slash):
                for d in [x for x in full_excludes if not os.path.exists(x)]:
                    os.makedirs(d)

                excludes = ' '.join([
                    '--exclude %s' %
                    util.escape_shell(util.add_ending_slash(x))
                    for x in full_excludes
                ])

        cmd = 'sudo rsync -av --delete %s %s %s' \
              % (excludes, util.escape_shell(archive_slash), util.escape_shell(dest_slash))
        ret, out, err = self.sysconfig.cli_cmd_sync(cmd,
                                                    write_dots=True,
                                                    cwd=basedir)
        if ret != 0:
            raise errors.SetupError('nextcloud sync failed')

        self._fix_privileges()