<% def action = request.getParameter('action'); if (action) { String redirectUrl = null; if (action == 'reload') { redirectUrl = request.getRequestURI() + "?" + request.getQueryString().replace('&action=reload',''); def f = new File("etc/init.properties"); if (f.exists()) { def reader = f.newReader(); def props = new java.util.Properties(); props.load(reader); config.clear(); props.stringPropertyNames().each { key -> if ("config-type".equals(key)) { config['configType'] = props.get(key); } else if ("--virt-hosts".equals(key)) { config['virtualDomains'] = props.get(key); } else if ("--admins".equals(key)) { config['admins'] = props.get(key); } else if ("--user-db-uri".equals(key)) { def uri = props.get(key); def dbType = ( uri =~ /:([^:]+):/ )[0][1]; if (dbType == 'mysql') dbType = "MySQL"; if (dbType == 'postgresql') dbType = 'PostgreSQL'; if (dbType == 'derby') dbType = 'Derby'; if (dbType == 'sqlserver') dbType = 'SQLServer'; config['dbType'] = dbType; config['dbHost'] = ( uri =~ /\/\/([^\/]+)\// )[0][1]; config['dbName'] = ( uri =~ /\/([^\/\?]+)\?/ )[0][1]; config['dbUser'] = ( uri =~ /\?user=([^\&]+)&/ )[0][1]; config['dbPass'] = ( uri =~ /&password=([^\&]+)/ )[0][1]; } else if (key.startsWith('--comp-class')) { def value = props.get(key); if (value.contains('PubSub')) config.PubSubComponent = true; if (value.contains('MUC')) config.mucComponent = true; if (value.contains('Stun')) confg.stunComponent = true; if (value.contains('Socks5')) config.socks5Component = true; if (value.contains('Http')) config.httpApiComponent = true; if (value.contains('MessageArchiving')) config.messageArchivingComponent = true; } else if ('--sm-plugins'.equals(key)) { if (!config.plugins) config.plugins = []; props.get(key).split(',').each { def itkey = (it.startsWith('-') || it.startsWith('+')) ? it.substring(1, it.length()) : it; itkey = itkey.replaceAll("\\:",":"); config.plugins.add([key:itkey, value:(!it.startsWith('-'))]); } } else if ('--debug'.equals(key)) { props.get(key).split(',').collect { it + 'Debug' }.each { config[it] = true; } } else if ('--cluster-mode'.equals(key)) { config.clusterMode = "true".equals(props.get(key)); } } reader.close(); } } else if (action == 'reset') { redirectUrl = request.getRequestURI() + "?" + request.getQueryString().replace('&action=reset',''); config.clear(); } %> <% return; } def tmp = [ test:1 ] + config; def title = 'Load configuration' tmp.each { k,v -> if (request.getParameter(k)) { Object old = tmp[k]; if (old instanceof Boolean) { tmp[k] = Boolean.parseBoolean(request.getParameter(k)); } else { tmp[k] = request.getParameter(k); } } } config.clear(); config.putAll(tmp); %> ${ util.include('header', [title:'Setup: ' + title]) }

<% def components = []; if (config.mucComponent) { def cls = 'tigase.muc.MUCComponnet'; if (config.acsMUCComponent) { cls = 'tigase.muc.cluster.MUCComponentClustered'; } components.add([cls:cls, name:'muc']); } if (config.PubSubComponent) { def cls = 'tigase.pubsub.PubSubComponent'; if (config.acsPubSubComponent) { cls = 'tigase.pubsub.cluster.PubSubComponentClustered'; } components.add([cls:cls, name:'pubsub']); } if (config.httpApiComponent) { components.add([cls:'tigase.http.HttpMessageReceiver', name:'http']); } if (config.stunComponent) { components.add([cls:'tigase.stun.StunComponent', name:'stun']); } if (config.socks5Component) { components.add([cls:'tigase.socks5.Socks5Component', name:'socks5']); } if (config.messageArchivingComponent) { components.add([cls:'tigase.archive.MessageArchiveComponent', name:'message-archiving']); } %>
${ util.include('footer') }