Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

46
LINES

< > BotCompany Repo | #1009062 // Linux: Start JavaX Super User VM v2 [prompts for password]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (10095L/65K).

!7

sbool preserveEnvironment = true;
sS javaxOptions = "-verbose -dontcompilethroughport5000";

p {
  if (hasSuperUserVM()) {
    print("Super User VM already running!");
    ret;
  }
  
  doIt();
  cleanKill();
}

svoid doIt ctex {
  if (!isOnPATH("x-terminal-emulator"))
    fail("x-terminal-emulator not on PATH. Your Linux is weird");
    
  //File outFile = File.createTempFile("suvm_", ".out");
  File outFile = newFile("/tmp/" + now() + ".log");
  S msg = "Starting JavaX Super User VM...";
  
  // the actual command executed as root
  
  S cmd3 = "whoami; nohup "
    + relativeCmdToAbsoluteUsingPath(_javaCommand())
    + " " + javaxDefaultVMArgs()
    + " -jar " + pathToJavaxJar()
    + " " + appendSpaceIfNempty(javaxOptions)
    + psI(#1009053)
    + " " + bashQuote(userHome())
    + " >" + bashQuote(outFile) + " 2>&1 &";
    
  print(+cmd3);
  
  S cmd2 = "echo " + bashQuote(msg) + "; echo; sudo "
    + (preserveEnvironment ? "-E " : "") + "/bin/bash -c " + bashQuote(cmd3) + "; sleep 2";
  print(+cmd2);
  S cmd = "/bin/bash -c " + bashQuote(cmd2);
  print(+cmd);
  
  nohup("x-terminal-emulator -e " + bashQuote(cmd));
  
  print("\nWatch " + outFile + " to check progress");
}

Author comment

Began life as a copy of #1009051

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, snaazhdonpnp, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1009062
Snippet name: Linux: Start JavaX Super User VM v2 [prompts for password]
Eternal ID of this version: #1009062/28
Text MD5: 40a4d785801b5e59ee974a403ef8bdd0
Transpilation MD5: b98a1cc3232be4c986e18f0de0aef029
Author: stefan
Category: javax
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-20 17:22:54
Source code size: 1244 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 731 / 1968
Version history: 27 change(s)
Referenced in: #1009053 - JavaX Super User VM - start using #1009062 on Linux
#1009065 - startSuperUserVM