def init_configs(self): linux.fix_locale() variables = { 'apps_root': config.APPS_ROOT, 'data_root': config.DATA_ROOT, 'configs_root': config.DATA_ROOT, 'config_root': self.data_dir, 'config_dir': self.config_dir, 'app_dir': config.INSTALL_DIR, 'app_data': config.DATA_DIR, 'app_data_prefix': config.APP_DATA_PREFIX } gen.generate_files(self.templates_path, self.config_dir, variables) data_dirs = [ join(self.data_dir, 'webapps'), join(self.data_dir, 'log'), join(self.data_dir, 'nginx'), join(self.data_dir, 'openldap'), join(self.data_dir, 'openldap-data'), join(self.data_dir, 'certbot'), join(self.data_dir, 'certbot', 'www') ] for data_dir in data_dirs: fs.makepath(data_dir)
def prepare_storage(self): storage.init_storage(APP_NAME, USER_NAME) storage_dir = storage.get_storage_dir(APP_NAME) tmp_dir = join(storage_dir, 'tmp') fs.makepath(tmp_dir) fs.chownpath(tmp_dir, USER_NAME) uploads_dir = join(storage_dir, 'uploads') fs.makepath(uploads_dir) fs.chownpath(uploads_dir, USER_NAME)
def prepare_storage(self): app_storage_dir = storage.init_storage(APP_NAME, USER_NAME) ocdata = join(app_storage_dir, '.ocdata') fs.touchfile(ocdata) check_output('chown {0}. {1}'.format(USER_NAME, ocdata), shell=True) 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) real_app_storage_dir = realpath(app_storage_dir) self.oc_config.set_value('datadirectory', real_app_storage_dir)
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)
def init_keys(self): fs.makepath(self.openvpn_config_dir) openvpn_keys_dir = join(self.openvpn_config_dir, 'keys') fs.makepath(openvpn_keys_dir) shutil.copy(join(self.config_path, 'openvpn/keys/index.txt'), openvpn_keys_dir) shutil.copy(join(self.config_path, 'openvpn/keys/serial'), openvpn_keys_dir) shutil.copy(join(self.config_path, 'openvpn/keys/vars'), openvpn_keys_dir) check_output('{0} dhparam -dsaparam -out {1}/dh2048.pem 2048'.format( self.openssl_bin, self.openvpn_config_dir), shell=True) check_output(self.generate_keys_bin, shell=True)
def install_config(self): home_folder = join('/home', USER_NAME) linux.useradd(USER_NAME, home_folder=home_folder) storage.init_storage(APP_NAME, USER_NAME) templates_path = join(self.app_dir, 'config') variables = { 'app_dir': self.app_dir, 'common_dir': self.common_dir, 'data_dir': self.data_dir, 'db_psql_port': PSQL_PORT, 'database_dir': self.db.database_dir, 'config_dir': self.config_dir, 'domain': urls.get_app_domain_name(APP_NAME) } gen.generate_files(templates_path, self.config_dir, variables) fs.makepath(self.nextcloud_config_path) fs.makepath(join(self.common_dir, 'log')) fs.makepath(join(self.common_dir, 'nginx')) fs.makepath(self.extra_apps_dir) self.fix_permissions()
def install(self): home_folder = join('/home', USER_NAME) linux.useradd(USER_NAME, home_folder=home_folder) storage.init_storage(APP_NAME, USER_NAME) templates_path = join(self.app_dir, 'config') config_path = join(self.app_data_dir, 'config') variables = { 'app_dir': self.app_dir, 'app_data_dir': self.app_data_dir, 'syncthing_port': SYNCTHING_PORT } gen.generate_files(templates_path, config_path, variables) fs.makepath(join(self.app_data_dir, 'log')) fs.makepath(join(self.app_data_dir, 'nginx')) fs.chownpath(self.app_data_dir, USER_NAME, recursive=True)
def install(self): home_folder = join('/home', USER_NAME) linux.useradd(USER_NAME, home_folder=home_folder) self.regenerate_config() fs.makepath(join(self.app_data_dir, 'config')) fs.makepath(join(self.app_data_dir, 'redis')) fs.makepath(join(self.app_data_dir, 'log')) fs.makepath(join(self.app_data_dir, 'nginx')) fs.makepath(join(self.app_data_dir, 'tmp')) fs.chownpath(self.app_data_dir, USER_NAME, recursive=True) if 'SNAP' not in environ: self.log.info(fs.chownpath(self.app_dir, USER_NAME, recursive=True)) self.log.info("setup systemd") if not UserConfig(self.app_data_dir).is_activated(): database_init(self.log, self.app_dir, self.app_data_dir, self.database_path, USER_NAME)
def init_config(self): linux.useradd(USER_NAME) log_dir = join(self.common_dir, 'log') self.log.info('creating log dir: {0}'.format(log_dir)) fs.makepath(log_dir) fs.makepath(join(self.data_dir, 'nginx')) fs.makepath(join(self.data_dir, 'mongodb')) gen.generate_file_jinja(self.rocketchat_env_file_source, self.rocketchat_env_file_target, {'url': self.app_url}) fs.chownpath(self.data_dir, USER_NAME, recursive=True) fs.chownpath(self.common_dir, USER_NAME, recursive=True) self.prepare_storage()
def install_config(self): home_folder = join('/home', USER_NAME) linux.useradd(USER_NAME, home_folder=home_folder) fs.makepath(join(self.app_data_dir, 'log')) fs.makepath(join(self.app_data_dir, 'nginx')) fs.makepath(join(self.app_data_dir, 'temp')) storage.init_storage(APP_NAME, USER_NAME) templates_path = join(self.app_dir, 'config.templates') config_path = join(self.app_data_dir, 'config') variables = { 'app': APP_NAME, 'app_dir': self.app_dir, 'app_data_dir': self.app_data_dir } gen.generate_files(templates_path, config_path, variables)
def install(self): linux.useradd('maildrop') linux.useradd('dovecot') linux.useradd(USER_NAME) fs.makepath(join(self.app_data_dir, 'nginx')) self.regenerate_configs() fs.chownpath(self.app_data_dir, USER_NAME, recursive=True) data_dirs = [ join(self.app_data_dir, 'config'), join(self.app_data_dir, 'log'), join(self.app_data_dir, 'spool'), join(self.app_data_dir, 'dovecot'), join(self.app_data_dir, 'dovecot', 'private'), join(self.app_data_dir, 'data') ] for data_dir in data_dirs: fs.makepath(data_dir) fs.chownpath(data_dir, USER_NAME) box_data_dir = join(self.app_data_dir, 'box') fs.makepath(box_data_dir) fs.chownpath(box_data_dir, 'dovecot', recursive=True) dovecot_lda_error_log = join(self.app_data_dir, 'log', 'dovecot-lda.error.log') fs.touchfile(dovecot_lda_error_log) fs.chownpath(dovecot_lda_error_log, 'dovecot') dovecot_lda_info_log = join(self.app_data_dir, 'log', 'dovecot-lda.info.log') fs.touchfile(dovecot_lda_info_log) fs.chownpath(dovecot_lda_info_log, 'dovecot') self.log.info("setup configs") if not self.user_config.is_activated(): self.database_init(self.database_path, USER_NAME)
def install_config(self): home_folder = join(self.common_dir, USER_NAME) linux.useradd(USER_NAME, home_folder=home_folder) fs.makepath(join(self.common_dir, 'log')) fs.makepath(join(self.common_dir, 'nginx')) fs.makepath(join(self.snap_data_dir, 'data')) storage.init_storage(APP_NAME, USER_NAME) templates_path = join(self.app_dir, 'config.templates') config_path = join(self.snap_data_dir, 'config') variables = { 'app': APP_NAME, 'app_dir': self.app_dir, 'common_dir': self.common_dir, 'snap_data': self.snap_data_dir } gen.generate_files(templates_path, config_path, variables) fs.chownpath(self.snap_data_dir, USER_NAME, recursive=True) fs.chownpath(self.common_dir, USER_NAME, recursive=True)
def install_config(self): home_folder = join('/home', USER_NAME) linux.useradd(USER_NAME, home_folder=home_folder) fs.makepath(join(self.snap_common, 'log')) fs.makepath(join(self.snap_common, 'nginx')) fs.makepath(join(self.snap_common, 'db')) if os.path.lexists(self.prefix_delegation_link): os.remove(self.prefix_delegation_link) os.symlink(self.prefix_delegation_bin, self.prefix_delegation_link) storage.init_storage(APP_NAME, USER_NAME) templates_path = join(self.app_dir, 'config') variables = { 'app': APP_NAME, 'app_dir': self.app_dir, 'snap_data': self.snap_data, 'snap_common': self.snap_common, 'device_domain_name': self.device_domain_name } gen.generate_files(templates_path, self.config_path, variables)
def prepare_storage(self): app_storage_dir = storage.init_storage(APP_NAME, USER_NAME) tmp_storage_path = join(app_storage_dir, 'tmp') fs.makepath(tmp_storage_path) fs.chownpath(tmp_storage_path, USER_NAME)