Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ServerInstaller.java #127

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Ayush-Thakur-geek
Copy link

Added a warning message for installation via sudo.

Added a warning message for installation via sudo.
@sfPlayer1
Copy link
Contributor

What "issues with the application" do you mean? There's obviously some problems if the user then runs the server as non-root due to file permissions, but that's to be expected.

@Ayush-Thakur-geek
Copy link
Author

I just worked on the issue #112

@modmuss50
Copy link
Member

Yeah, this is something that we should warn about.

Copy link
Member

@modmuss50 modmuss50 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done for the client install only as thats where most of the issues come from. I would take a look at how the client installer shows a warning when the vanilla launcher is open.

It may also be a nice idea to show the same warning when running as an admin on windows?

I would also recommended building your PR to make sure that it passes the checkstyle rules. 👍 Let me know if you have any questions.

Comment on lines 279 to 282
public static boolean isSudo() {
String user = System.getProperty("user.name");
return "root".equals(user);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is fine, maybe just limit it to macos and Linux?

@@ -115,7 +142,8 @@ public static void install(Path dir, LoaderVersion loaderVersion, String gameVer
Path libraryFile = libsDir.resolve(library.getPath());

if (library.inputPath == null) {
progress.updateProgress(new MessageFormat(Utils.BUNDLE.getString("progress.download.library.entry")).format(new Object[]{library.name}));
progress.updateProgress(new MessageFormat(Utils.BUNDLE.getString("progress.download.library.entry"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont change lines you havent changed.

Comment on lines 116 to 119
libraries.add(new Library(String.format("net.fabricmc:fabric-loader:%s", loaderVersion.name)
, null, loaderVersion.path));
libraries.add(new Library(String.format("net.fabricmc:intermediary:%s", gameVersion)
, "https://maven.fabricmc.net/", null));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont change this

Comment on lines 106 to 108
Json json = FabricService.queryMetaJson(String.format("v2/versions/loader/%s/%s/server/json"
, gameVersion
, loaderVersion.name));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont change this

Comment on lines 92 to 93
progress.updateProgress(new MessageFormat(Utils.BUNDLE.getString("progress.installing.server"))
.format(new Object[]{String.format("%s(%s)", loaderVersion.name, gameVersion)}));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont change this

Comment on lines 65 to 68
public static void install(Path dir
, LoaderVersion loaderVersion
, String gameVersion
, InstallerProgress progress) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very weird formatting, why change it? Please make sure it passes the checkstyle checks.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, actually while I code I have a habit of wanting everything in front of my eyes and hate to scroll sideways. In the case of previous formatting, I had to scroll sideways, so I changed it.

, String gameVersion
, InstallerProgress progress) throws IOException {

Scanner sc = new Scanner(System.in);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this will basically break when installing via the GUI. It should show a warning message box. Take a look at the client one for when the launcher is already open.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, I will improve the code according to what is needed.

Comment on lines 74 to 75
System.out.println("WARNING: Running this installer with sudo might cause issues with the application.");
System.out.print("Do you really want to continue? (y/n): ");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be translatable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please describe it a bit in detail.

Comment on lines 82 to 84
} else {
System.out.println("Invalid Response!!");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just assume the user aborted it. This will be removed anyway as a Scanner isnt the right solution

Comment on lines 79 to 86
install(dir, loaderVersion, gameVersion, progress, launchJar);
} else if (RESPONSE_TO_OPTION.equalsIgnoreCase("n")){
throw new RuntimeException("Installation aborted by the user.");
} else {
System.out.println("Invalid Response!!");
}
} else {
install(dir, loaderVersion, gameVersion, progress, launchJar);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could clean this code up a lot to remove the 2 calls to install.

if (isSudo() && !proceedWithSudoInstall()) {
   return;
}

install(dir, loaderVersion, gameVersion, progress, launchJar);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants