コード例 #1
0
    def init_configs(self):
        linux.fix_locale()

        templates_path = join(config.INSTALL_DIR, 'config.templates')
        config_dir = join(config.DATA_DIR, 'config')
        data_dir = config.DATA_DIR
        variables = {
            'apps_root': config.APPS_ROOT,
            'data_root': config.DATA_ROOT,
            'configs_root': config.DATA_ROOT,
            'config_root': data_dir,
            'config_dir': config_dir,
            'app_dir': config.INSTALL_DIR,
            'app_data': config.DATA_DIR,
            'app_data_prefix': config.APP_DATA_PREFIX
        }
        gen.generate_files(templates_path, config_dir, variables)

        data_dirs = [
            join(data_dir, 'webapps'),
            join(data_dir, 'log'),
            join(data_dir, 'nginx'),
            join(data_dir, 'openldap'),
            join(data_dir, 'openldap-data'),
            join(data_dir, 'certbot'),
            join(data_dir, 'certbot', 'www')
        ]

        for data_dir in data_dirs:
            fs.makepath(data_dir)
コード例 #2
0
 def prepare_storage(self):
     app_storage_dir = self.app.init_storage(USER_NAME)
     fs.touchfile(join(app_storage_dir, '.ocdata'))
     check_output('chmod 770 {0}'.format(app_storage_dir), shell=True)
     tmp_storage_path = join(app_storage_dir, 'tmp')
     fs.makepath(tmp_storage_path)
     fs.chownpath(tmp_storage_path, USER_NAME)
コード例 #3
0
ファイル: installer.py プロジェクト: syncloud/owncloud
    def install(self):

        linux.fix_locale()

        linux.useradd(USER_NAME)

        templates_path = join(self.app.get_install_dir(), 'config.templates')
        config_path = join(self.app.get_data_dir(), 'config')

        app_data_dir = self.app.get_data_dir()

        variables = {
            'app_dir': self.app.get_install_dir(),
            'app_data_dir': app_data_dir,
            'db_psql_port': PSQL_PORT
        }
        gen.generate_files(templates_path, config_path, variables)
        fs.chownpath(self.app.get_install_dir(), USER_NAME, recursive=True)

        config_data_dir = join(app_data_dir, 'config')
        log_dir = join(app_data_dir, 'log')

        fs.makepath(config_data_dir)
        fs.makepath(log_dir)

        fs.chownpath(app_data_dir, USER_NAME, recursive=True)

        config_app_dir = join(self.app.get_install_dir(), APP_CONFIG_PATH)
        symlink(config_data_dir, config_app_dir)

        database_init(self.log, self.app.get_install_dir(), self.app.get_data_dir(), USER_NAME)

        print("setup systemd")
        self.app.add_service(SYSTEMD_POSTGRESQL)
        self.app.add_service(SYSTEMD_PHP_FPM_NAME)
        self.app.add_service(SYSTEMD_NGINX_NAME)

        self.prepare_storage()

        if self.installed():
            self.upgrade()
        else:
            self.initialize()

        cron = OwncloudCron(join(self.app.get_install_dir(), CRON_CMD), CRON_USER)
        cron.remove()
        cron.create()

        oc_config = OCConfig(join(self.app.get_install_dir(), OC_CONFIG_PATH))
        oc_config.set_value('memcache.local', '\OC\Memcache\APCu')
        oc_config.set_value('loglevel', '2')
        oc_config.set_value('logfile', join(self.app.get_data_dir(), OWNCLOUD_LOG_PATH))
        oc_config.set_value('datadirectory', self.app.get_storage_dir())

        self.on_domain_change()

        fs.chownpath(self.app.get_data_dir(), USER_NAME, recursive=True)
コード例 #4
0
    def init(self):
        if self.installed():
            self.log.info('ldap config already initialized')
            return

        self.log.info('initializing ldap config')
        fs.makepath(self.user_conf_dir)
        init_script = '{0}/ldap/slapd.ldif'.format(self.config.config_dir())

        check_output('{0}/sbin/slapadd.sh -F {1} -b "cn=config" -l {2}'.format(
            self.ldap_root, self.user_conf_dir, init_script),
                     shell=True)
