def _unregister_app(self, app, args, lo=None, pos=None, delay=False): if lo is None: lo, pos = self._get_ldap_connection(args, allow_machine_connection=True) updates = {} for key in ucr_keys(): if key.startswith('appcenter/apps/%s/' % app.id): updates[key] = None if re.match('ucs/web/overview/entries/[^/]+/%s/' % app.id, key): updates[key] = None if re.match('appreport/%s/' % app.id, key): updates[key] = None if app.docker and not app.plugin_of: try: from univention.appcenter.actions.service import Service except ImportError: # univention-appcenter-docker is not installed pass else: try: init_script = Service.get_init(app) os.unlink(init_script) self._call_script('/usr/sbin/update-rc.d', os.path.basename(init_script), 'remove') except OSError: pass ldap_object = get_app_ldap_object(app, lo, pos) if ldap_object: self.log('Removing localhost from LDAP object') ldap_object.remove_localhost() if not delay: ucr_save(updates) self._reload_apache() return updates
def _register_docker_variables(self, app): updates = {} if app.docker and not app.plugin_of: try: from univention.appcenter.actions.service import Service, ORIGINAL_INIT_SCRIPT except ImportError: # univention-appcenter-docker is not installed pass else: if not app.uses_docker_compose(): try: init_script = Service.get_init(app) self.log('Creating %s' % init_script) with open(ORIGINAL_INIT_SCRIPT, 'r') as source: lines = source.readlines() with open(init_script, 'w') as target: for line in lines: target.write(re.sub(r'@%@APPID@%@', app.id, line)) os.chmod(init_script, 0o755) self._call_script('/usr/sbin/update-rc.d', os.path.basename(init_script), 'defaults', '41', '14') self._call_script('/bin/systemctl', 'daemon-reload') except OSError as exc: msg = str(exc) if exc.errno == 17: self.log(msg) else: self.warn(msg) updates[app.ucr_image_key] = app.get_docker_image_name() return updates