Framework for Minecraft server

This commit is contained in:
Jamie Cameron
2012-11-27 20:54:54 -08:00
parent 139b4fb666
commit a73c9a5227
11 changed files with 102 additions and 2 deletions

View File

@@ -1,3 +1,3 @@
minecraft_dir=/usr/local/minecraft
java_cmd=java
init_script=minecraft
init_name=minecraft

View File

@@ -1,4 +1,4 @@
minecraft_dir=Base directory for Minecraft server,0
minecraft_jar=Full path to Minecraft JAR file,3,In the base directory
java_cmd=Full path to java command,0
init_script=Name of init script,0
init_name=Name of init script,0

BIN
minecraft/images/conf.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
minecraft/images/icon.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
minecraft/images/logs.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
minecraft/images/manual.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
minecraft/images/users.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

53
minecraft/index.cgi Normal file
View File

@@ -0,0 +1,53 @@
#!/usr/local/bin/perl
# Show icons for config editing, whitelist and ops
use strict;
use warnings;
require './minecraft-lib.pl';
our (%in, %text, %config, $module_name);
&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
my $err = &check_minecraft_server();
if ($err) {
&ui_print_endpage(&text('index_cerr', $err, "../config.cgi?$module_name"));
}
my @links = ( "edit_conf.cgi", "edit_users.cgi",
"view_logs.cgi", "edit_manual.gif" );
my @titles = ( $text{'conf_title'}, $text{'users_title'},
$text{'logs_title'}, $text{'manual_title'} );
my @icons = ( "images/conf.gif", "images/users.gif",
"images/logs.gif", "images/manual.gif" );
&icons_table(\@links, \@titles, \@icons);
print &ui_hr();
print &ui_buttons_start();
# Show start/stop/restart buttons
my $pid = &is_minecraft_server_running();
if ($pid) {
print &ui_buttons_row("restart.cgi", $text{'index_restart'},
$text{'index_restartdesc'});
print &ui_buttons_row("stop.cgi", $text{'index_stop'},
$text{'index_stopdesc'});
}
else {
print &ui_buttons_row("start.cgi", $text{'index_start'},
$text{'index_startdesc'});
}
# Show start at boot button
&foreign_require("init");
my $starting = &init::action_status($config{'init_name'});
print &ui_buttons_row("atboot.cgi",
$text{'index_atboot'},
$text{'index_atbootdesc'},
undef,
&ui_radio("boot", $starting == 2 ? 1 : 0,
[ [ 1, $text{'yes'} ], [ 0, $text{'no'} ] ]));
print &ui_buttons_end();
&ui_print_footer("/", $text{'index_return'});

23
minecraft/lang/en Normal file
View File

@@ -0,0 +1,23 @@
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_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
index_startdesc=Click this button to start the Minecraft server, so that clients can connect.
index_restart=Restart Minecraft Server
index_restartdesc=Click this button to apply the current configuration by restarting the Minecraft server.
index_atboot=Start at boot?
index_atbootdesc=Change this option to control whether the Minecraft server is started at boot time or not. If it is not currently started at boot and Yes is chosen, a new init script will be created.
index_return=module index
check_edir=The base directory $1 does not exist
check_ejar=The server JAR file $1 does not exist
check_ejava=The Java executable $1 was not found
conf_title=Server Configuration
users_title=Users and Operators
logs_title=View Log File
manual_title=Edit Configuration File

View File

@@ -9,4 +9,25 @@ our ($module_root_directory, %text, %gconfig, $root_directory, %config,
$module_name, $remote_user, $base_remote_user, $gpgpath,
$module_config_directory, @lang_order_list, @root_directories);
# check_minecraft_server()
# Returns an error message if the Minecraft server is not installed
sub check_minecraft_server
{
-d $config{'minecraft_dir'} ||
return &text('check_edir', $config{'minecraft_dir'});
my $jar = $config{'minecraft_jar'} ||
$config{'minecraft_dir'}."/"."minecraft_server.jar";
-r $jar ||
return &text('check_ejar', $jar);
&has_command($config{'java_cmd'}) ||
return &text('check_ejava', $config{'java_cmd'});
return undef;
}
# is_minecraft_server_running()
# If the minecraft server is running, return the PID
sub is_minecraft_server_running
{
}
1;

3
minecraft/module.info Normal file
View File

@@ -0,0 +1,3 @@
desc=Minecraft Server
depends=init
category=servers