2020
2121package io .mcdocker .launcher .protocol ;
2222
23- import io .mcdocker .launcher .utils .OperatingSystem ;
2423import io .mcdocker .launcher .utils .http .HTTPUtils ;
2524
2625import java .io .BufferedReader ;
@@ -47,36 +46,30 @@ public CompletableFuture<Boolean> registerWindows(Consumer<String> status) {
4746 }
4847
4948 public CompletableFuture <Boolean > registerLinux () {
50- CompletableFuture <Boolean > future = new CompletableFuture <>();
51-
52- HTTPUtils .download ("https://raw.githubusercontent.com/MCDocker/Assets/main/linux.sh" , new File (installPath + "/linux.sh" ));
53-
54- File script = new File (installPath + "/linux.sh" );
55-
56- ProcessBuilder builder = new ProcessBuilder ("/bin/sh" , '"' + script .getAbsolutePath () + '"' );
57- System .out .println (builder .command ());
58- try {
59- Process process = builder .start ();
60-
61- System .out .println (process .info ().command ());
62-
63- StringBuilder output = new StringBuilder ();
64- BufferedReader reader = new BufferedReader (new InputStreamReader (process .getInputStream ()));
65- String line ;
66- while ((line = reader .readLine ()) != null ) {
67- System .out .println (line );
49+ return CompletableFuture .supplyAsync (() -> {
50+ HTTPUtils .download ("https://raw.githubusercontent.com/MCDocker/Assets/main/linux.sh" , new File (installPath + "/linux.sh" ));
51+
52+ File script = new File (installPath + "/linux.sh" );
53+
54+ ProcessBuilder builder = new ProcessBuilder ("/bin/sh" , '"' + script .getAbsolutePath () + '"' );
55+ System .out .println (builder .command ());
56+ try {
57+ Process process = builder .start ();
58+ System .out .println (process .info ().command ());
59+
60+ BufferedReader reader = new BufferedReader (new InputStreamReader (process .getInputStream ()));
61+ String line ;
62+ while ((line = reader .readLine ()) != null ) {
63+ System .out .println (line );
64+ }
65+
66+ System .out .println ("Exit code: " + process .onExit ().join ().exitValue ());
67+ return true ;
68+ } catch (IOException e ) {
69+ e .printStackTrace ();
70+ return false ;
6871 }
69-
70- process .onExit ().thenAccept (exitCode -> {
71- System .out .println ("Exit code: " + exitCode );
72- future .complete (true );
73- });
74- } catch (IOException e ) {
75- e .printStackTrace ();
76- future .completeExceptionally (e );
77- }
78-
79- return future ;
72+ });
8073 }
8174
8275}
0 commit comments