コード例 #5
0
    def install(self):
        linux.fix_locale()

        apps_root = '/snap'
        data_root = '/var/snap'
        install_dir = os.environ['SNAP']
        data_dir = os.environ['SNAP_COMMON']
        app_data_prefix = 'common/'

        templates_path = join(install_dir, 'config.templates')
        config_dir = join(data_dir, 'config')

        variables = {
            'apps_root': apps_root,
            'data_root': data_root,
            'configs_root': data_root,
            'config_root': data_dir,
            'config_dir': config_dir,
            'app_dir': install_dir,
            'app_data': data_dir,
            'app_data_prefix': app_data_prefix
        }
        gen.generate_files(templates_path, config_dir, variables)

        data_dirs = [
            join(data_dir, 'webapps'),
            join(data_dir, 'log'),
            join(data_dir, 'nginx'),
            join(data_dir, 'openldap'),
            join(data_dir, 'openldap-data'),
            join(data_dir, 'certbot'),
            join(data_dir, 'certbot', 'www')
        ]

        for data_dir in data_dirs:
            fs.makepath(data_dir)

        injector = get_injector()

        hardware = injector.hardware
        hardware.init_disk()

        injector.tls.init_certificate()

        injector.platform_cron.remove()
        injector.platform_cron.create()

        ldap_auth = injector.ldap_auth
        ldap_auth.init()

        nginx = injector.nginx
        nginx.init_config()
コード例 #6
0
    def init(self, fix_permissions=False):
        if self.installed():
            self.log.info('ldap config already initialized')
            return

        self.log.info('initializing ldap config')
        fs.makepath(self.user_conf_dir)
        init_script = '{0}/ldap/slapd.ldif'.format(self.config.config_dir())

        check_output('{0}/sbin/slapadd -F {1} -b "cn=config" -l {2}'.format(
            self.ldap_root, self.user_conf_dir, init_script),
                     shell=True)

        if fix_permissions:
            self.log.info('fixing permissions for ldap user conf')
            fs.chownpath(self.user_conf_dir, platform_user, recursive=True)
コード例 #7
0
    def install(self):

        linux.fix_locale()

        linux.useradd(USER_NAME)

        self.log.info(fs.chownpath(self.app.get_install_dir(), USER_NAME, recursive=True))

        app_data_dir = self.app.get_data_dir()
        database_path = '{0}/database'.format(app_data_dir)

        variables = {
            'app_dir': self.app_dir,
            'app_data_dir': app_data_dir,
            'db_psql_path': database_path,
            'db_psql_port': PSQL_PORT,
            'db_name': DB_NAME,
            'db_user': DB_USER,
            'db_password': DB_PASS
        }

        templates_path = join(self.app_dir, 'config.templates')
        config_path = join(app_data_dir, 'config')
        gen.generate_files(templates_path, config_path, variables)

        fs.makepath(join(app_data_dir, 'config'))
        fs.makepath(join(app_data_dir, 'redis'))
        fs.makepath(join(app_data_dir, 'log'))
        fs.makepath(join(app_data_dir, 'nginx'))

        fs.chownpath(app_data_dir, USER_NAME, recursive=True)

        self.log.info("setup systemd")

        user_config = UserConfig(app_data_dir)
        is_first_time = not user_config.is_activated()
        if is_first_time:
            database_init(self.log, self.app_dir, app_data_dir, database_path, USER_NAME)

        self.app.add_service(SYSTEMD_POSTGRESQL)

        config = Config(app_data_dir)
        symlink(join(config_path, 'diaspora', 'diaspora.yml'), join(self.app_dir, 'diaspora', 'config', 'diaspora.yml'))
        symlink(join(config_path, 'diaspora', 'database.yml'), join(self.app_dir, 'diaspora', 'config', 'database.yml'))
        self.update_configuraiton(config)

        if is_first_time:
            self.initialize(app_data_dir, config)

        self.log.info(fs.chownpath(self.app_dir, USER_NAME, recursive=True))

        self.app.add_service(SYSTEMD_REDIS)
        self.app.add_service(SYSTEMD_SIDEKIQ)
        self.app.add_service(SYSTEMD_UNICORN)
        self.app.add_service(SYSTEMD_NGINX_NAME)

        self.app.init_storage(USER_NAME)
