def sync_all(self): update_token = self.user_platform_config.get_domain_update_token() if update_token is None: return external_access = self.user_platform_config.get_external_access() upnp = self.user_platform_config.get_upnp() public_ip = self.user_platform_config.get_public_ip() manual_certificate_port = self.user_platform_config.get_manual_certificate_port( ) manual_access_port = self.user_platform_config.get_manual_access_port() port_drill = self.port_drill_factory.get_drill( upnp, external_access, public_ip, manual_certificate_port, manual_access_port) try: port_drill.sync_existing_ports() except Exception as e: self.logger.error('Unable to sync port mappings: {0}'.format( str(e))) router_port = None mapping = port_drill.get(WEB_ACCESS_PORT, http_network_protocol) if mapping: router_port = mapping.external_port external_ip = port_drill.external_ip() self.redirect_service.sync(external_ip, router_port, WEB_ACCESS_PORT, WEB_PROTOCOL, update_token, external_access) if not getpass.getuser() == self.platform_config.cron_user(): fs.chownpath(self.platform_config.data_dir(), self.platform_config.cron_user())
def install(self): self.install_config() self.database_init() shutil.copytree(join(self.app_dir, 'wp-content.template'), join(self.app_data_dir, 'wp-content')) fs.chownpath(self.app_data_dir, USER_NAME, recursive=True)
def init_app_storage(self, app_id, owner=None): app_storage_dir = self.get_app_storage_dir(app_id) if not path.exists(app_storage_dir): os.mkdir(app_storage_dir) if owner: self.log.info('fixing permissions on {0}'.format(app_storage_dir)) fs.chownpath(app_storage_dir, owner, recursive=True) else: self.log.info('not fixing permissions') return app_storage_dir
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 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 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(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): 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(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 regenerate_configs(self): variables = { 'app_dir': self.app_dir, 'app_data_dir': self.app_data_dir, 'db_psql_path': self.database_path, 'db_psql_port': PSQL_PORT, 'db_name': DB_NAME, 'db_user': DB_USER, 'db_password': DB_PASS, 'platform_data_dir': self.platform_data_dir, 'device_domain_name': self.device_domain_name, 'app_domain_name': self.app_domain_name, 'timezone': get_localzone() } templates_path = join(self.app_dir, 'config.templates') gen.generate_files(templates_path, self.config_path, variables) self.log.info(fs.chownpath(self.config_path, USER_NAME, recursive=True))
def fix_permissions(self): fs.chownpath(self.snap_data, USER_NAME, recursive=True) fs.chownpath(self.snap_common, USER_NAME, recursive=True)
def fix_config_permission(self): fs.chownpath(self.nextcloud_config_file, USER_NAME)
except Exception, e: self.logger.error('Unable to sync port mappings: {0}'.format( e.message)) router_port = None mapping = port_drill.get(WEB_ACCESS_PORT, http_network_protocol) if mapping: router_port = mapping.external_port external_ip = port_drill.external_ip() self.redirect_service.sync(external_ip, router_port, WEB_ACCESS_PORT, WEB_PROTOCOL, update_token, external_access) if not getpass.getuser() == self.platform_config.cron_user(): fs.chownpath(self.platform_config.data_dir(), self.platform_config.cron_user()) def add_port(self, local_port, protocol): external_access = self.user_platform_config.get_external_access() upnp = self.user_platform_config.get_upnp() public_ip = self.user_platform_config.get_public_ip() manual_certificate_port = self.user_platform_config.get_manual_certificate_port( ) manual_access_port = self.user_platform_config.get_manual_access_port() drill = self.port_drill_factory.get_drill(upnp, external_access, public_ip, manual_certificate_port, manual_access_port) drill.sync_new_port(local_port, protocol) def remove_port(self, local_port, protocol):
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)
def refresh(self): self.install_config() fs.chownpath(self.app_data_dir, USER_NAME, recursive=True)