local updates
This commit is contained in:
parent
8e8d2f17b8
commit
ba0f9e9245
@ -12,6 +12,7 @@ import javax.script.ScriptEngineManager;
|
|||||||
import javax.script.ScriptException;
|
import javax.script.ScriptException;
|
||||||
|
|
||||||
import de.hsadmin.common.error.TechnicalException;
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
|
import de.hsadmin.jscli.console.CommandShell;
|
||||||
import de.hsadmin.jscli.console.ConsoleWrapper;
|
import de.hsadmin.jscli.console.ConsoleWrapper;
|
||||||
import de.hsadmin.jscli.exception.JSCliException;
|
import de.hsadmin.jscli.exception.JSCliException;
|
||||||
import de.hsadmin.login.cas.TicketProviderFactory;
|
import de.hsadmin.login.cas.TicketProviderFactory;
|
||||||
@ -23,14 +24,18 @@ public class ScriptClient {
|
|||||||
|
|
||||||
public ScriptClient(final ConsoleWrapper console, final String user, final String runAs, final String... arguments) throws JSCliException {
|
public ScriptClient(final ConsoleWrapper console, final String user, final String runAs, final String... arguments) throws JSCliException {
|
||||||
final RpcClient rpcClient = new RpcClient();
|
final RpcClient rpcClient = new RpcClient();
|
||||||
|
final CommandShell commandShell = new CommandShell();
|
||||||
try {
|
try {
|
||||||
engine = new ScriptEngineManager().getEngineByName("js");
|
engine = new ScriptEngineManager().getEngineByName("js");
|
||||||
engine.put("casgrantingticket", TicketProviderFactory.getInstance(console, user, runAs));
|
engine.put("casgrantingticket", TicketProviderFactory.getInstance(console, user, runAs));
|
||||||
engine.put("xmlrpcclient", rpcClient);
|
engine.put("xmlrpcclient", rpcClient);
|
||||||
engine.put("xmlrpcLastResult", null);
|
engine.put("xmlrpcLastResult", null);
|
||||||
|
engine.put("commandshell", commandShell);
|
||||||
completionStrings = new HashSet<String>();
|
completionStrings = new HashSet<String>();
|
||||||
completionStrings.add("set");
|
completionStrings.add("set");
|
||||||
completionStrings.add("where");
|
completionStrings.add("where");
|
||||||
|
completionStrings.add("commandshell");
|
||||||
|
completionStrings.add("commandshell.execute");
|
||||||
considerArguments(arguments);
|
considerArguments(arguments);
|
||||||
try {
|
try {
|
||||||
final ClassLoader classLoader = getClass().getClassLoader();
|
final ClassLoader classLoader = getClass().getClassLoader();
|
||||||
|
61
cli/src/main/java/de/hsadmin/jscli/console/CommandShell.java
Normal file
61
cli/src/main/java/de/hsadmin/jscli/console/CommandShell.java
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package de.hsadmin.jscli.console;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
|
import de.hsadmin.jscli.exception.ShellException;
|
||||||
|
|
||||||
|
public class CommandShell {
|
||||||
|
|
||||||
|
public String execute(String command) throws ShellException {
|
||||||
|
return execute(command, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String execute(String command, String stdInput) throws ShellException {
|
||||||
|
Process backend = null;
|
||||||
|
String callOutput = null;
|
||||||
|
int exitCode = 0;
|
||||||
|
try {
|
||||||
|
String[] cmdArray = { "/bin/bash", "-c", command };
|
||||||
|
backend = Runtime.getRuntime().exec(cmdArray);
|
||||||
|
if (stdInput != null) {
|
||||||
|
OutputStream stdInputStream = backend.getOutputStream();
|
||||||
|
PrintWriter stdInputWriter = new PrintWriter(stdInputStream);
|
||||||
|
stdInputWriter.print(stdInput);
|
||||||
|
stdInputWriter.close();
|
||||||
|
stdInputStream.close();
|
||||||
|
}
|
||||||
|
callOutput = readProcessStream(backend.getInputStream());
|
||||||
|
exitCode = backend.waitFor();
|
||||||
|
if (exitCode != 0) {
|
||||||
|
String aErr = readProcessStream(backend.getErrorStream());
|
||||||
|
throw new ShellException(aErr);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ShellException(e);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new ShellException(e);
|
||||||
|
}
|
||||||
|
if (callOutput != null) {
|
||||||
|
return callOutput.trim();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String readProcessStream(InputStream stream) throws IOException {
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
|
||||||
|
StringBuffer textBuff = new StringBuffer();
|
||||||
|
String textLine = reader.readLine();
|
||||||
|
while (textLine != null) {
|
||||||
|
textBuff.append(textLine);
|
||||||
|
textBuff.append('\n');
|
||||||
|
textLine = reader.readLine();
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
return textBuff.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package de.hsadmin.jscli.exception;
|
||||||
|
|
||||||
|
public class ShellException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 5499293305075489652L;
|
||||||
|
|
||||||
|
public ShellException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShellException(Throwable e) {
|
||||||
|
super(e);
|
||||||
|
}
|
||||||
|
}
|
@ -22,7 +22,7 @@ function hsaParseParam(val) {
|
|||||||
function hsaParseParamArray(o) {
|
function hsaParseParamArray(o) {
|
||||||
var lst = new JArrayList();
|
var lst = new JArrayList();
|
||||||
var val = '';
|
var val = '';
|
||||||
for (var idx=0; idx < o.length; idx++) {
|
for (var idx = 0; idx < o.length; idx++) {
|
||||||
val = o[idx];
|
val = o[idx];
|
||||||
if (typeof val === 'object' && val.constructor === Array) {
|
if (typeof val === 'object' && val.constructor === Array) {
|
||||||
val = hsaParseParamArray(val);
|
val = hsaParseParamArray(val);
|
||||||
@ -55,8 +55,8 @@ function hsaParseParamObject(o) {
|
|||||||
function hsaToNativeJSObject(val) {
|
function hsaToNativeJSObject(val) {
|
||||||
if (val instanceof java.util.List) {
|
if (val instanceof java.util.List) {
|
||||||
var res = [];
|
var res = [];
|
||||||
for (var i = 0; i < val.size(); i++) {
|
for (var idx = 0; idx < val.size(); idx++) {
|
||||||
res[i] = hsaToNativeJSObject(val.get(i));
|
res[idx] = hsaToNativeJSObject(val.get(idx));
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -88,3 +88,14 @@ function hsaModuleCall(mod, fct, json) {
|
|||||||
xmlrpcLastResult = xmlrpcclient.execute(mod + "." + fct, params);
|
xmlrpcLastResult = xmlrpcclient.execute(mod + "." + fct, params);
|
||||||
return hsaToNativeJSObject(xmlrpcLastResult);
|
return hsaToNativeJSObject(xmlrpcLastResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pwGen() {
|
||||||
|
var chars = "0123456789ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz_#%&$+-!?.*=";
|
||||||
|
var pwLength = 14;
|
||||||
|
var randomstring = '';
|
||||||
|
for (var idx = 0; idx < pwLength; idx++) {
|
||||||
|
var rnum = Math.floor(Math.random() * chars.length);
|
||||||
|
randomstring += chars.substring(rnum,rnum+1);
|
||||||
|
}
|
||||||
|
return randomstring;
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package de.hsadmin.web;
|
package de.hsadmin.web;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -39,11 +41,13 @@ public class BinaryPathEditor extends CustomComponent implements IHSEditor {
|
|||||||
"/usr/lib/cgi-bin/php8.0",
|
"/usr/lib/cgi-bin/php8.0",
|
||||||
"/usr/lib/cgi-bin/php8.1",
|
"/usr/lib/cgi-bin/php8.1",
|
||||||
"/usr/lib/cgi-bin/php8.2",
|
"/usr/lib/cgi-bin/php8.2",
|
||||||
|
"/usr/lib/cgi-bin/php8.3",
|
||||||
"/usr/lib/cgi-bin/php"
|
"/usr/lib/cgi-bin/php"
|
||||||
};
|
};
|
||||||
|
|
||||||
private PropertyInfo propertyInfo;
|
|
||||||
private I18N i18n;
|
private I18N i18n;
|
||||||
|
private PropertyInfo propertyInfo;
|
||||||
|
private String[] selectablePathValues;
|
||||||
private HorizontalLayout layout;
|
private HorizontalLayout layout;
|
||||||
private NativeSelect isManagedInstallationSelect;
|
private NativeSelect isManagedInstallationSelect;
|
||||||
private NativeSelect managedPathSelect;
|
private NativeSelect managedPathSelect;
|
||||||
@ -52,6 +56,7 @@ public class BinaryPathEditor extends CustomComponent implements IHSEditor {
|
|||||||
public BinaryPathEditor(final I18N i18n, final PropertyInfo propertyInfo, final String[] values) {
|
public BinaryPathEditor(final I18N i18n, final PropertyInfo propertyInfo, final String[] values) {
|
||||||
this.propertyInfo = propertyInfo;
|
this.propertyInfo = propertyInfo;
|
||||||
this.i18n = i18n;
|
this.i18n = i18n;
|
||||||
|
this.selectablePathValues = values;
|
||||||
this.setCaption(i18n.getText(propertyInfo.getName()));
|
this.setCaption(i18n.getText(propertyInfo.getName()));
|
||||||
layout = new HorizontalLayout();
|
layout = new HorizontalLayout();
|
||||||
layout.setSpacing(true);
|
layout.setSpacing(true);
|
||||||
@ -73,10 +78,10 @@ public class BinaryPathEditor extends CustomComponent implements IHSEditor {
|
|||||||
defaultPath = path;
|
defaultPath = path;
|
||||||
}
|
}
|
||||||
managedPathSelect.setValue(defaultPath);
|
managedPathSelect.setValue(defaultPath);
|
||||||
managedPathSelect.setWidth("400px");
|
managedPathSelect.setWidth("436px");
|
||||||
layout.addComponent(managedPathSelect);
|
layout.addComponent(managedPathSelect);
|
||||||
pathField = new TextField();
|
pathField = new TextField();
|
||||||
pathField.setWidth("400px");
|
pathField.setWidth("436px");
|
||||||
pathField.setVisible(false);
|
pathField.setVisible(false);
|
||||||
layout.addComponent(pathField);
|
layout.addComponent(pathField);
|
||||||
isManagedInstallationSelect.setImmediate(true);
|
isManagedInstallationSelect.setImmediate(true);
|
||||||
@ -102,7 +107,7 @@ public class BinaryPathEditor extends CustomComponent implements IHSEditor {
|
|||||||
if (value == null) value = "";
|
if (value == null) value = "";
|
||||||
if (!(value instanceof String)) value = "";
|
if (!(value instanceof String)) value = "";
|
||||||
String text = (String) value;
|
String text = (String) value;
|
||||||
if (text.isEmpty() || text.startsWith("/usr/bin/") || text.startsWith("/usr/lib/")) {
|
if (text.isEmpty() || Arrays.asList(selectablePathValues).contains(text)) {
|
||||||
isManagedInstallationSelect.setValue(i18n.getText("patheditor.managed"));
|
isManagedInstallationSelect.setValue(i18n.getText("patheditor.managed"));
|
||||||
managedPathSelect.setValue(text);
|
managedPathSelect.setValue(text);
|
||||||
} else {
|
} else {
|
||||||
|
@ -194,7 +194,7 @@ pac.basepac=Packet type
|
|||||||
pac.hive=Packet server
|
pac.hive=Packet server
|
||||||
pac.curinetaddr=IPv4 address
|
pac.curinetaddr=IPv4 address
|
||||||
patheditor.managed=provided (/usr/bin/..)
|
patheditor.managed=provided (/usr/bin/..)
|
||||||
patheditor.userspace=Userspace (/home/..)
|
patheditor.userspace=custom (/home/..)
|
||||||
passengerpython=passenger python binary
|
passengerpython=passenger python binary
|
||||||
passengernodejs=passenger node binary
|
passengernodejs=passenger node binary
|
||||||
passengerruby=passenger ruby binary
|
passengerruby=passenger ruby binary
|
||||||
|
@ -48,10 +48,10 @@ domainoption.backupmxforexternalmx=Backup-MX f
|
|||||||
domainoption.letsencrypt=Let's Encrypt-Zertifikat
|
domainoption.letsencrypt=Let's Encrypt-Zertifikat
|
||||||
domainoption.autoconfig=E-Mail Auto-Konfiguration
|
domainoption.autoconfig=E-Mail Auto-Konfiguration
|
||||||
domainoption.dkim=Domain Key - DKIM
|
domainoption.dkim=Domain Key - DKIM
|
||||||
domainoption.cgi=CGI-Funktion aktiv
|
domainoption.cgi=CGI-Funktion
|
||||||
domainoption.fastcgi=FastCGI-Funktion aktiv
|
domainoption.fastcgi=FastCGI-Funktion
|
||||||
domainoption.passenger=Passenger-Modul aktiv
|
domainoption.passenger=Passenger-Modul
|
||||||
domainoption.passengerfriendlyerrorpages=Passenger Debug-Modus aktiv
|
domainoption.passengerfriendlyerrorpages=Passenger Debug-Modus
|
||||||
mysqluser.name=MySQL-Benutzer
|
mysqluser.name=MySQL-Benutzer
|
||||||
mysqluser.instance=Datenbanksystem
|
mysqluser.instance=Datenbanksystem
|
||||||
mysqluser.pac=Web-Paket
|
mysqluser.pac=Web-Paket
|
||||||
@ -189,7 +189,7 @@ pac.basepac=Paket-Typ
|
|||||||
pac.hive=Server/Hive
|
pac.hive=Server/Hive
|
||||||
pac.curinetaddr=Netzwerk-Adresse (IPv4)
|
pac.curinetaddr=Netzwerk-Adresse (IPv4)
|
||||||
patheditor.managed=vorinstalliert (/usr/bin/..)
|
patheditor.managed=vorinstalliert (/usr/bin/..)
|
||||||
patheditor.userspace=Userspace (/home/..)
|
patheditor.userspace=individuell (/home/..)
|
||||||
passengerpython=Passenger Python-Interpreter
|
passengerpython=Passenger Python-Interpreter
|
||||||
passengernodejs=Passenger Node-Interpreter
|
passengernodejs=Passenger Node-Interpreter
|
||||||
passengerruby=Passenger Ruby-Interpreter
|
passengerruby=Passenger Ruby-Interpreter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user