Bugfixes and custom port support

This commit is contained in:
Jamie Cameron
2015-02-02 19:50:27 -08:00
parent 6e873a172a
commit a71bf42232
4 changed files with 9 additions and 5 deletions

View File

@@ -4,3 +4,4 @@ java_cmd=Full path to java command,0
unix_user=Run Minecraft server as user,5
init_name=Name of init script,0
history_size=Command history size,0
port=Minecraft server port number,3,Default (25565)

View File

@@ -11,7 +11,7 @@ our $progress_callback_url;
# Validate inputs
if ($in{'new'}) {
$in{'dir'} =~ /^\/\S+$/ || &error($text{'download_edir'});
getpwnam($in{'user'}) || &error($text{'download_euser'});
defined(getpwnam($in{'user'})) || &error($text{'download_euser'});
}
&ui_print_unbuffered_header(undef, $text{'download_title'}, "");

View File

@@ -1,5 +1,5 @@
index_title=Minecraft Server
index_cerr=An error was detected with your Minecraft server : $1. You may need to adjust the <a href='$2'>module configuration</a>.
index_cerr=An error was detected with your Minecraft server : $1. You may need to adjust the <a href='$2'>module configuration</a>. Automatic installation is not possible as the server appears to be already running.
index_cerr2=The Minecraft server does not appear to be installed on your system. If it is already running, you will need to adjust the <a href='$1'>module configuration</a> to use the correct paths.
index_rooterr=The Minecraft root directory is set on the <a href='$1'>module configuration</a> page to <tt>$2</tt>, but this is the same as the Webmin module directory!
index_nojava=Also, the Java command <tt>$1</tt> needed to run Minecraft was not found.

View File

@@ -38,11 +38,14 @@ return undef;
sub is_minecraft_port_in_use
{
&foreign_require("proc");
my ($pid) = &proc::find_socket_processes("tcp:25565");
my $port = $config{'port'} || 25565;
my ($pid) = &proc::find_socket_processes("tcp:".$port);
return $pid if ($pid);
my @procs = &proc::list_processes();
my $jar = $config{'minecraft_jar'} ||
$config{'minecraft_dir'}."/"."minecraft_server.jar";
foreach my $p (@procs) {
if ($p->{'args'} =~ /^java.*minecraft_server.jar/) {
if ($p->{'args'} =~ /^java.*\Q$jar\E/) {
return $p->{'pid'};
}
}
@@ -60,7 +63,7 @@ my $jar = $config{'minecraft_jar'} ||
my $shortjar = $jar;
$shortjar =~ s/^.*\///;
foreach my $p (@procs) {
if ($p->{'args'} =~ /^\S*\Q$config{'java_cmd'}\E.*(\Q$jar\E|\Q$shortjar\E)/) {
if ($p->{'args'} =~ /^\S*\Q$config{'java_cmd'}\E.*\Q$jar\E/) {
return $p->{'pid'};
}
}