itamae-plugin-recipe-bedrock_server 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4d11d81e37964b2e95787f8539e478fe8387a863cae7d6be116002486d090ac5
4
+ data.tar.gz: acb7821c226813e46620b970ac5b2154d641a8df263b0774fcf4025736361d3b
5
+ SHA512:
6
+ metadata.gz: 28e9a3caca5826fd65ff418b7cd1d714fd50efd3c95b60c39ed9ec40bd5513a49438331a7ef9a81d0d241110bbf26322d857242aec5b9f7a5b4481aa9f3bd6db
7
+ data.tar.gz: beb581ebd45cccbabffd9f61302e6a467c51c7d67c9a0a2a49aec055b01def371bee7835233feaed52d76053bfb8301e52a1477d4ffa405391b9becff5247fd4
@@ -0,0 +1,71 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ types:
9
+ - opened
10
+ - synchronize
11
+ - reopened
12
+ schedule:
13
+ - cron: "0 10 * * 5"
14
+
15
+ env:
16
+ CI: "true"
17
+
18
+ jobs:
19
+ test:
20
+ runs-on: ubuntu-latest
21
+
22
+ strategy:
23
+ fail-fast: false
24
+
25
+ matrix:
26
+ ruby:
27
+ - 2.6
28
+ - 3.0
29
+ image:
30
+ - ubuntu:18.04
31
+ - ubuntu:latest
32
+
33
+ steps:
34
+ - uses: actions/checkout@v2
35
+
36
+ - uses: eregon/use-ruby-action@v1
37
+ with:
38
+ ruby-version: ${{ matrix.ruby }}
39
+
40
+ - name: Cache vendor/bundle
41
+ uses: actions/cache@v1
42
+ id: cache_gem
43
+ with:
44
+ path: vendor/bundle
45
+ key: v1-gem-${{ runner.os }}-${{ matrix.ruby }}-${{ github.sha }}
46
+ restore-keys: |
47
+ v1-gem-${{ runner.os }}-${{ matrix.ruby }}-
48
+ - name: bundle update
49
+ run: |
50
+ set -xe
51
+ bundle config path vendor/bundle
52
+ bundle update --jobs $(nproc) --retry 3
53
+ - name: Start container
54
+ run: |
55
+ set -xe
56
+ docker run --name tmp-ubuntu $IMAGE bash -c "apt-get update && apt-get install -y systemd-sysv"
57
+ docker commit tmp-ubuntu ubuntu-with-systemd
58
+ docker run --privileged -d --name container-with-service ubuntu-with-systemd /sbin/init
59
+ env:
60
+ IMAGE: ${{ matrix.image }}
61
+
62
+ - name: Run Itamae
63
+ run: |
64
+ set -xe
65
+ bundle exec itamae docker --node-yaml=recipes/node.yml recipes/install.rb --container=container-with-service --tag itamae-plugin:latest
66
+ - name: Run Serverspec
67
+ run: |
68
+ set -xe
69
+ bundle exec rspec
70
+ env:
71
+ DOCKER_CONTAINER: container-with-service
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ /Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in itamae-plugin-recipe-bedrock_server.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 kyohah
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,79 @@
1
+ # Itamae::Plugin::Recipe::BedrockServer
2
+
3
+ Itamae plugin to install [Minecraft](https://www.minecraft.net/) with init scripts
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/itamae-plugin-recipe-bedrock_server.svg)](https://badge.fury.io/rb/itamae-plugin-recipe-bedrock_server)
6
+ ![test](https://github.com/kyohah/itamae-plugin-recipe-bedrock_server/workflows/test/badge.svg)
7
+
8
+ ## Supported
9
+ * Ubuntu 18 or later [^1]
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'itamae-plugin-recipe-bedrock_server'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install itamae-plugin-recipe-bedrock_server
26
+
27
+ ## Usage
28
+
29
+ ### Recipe
30
+
31
+ Install bedrock_server executable file and init scritps (systemd or init.d)
32
+
33
+ ```ruby
34
+ # recipe.rb
35
+ include_recipe "bedrock_server"
36
+ ```
37
+
38
+ Or `include_recipe` just what you need manually:
39
+
40
+ ```ruby
41
+ include_recipe "bedrock_server::setup"
42
+ include_recipe "bedrock_server::install"
43
+ include_recipe "bedrock_server::service"
44
+ ```
45
+
46
+ ### Node
47
+
48
+ ```yml
49
+ # node.yml
50
+ bedrock_server:
51
+ # path to downloaded zip file (default: "/opt")
52
+ app_dir: "/opt"
53
+
54
+ # start environment (default: ".")
55
+ ld_library_path: "."
56
+
57
+ # bedrock_server service actions when after install (default: enable, start)
58
+ service_actions:
59
+ - enable
60
+ - start
61
+ # - disable
62
+ # - stop
63
+ ```
64
+
65
+ ## Development
66
+
67
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
68
+
69
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
70
+
71
+ ## Contributing
72
+
73
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kyohah/itamae-plugin-recipe-bedrock_server.
74
+
75
+ ## License
76
+
77
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
78
+
79
+ [^1]: bedrock-server-1.16.201.02/bedrock_server_how_to.html
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "itamae/plugin/recipe/bedrock_server"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/itamae/plugin/recipe/bedrock_server/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "itamae-plugin-recipe-bedrock_server"
7
+ spec.version = Itamae::Plugin::Recipe::BedrockServer::VERSION
8
+ spec.authors = ["kyohah"]
9
+ spec.email = ["3257272+kyohah@users.noreply.github.com"]
10
+
11
+ spec.summary = "Itamae plugin to install Minecraft with init scripts."
12
+ spec.description = "Itamae plugin to install Minecraft with init scripts."
13
+ spec.homepage = "https://github.com/kyohah/itamae-plugin-recipe-bedrock_server"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_dependency "itamae"
28
+
29
+ spec.add_development_dependency "docker-api"
30
+ spec.add_development_dependency "serverspec"
31
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "bedrock_server/version"
4
+
5
+ module Itamae
6
+ module Plugin
7
+ module Recipe
8
+ module BedrockServer
9
+ class Error < StandardError; end
10
+ # Your code goes here...
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ include_recipe "bedrock_server::setup"
2
+ include_recipe "bedrock_server::install"
3
+ include_recipe "bedrock_server::service"
@@ -0,0 +1,12 @@
1
+ require 'open-uri'
2
+
3
+ package "unzip"
4
+ package "curl"
5
+
6
+ bedrock_server_url = node[:bedrock_server][:url] || URI.open("https://minecraft.net/en-us/download/server/bedrock/").read.match(/https:\/\/minecraft\.azureedge\.net\/bin-linux\/bedrock-server-[.0-9]*\.zip/).to_s
7
+
8
+ http_request "bedrock-server.zip" do
9
+ url bedrock_server_url
10
+ end
11
+
12
+ execute "unzip -o bedrock-server.zip -d #{node[:bedrock_server][:app_dir]}/bedrock-server"
@@ -0,0 +1,28 @@
1
+ environment_content =
2
+ <<-EOS
3
+ LD_LIBRARY_PATH=#{node[:bedrock_server][:ld_library_path]}
4
+ EOS
5
+
6
+ environment_file = "/etc/default/bedrock_server"
7
+
8
+ file environment_file do
9
+ mode "644"
10
+ content environment_content
11
+ notifies :restart, "service[bedrock_server]"
12
+ end
13
+
14
+ template "/etc/systemd/system/bedrock_server.service" do
15
+ mode "644"
16
+ variables(
17
+ environment_file: environment_file,
18
+ app_dir: "#{node[:bedrock_server][:app_dir]}",
19
+ )
20
+
21
+ notifies :restart, "service[bedrock_server]"
22
+ end
23
+
24
+ directory "/etc/bedrock_server.d"
25
+
26
+ service "bedrock_server" do
27
+ action node[:bedrock_server][:service_actions]
28
+ end
@@ -0,0 +1,19 @@
1
+ # Check required node values
2
+ # node.validate! do
3
+ # {
4
+ # bedrock_server: {
5
+ # version: string,
6
+ # },
7
+ # }
8
+ # end
9
+
10
+ # Set default node values
11
+ node.reverse_merge!(
12
+ bedrock_server: {
13
+ app_dir: "/opt",
14
+ ld_library_path: ".",
15
+ service_actions: [:enable, :start]
16
+ },
17
+ )
18
+
19
+ node[:bedrock_server][:service_actions] ||= []
@@ -0,0 +1,13 @@
1
+ [Unit]
2
+ Description=Minecraft Bedrock Server
3
+ After=network.target
4
+
5
+ [Service]
6
+ EnvironmentFile=-<%= @environment_file %>
7
+ Type=simple
8
+ WorkingDirectory=<%= @app_dir %>/bedrock-server
9
+ ExecStart=<%= @app_dir %>/bedrock-server/bedrock_server
10
+ Restart=on-failure
11
+
12
+ [Install]
13
+ WantedBy=multi-user.target
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Itamae
4
+ module Plugin
5
+ module Recipe
6
+ module BedrockServer
7
+ VERSION = "0.1.0"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+
2
+ execute "apt update"
3
+
4
+ directory "/tmp/itamae_tmp"
5
+
6
+ include_recipe 'bedrock_server'
@@ -0,0 +1,6 @@
1
+ bedrock_server:
2
+ app_dir: "/opt"
3
+ ld_library_path: "."
4
+ service_actions:
5
+ - enable
6
+ - start
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: itamae-plugin-recipe-bedrock_server
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - kyohah
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-01-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: itamae
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: docker-api
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: serverspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Itamae plugin to install Minecraft with init scripts.
56
+ email:
57
+ - 3257272+kyohah@users.noreply.github.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".github/workflows/test.yml"
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/setup
71
+ - itamae-plugin-recipe-bedrock_server.gemspec
72
+ - lib/itamae/plugin/recipe/bedrock_server.rb
73
+ - lib/itamae/plugin/recipe/bedrock_server/default.rb
74
+ - lib/itamae/plugin/recipe/bedrock_server/install.rb
75
+ - lib/itamae/plugin/recipe/bedrock_server/service.rb
76
+ - lib/itamae/plugin/recipe/bedrock_server/setup.rb
77
+ - lib/itamae/plugin/recipe/bedrock_server/templates/etc/systemd/system/bedrock_server.service.erb
78
+ - lib/itamae/plugin/recipe/bedrock_server/version.rb
79
+ - recipes/install.rb
80
+ - recipes/node.yml
81
+ homepage: https://github.com/kyohah/itamae-plugin-recipe-bedrock_server
82
+ licenses:
83
+ - MIT
84
+ metadata:
85
+ homepage_uri: https://github.com/kyohah/itamae-plugin-recipe-bedrock_server
86
+ source_code_uri: https://github.com/kyohah/itamae-plugin-recipe-bedrock_server
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 2.3.0
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubygems_version: 3.2.3
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: Itamae plugin to install Minecraft with init scripts.
106
+ test_files: []