コード例 #8
0
ファイル: installer.py プロジェクト: syncloud/diaspora
    def install(self):

        linux.fix_locale()

        linux.useradd(USER_NAME)

        self.log.info(fs.chownpath(self.app.get_install_dir(), USER_NAME, recursive=True))

        app_data_dir = self.app.get_data_dir()

        fs.makepath(join(app_data_dir, 'config'))
        fs.makepath(join(app_data_dir, 'postgresql'))
        fs.makepath(join(app_data_dir, 'redis'))
        fs.makepath(join(app_data_dir, 'log'))
        fs.makepath(join(app_data_dir, 'nginx'))

        fs.chownpath(app_data_dir, USER_NAME, recursive=True)

        print("setup systemd")

        self.app.add_service(SYSTEMD_POSTGRESQL)

        self.update_configuraiton()

        if not UserConfig().is_installed():
            self.initialize()

        #self.recompile_assets()

        self.log.info(fs.chownpath(self.config.install_path(), USER_NAME, recursive=True))

        self.app.add_service(SYSTEMD_REDIS)
        self.app.add_service(SYSTEMD_SIDEKIQ)
        self.app.add_service(SYSTEMD_UNICORN)
        self.app.add_service(SYSTEMD_NGINX_NAME)

        self.app.init_storage(USER_NAME)

        self.app.register_web(self.config.port())
コード例 #9
0
ファイル: ldapauth.py プロジェクト: Shadance/platform
    def reset(self, user, password):

        data_dir = self.app_paths.get_data_dir()
        user_conf_dir = join(data_dir, ldap_user_conf_dir)
        fs.removepath(user_conf_dir)
        fs.makepath(user_conf_dir)
        fs.chownpath(user_conf_dir, platform_user)

        stop_service('platform-openldap')

        files = glob.glob('/opt/data/platform/openldap-data/*')
        for f in files:
            os.remove(f)

        init_script = '{0}/ldap/slapd.ldif'.format(self.config.config_dir())
        ldap_root = '{0}/openldap'.format(self.config.app_dir())

        check_output('{0}/sbin/slapadd -F {1} -b "cn=config" -l {2}'.format(
            ldap_root, user_conf_dir, init_script),
                     shell=True)

        check_output('chown -R {0}. {1}'.format(platform_user, user_conf_dir),
                     shell=True)

        start_service('platform-openldap')

        fd, filename = tempfile.mkstemp()
        util.transform_file(
            '{0}/ldap/init.ldif'.format(self.config.config_dir()), filename, {
                'user': user,
                'password': make_secret(password)
            })

        self.__init_db(filename, ldap_root)

        check_output('echo "root:{0}" | chpasswd'.format(password), shell=True)
コード例 #10
0
    def install(self):

        linux.fix_locale()

        linux.useradd(USER_NAME)

        templates_path = join(self.app.get_install_dir(), 'templates')
        config_path = join(self.app.get_install_dir(), 'config')

        app_data_dir = self.app.get_data_dir()

        variables = {
            'app_dir': self.app.get_install_dir(),
            'app_data_dir': app_data_dir,
            'web_port': OWNCLOUD_PORT
        }
        gen.generate_files(templates_path, config_path, variables)
        fs.chownpath(self.app.get_install_dir(), USER_NAME, recursive=True)

        config_data_dir = join(app_data_dir, 'config')
        log_dir = join(app_data_dir, 'log')

        fs.makepath(config_data_dir)
        fs.makepath(log_dir)

        fs.chownpath(app_data_dir, USER_NAME, recursive=True)

        config_app_dir = join(self.app.get_install_dir(), OWNCLOUD_APP_CONFIG_PATH)
        symlink(config_data_dir, config_app_dir)

        database_path = join(self.app.get_data_dir(), 'database')
        if not isdir(database_path):
            psql_initdb = join(self.app.get_install_dir(), 'postgresql/bin/initdb')
            check_output(['sudo', '-H', '-u', USER_NAME, psql_initdb, database_path])

        print("setup systemd")
        self.app.add_service(SYSTEMD_POSTGRESQL)
        self.app.add_service(SYSTEMD_PHP_FPM_NAME)
        self.app.add_service(SYSTEMD_NGINX_NAME)

        self.prepare_storage()

        if not self.installed():
            self.initialize()

        cron = OwncloudCron(join(self.app.get_install_dir(), CRON_CMD), CRON_USER)
        cron.remove()
        cron.create()

        oc_config = OCConfig(join(self.app.get_install_dir(), OC_CONFIG_PATH))
        oc_config.set_value('memcache.local', '\OC\Memcache\APCu')
        oc_config.set_value('loglevel', '2')
        oc_config.set_value('logfile', join(self.app.get_data_dir(), OWNCLOUD_LOG_PATH))
        oc_config.set_value('datadirectory', self.app.get_storage_dir())
        oc_config.set_value('integrity.check.disabled', 'true')

        self.update_domain()

        fs.chownpath(self.app.get_data_dir(), USER_NAME, recursive=True)

        self.app.register_web(OWNCLOUD_PORT)
