Page to prompt to download initial Jar file

This commit is contained in:
Jamie Cameron
2013-01-02 18:46:33 -08:00
parent 5f6d156231
commit 1cbe43e60f
3 changed files with 42 additions and 4 deletions

View File

@@ -4,12 +4,20 @@
use strict;
use warnings;
require './minecraft-lib.pl';
our (%text, %config);
our (%text, %config, %in);
our $server_jar_url;
our $progress_callback_url;
&ReadParse();
&ui_print_unbuffered_header(undef, $text{'download_title'}, "");
if ($in{'new'} && -d $config{'minecraft_dir'}) {
# Create install dir
print &text('download_mkdir', $config{'minecraft_dir'}),"<p>\n";
&make_dir($config{'minecraft_dir'}, 0755) ||
&error($text{'download_emkdir'});
}
# Download to temp file
my $temp = &transname();
my ($host, $port, $page, $ssl) = &parse_http_url($server_jar_url);
@@ -29,7 +37,12 @@ else {
&copy_source_dest($temp, $jar);
print &text('download_done', $jar),"<p>\n";
if (&is_minecraft_server_running()) {
if ($in{'new'}) {
print $text{'download_start'},"<p>\n";
print &ui_form_start("start.cgi");
print &ui_form_end([ [ undef, $text{'index_start'} ] ]);
}
elsif (&is_minecraft_server_running()) {
print $text{'download_restart'},"<p>\n";
print &ui_form_start("restart.cgi");
print &ui_form_end([ [ undef, $text{'index_restart'} ] ]);

View File

@@ -10,8 +10,25 @@ our (%in, %text, %config, $module_name);
&help_search_link("minecraft", "google"));
my $err = &check_minecraft_server();
if ($err) {
&ui_print_endpage(&text('index_cerr', $err, "../config.cgi?$module_name"));
if ($err && &is_minecraft_port_in_use()) {
# Not found, but server appears to be running
&ui_print_endpage(&text('index_cerr', $err,
"../config.cgi?$module_name"));
}
elsif ($err) {
# Not found, and not running. Offer to setup.
print &text('index_cerr2', "../config.cgi?$module_name"),"<p>\n";
if (&has_command($config{'java_cmd'})) {
print &ui_form_start("download.cgi");
print &ui_hidden("new", 1);
print &text('index_offer', $config{'minecraft_dir'}),"<p>\n";
print &ui_form_end([ [ undef, $text{'index_install'} ] ]);
}
else {
print &text('index_nojava', $config{'java_cmd'}),"<p>\n";
}
return;
}
my @links = ( "edit_conf.cgi", "edit_users.cgi",

View File

@@ -1,5 +1,9 @@
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_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='$2'>module configuration</a> to use the correct paths.
index_nojava=Also, the Java command at <tt>$1</tt> needed to run Minecraft was not found.
index_offer=Alternatively, Webmin can automatically download and install the Minecraft server for you, into the directory <tt>$1</tt>.
index_install=Download and Install
index_stop=Stop Minecraft Server
index_stopdesc=Click this button to stop the running Minecraft server. All clients will be immediately disconnected.
index_start=Start Minecraft Server
@@ -234,7 +238,11 @@ manual_econf=Nothing entered!
download_title=Download Minecraft Server
download_already=Your system is already running the latest version of the Minecraft server.
download_done=Your system has been upgraded to the latest version of the Minecraft server.
download_done2=The latest version of the Minecraft server has been downloaded to your system.
download_restart=The new version will only be used when the server is restarted.
download_start=The server must be started before it can be used.
download_mkdir=Creating base directory $1 ..
download_emkdir=Directory creation failed!
log_conf=Changed server configuration
log_stop=Stopped Minecraft server