diff --git a/minecraft/config b/minecraft/config index 909b82dce..4b2dd125b 100644 --- a/minecraft/config +++ b/minecraft/config @@ -1,3 +1,3 @@ minecraft_dir=/usr/local/minecraft java_cmd=java -init_script=minecraft +init_name=minecraft diff --git a/minecraft/config.info b/minecraft/config.info index 2928fe373..0961f8ccb 100644 --- a/minecraft/config.info +++ b/minecraft/config.info @@ -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 diff --git a/minecraft/images/conf.gif b/minecraft/images/conf.gif new file mode 100755 index 000000000..551799d00 Binary files /dev/null and b/minecraft/images/conf.gif differ diff --git a/minecraft/images/icon.gif b/minecraft/images/icon.gif new file mode 100755 index 000000000..551799d00 Binary files /dev/null and b/minecraft/images/icon.gif differ diff --git a/minecraft/images/logs.gif b/minecraft/images/logs.gif new file mode 100755 index 000000000..af09ea1d9 Binary files /dev/null and b/minecraft/images/logs.gif differ diff --git a/minecraft/images/manual.gif b/minecraft/images/manual.gif new file mode 100755 index 000000000..5d7fcec85 Binary files /dev/null and b/minecraft/images/manual.gif differ diff --git a/minecraft/images/users.gif b/minecraft/images/users.gif new file mode 100755 index 000000000..dba829d41 Binary files /dev/null and b/minecraft/images/users.gif differ diff --git a/minecraft/index.cgi b/minecraft/index.cgi new file mode 100644 index 000000000..a063c687a --- /dev/null +++ b/minecraft/index.cgi @@ -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'}); + diff --git a/minecraft/lang/en b/minecraft/lang/en new file mode 100644 index 000000000..48620f46e --- /dev/null +++ b/minecraft/lang/en @@ -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 module configuration. +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 diff --git a/minecraft/minecraft-lib.pl b/minecraft/minecraft-lib.pl index 5fe383e7f..24d7f6274 100644 --- a/minecraft/minecraft-lib.pl +++ b/minecraft/minecraft-lib.pl @@ -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; diff --git a/minecraft/module.info b/minecraft/module.info new file mode 100644 index 000000000..e53b4b832 --- /dev/null +++ b/minecraft/module.info @@ -0,0 +1,3 @@ +desc=Minecraft Server +depends=init +category=servers