コード例 #11
0
    'app_dir': install_dir,
    'app_data': app_data
}
gen.generate_files(templates_path, config_dir, variables)

data_dirs = [
    join(app_data, 'webapps'),
    join(app_data, 'log'),
    join(app_data, 'nginx'),
    join(app_data, 'openldap'),
    join(app_data, 'openldap-data'),
    join(app_data, 'certbot')
]

for data_dir in data_dirs:
    fs.makepath(data_dir)

injector = get_injector(config_dir=config_dir)

hardware = injector.hardware
hardware.init_disk()

injector.tls.init_certificate()

injector.platform_cron.remove()
injector.platform_cron.create()

udev = injector.udev
udev.remove()
udev.add()
コード例 #12
0
ファイル: installer.py プロジェクト: fuzioncloud/owncloud
    def install(self):

        linux.fix_locale()

        linux.useradd(USER_NAME)

        templates_path = join(self.app.get_install_dir(), 'config.templates')
        config_path = join(self.app.get_install_dir(), 'config')

        app_data_dir = self.app.get_data_dir()

        variables = {
            'app_dir': self.app.get_install_dir(),
            'app_data_dir': app_data_dir,
            'web_port': WEB_PORT,
            'db_psql_port': PSQL_PORT
        }
        gen.generate_files(templates_path, config_path, variables)
        fs.chownpath(self.app.get_install_dir(), USER_NAME, recursive=True)

        config_data_dir = join(app_data_dir, 'config')
        log_dir = join(app_data_dir, 'log')

        fs.makepath(config_data_dir)
        fs.makepath(log_dir)

        fs.chownpath(app_data_dir, USER_NAME, recursive=True)

        config_app_dir = join(self.app.get_install_dir(), APP_CONFIG_PATH)
        symlink(config_data_dir, config_app_dir)

        database_init(self.log, self.app.get_install_dir(),
                      self.app.get_data_dir(), USER_NAME)

        print("setup systemd")
        self.app.add_service(SYSTEMD_POSTGRESQL)
        self.app.add_service(SYSTEMD_PHP_FPM_NAME)
        self.app.add_service(SYSTEMD_NGINX_NAME)

        self.prepare_storage()

        if self.installed():
            self.upgrade()
        else:
            self.initialize()

        cron = OwncloudCron(join(self.app.get_install_dir(), CRON_CMD),
                            CRON_USER)
        cron.remove()
        cron.create()

        oc_config = OCConfig(join(self.app.get_install_dir(), OC_CONFIG_PATH))
        oc_config.set_value('memcache.local', '\OC\Memcache\APCu')
        oc_config.set_value('loglevel', '2')
        oc_config.set_value('logfile',
                            join(self.app.get_data_dir(), OWNCLOUD_LOG_PATH))
        oc_config.set_value('datadirectory', self.app.get_storage_dir())

        self.on_domain_change()

        fs.chownpath(self.app.get_data_dir(), USER_NAME, recursive=True)

        self.app.register_web(WEB_PORT)