From ace4187c64029175e1346c6508e8e584171d2b9d Mon Sep 17 00:00:00 2001 From: Chris Ridgers Date: Sun, 20 Sep 2015 13:43:40 +0100 Subject: [PATCH] New cask for minecraft-server I've created a new cask that pulls down the minecraft server jar and set's up a binary linking to it. Some potential changes for anyone reviewing it include testing for 64bit architecture as part of the binary and if present passing '-d64' to the java call as an argument'. Also, if there's a sane way to allow for the application to run in the background, that would be a nice default, along with the ability to pass options through to the java call. I've added in an extra line to the caveats. --- Casks/minecraft-server.rb | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Casks/minecraft-server.rb diff --git a/Casks/minecraft-server.rb b/Casks/minecraft-server.rb new file mode 100644 index 000000000000..061ed9c5839a --- /dev/null +++ b/Casks/minecraft-server.rb @@ -0,0 +1,37 @@ +cask :v1 => 'minecraft-server' do + version '1.8.8' + sha256 :no_check + + url 'https://s3.amazonaws.com/Minecraft.Download/versions/1.8.8/minecraft_server.1.8.8.jar' + name 'Minecraft Server' + homepage 'https://minecraft.net' + license :unknown # todo: change license and remove this comment; ':unknown' is a machine-generated placeholder + + container :type => :naked + + preflight do + FileUtils.touch "#{staged_path}/minecraft-server" + minecraft_server = File.open "#{staged_path}/minecraft-server", 'w' + minecraft_server.puts '#!/bin/bash' + minecraft_server.puts 'BASEDIR=$(dirname "$(readlink -n $0)")' + minecraft_server.puts 'cd $BASEDIR' + minecraft_server.puts 'java -Xmx1024M -Xms1024M -jar minecraft_server.1.8.8.jar nogui' + minecraft_server.close + end + + binary 'minecraft-server' + + postflight do + set_permissions "#{staged_path}/minecraft-server", '+x' + system 'minecraft-server' + + file_name = "#{staged_path}/EULA.txt" + contents = File.read(file_name).gsub(/false/, 'true') + File.open(file_name, 'w') {|file| file.puts contents } + end + + caveats do + puts 'To run this app, type "minecraft-server" in terminal.' + puts 'To configure the server take a look at the files staged at /opt/homebrew-cask/Caskroom/minecraft-server' + end +end