pleaserun 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 078f5cb3064f6af68bcba84c9f3c8e2abe1ef5b9
4
- data.tar.gz: c177ec491cc431d1ee25c871011134e23dab6b03
3
+ metadata.gz: 3ee1d62691f6064b630454f2f65776ae4fc03292
4
+ data.tar.gz: b9e3a4a126870684145ad4ca60e0e773987bc434
5
5
  SHA512:
6
- metadata.gz: b8ca3e5ddffab1005cd0cdac1868900f4a2b937d56278312f5cfe15f0bd5db2ed102051a040b0b3b39dcbab213adaf3686f30eb69ec9272ad9f0e7cda6077ce1
7
- data.tar.gz: b8f05cf1372f519fe586bfd72ab3d4e2c543c3cf391329ad19cf96954becbe056d2e107291c6f6e9aa0b37139be36d84972361125de521bbff6ec06f3d95ab1d
6
+ metadata.gz: ab49602841e860eda3ff79c3c9f2231765667df1606bdd371f490a8beade5b1f07350e21c7ed70dcf300283df336d624f802843a1b43c88a72eee7866b41a6a1
7
+ data.tar.gz: 7a2c5fe40bbcc62f791c8c9a1f4e34dfc9a10abbe7afaa3e823abb0d122146a1b9593a8e68c83699c91b91f7c09da077dc0d11e79f58c006fc498b9fd8445e17
data/CHANGELOG.asciidoc CHANGED
@@ -1,5 +1,16 @@
1
1
  = Pleaserun Changes and Releases
2
2
 
3
+ == 0.0.13 (April 30, 2015)
4
+ * Now supports MRI 1.9.3 (Vincent Janelle)
5
+ * cli: New flag --install-prefix. This lets you tell pleaserun what directory to write things.
6
+ * cli: New flag --[no-]install-actions. If enabled, will run any required installation actions in order to signal the local system to load your newly created service.
7
+ * upstart: now only generates the .conf file, not the init script,
8
+ since it's not needed.
9
+ * sysv: Add ulimit support
10
+ * detection: Amazon Linux is now detected and, because it is based on RHEL6, defaults to Upstart 0.6.5 (Bob Miller, #68)
11
+ * misc: The ohai gem is now optional. Ohai is incompatible with JRuby, so I don't want to require it by default. The ohai gem will still be used, if present, during platform detection.
12
+ * cli: New flag --sysv-log-path. This lets you set the path for the sysv platform to log its output.
13
+
3
14
  == 0.0.4 (March 5, 2014)
4
15
  * cli: Autodetect OSX and use launchd
5
16
 
data/Gemfile CHANGED
@@ -7,4 +7,6 @@ group :development do
7
7
  gem "guard-rspec"
8
8
  gem "net-ssh"
9
9
  gem "peach"
10
+ gem "flores"
11
+ gem "ohai"
10
12
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pleaserun (0.0.10)
4
+ pleaserun (0.0.12)
5
5
  cabin (> 0)
6
6
  clamp
7
7
  insist
@@ -19,6 +19,12 @@ GEM
19
19
  diff-lcs (1.2.5)
20
20
  ffi (1.9.6)
21
21
  ffi (1.9.6-java)
22
+ ffi-yajl (2.1.0)
23
+ libyajl2 (~> 1.2)
24
+ ffi-yajl (2.1.0-java)
25
+ ffi (~> 1.5)
26
+ libyajl2 (~> 1.2)
27
+ flores (0.0.3)
22
28
  formatador (0.2.5)
23
29
  guard (2.12.4)
24
30
  formatador (>= 0.2.4)
@@ -37,18 +43,37 @@ GEM
37
43
  hitimes (1.2.2)
38
44
  hitimes (1.2.2-java)
39
45
  insist (1.0.0)
46
+ ipaddress (0.8.0)
47
+ libyajl2 (1.2.0)
40
48
  listen (2.8.5)
41
49
  celluloid (>= 0.15.2)
42
50
  rb-fsevent (>= 0.9.3)
43
51
  rb-inotify (>= 0.9)
44
52
  lumberjack (1.0.9)
45
53
  method_source (0.8.2)
54
+ mime-types (2.5)
55
+ mixlib-cli (1.5.0)
56
+ mixlib-config (2.1.0)
57
+ mixlib-log (1.6.0)
58
+ mixlib-shellout (2.0.1)
46
59
  mustache (0.99.8)
47
60
  nenv (0.2.0)
48
61
  net-ssh (2.9.2)
49
62
  notiffany (0.0.6)
50
63
  nenv (~> 0.1)
51
64
  shellany (~> 0.0)
65
+ ohai (8.3.0)
66
+ ffi (~> 1.9)
67
+ ffi-yajl (>= 1.1, < 3.0)
68
+ ipaddress
69
+ mime-types (~> 2.0)
70
+ mixlib-cli
71
+ mixlib-config (~> 2.0)
72
+ mixlib-log
73
+ mixlib-shellout (~> 2.0)
74
+ rake (~> 10.1)
75
+ systemu (~> 2.6.4)
76
+ wmi-lite (~> 1.0)
52
77
  peach (0.5.1)
53
78
  pry (0.10.1)
54
79
  coderay (~> 1.1.0)
@@ -59,6 +84,7 @@ GEM
59
84
  method_source (~> 0.8.1)
60
85
  slop (~> 3.4)
61
86
  spoon (~> 0.0)
87
+ rake (10.4.2)
62
88
  rb-fsevent (0.9.4)
63
89
  rb-inotify (0.9.5)
64
90
  ffi (>= 0.5.0)
@@ -79,18 +105,22 @@ GEM
79
105
  spoon (0.0.4)
80
106
  ffi
81
107
  stud (0.0.19)
108
+ systemu (2.6.5)
82
109
  thor (0.19.1)
83
110
  timers (4.0.1)
84
111
  hitimes
112
+ wmi-lite (1.0.0)
85
113
 
86
114
  PLATFORMS
87
115
  java
88
116
  ruby
89
117
 
90
118
  DEPENDENCIES
119
+ flores
91
120
  guard
92
121
  guard-rspec
93
122
  net-ssh
123
+ ohai
94
124
  peach
95
125
  pleaserun!
96
126
  rspec (~> 3.0.0)
@@ -35,6 +35,13 @@ module PleaseRun::Configurable
35
35
  end
36
36
  end # def self.included
37
37
 
38
+ def validate
39
+ # validate the value of each attribute
40
+ self.class.attributes.each do |attribute|
41
+ attribute.validate(send(attribute.name))
42
+ end
43
+ end
44
+
38
45
  def configurable_setup
39
46
  @attributes = {}
40
47
  self.class.ancestors.each do |ancestor|
@@ -1,2 +1,3 @@
1
1
  PleaseRun = Module.new
2
2
  PleaseRun::Platform = Module.new
3
+ PleaseRun::User = Module.new
@@ -0,0 +1,65 @@
1
+ require "pleaserun/namespace"
2
+
3
+ class PleaseRun::User::Base
4
+ include PleaseRun::Configurable
5
+ include PleaseRun::MustacheMethods
6
+
7
+ InvalidTemplate = Class.new(StandardError)
8
+
9
+ STRING = proc do
10
+ validate do |v|
11
+ insist { v }.is_a?(String)
12
+ end
13
+ end
14
+
15
+ STRING_OR_NIL = proc do
16
+ validate do |v|
17
+ begin
18
+ insist { v }.is_a?(String)
19
+ rescue Insist::Failure
20
+ begin
21
+ insist { v }.nil?
22
+ rescue Insist::Failure
23
+ raise Insist::Failure, "Expected #{v} to be a String or nil value."
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ attribute :name, "The user name", &STRING
30
+ attribute :platform, "The platform name", &STRING
31
+ attribute :version, "The platform version", &STRING_OR_NIL
32
+
33
+ def render_installer
34
+ render_template("installer.sh")
35
+ end
36
+
37
+ def render_remover
38
+ render_template("remover.sh")
39
+ end
40
+
41
+ # Get the template path for this platform.
42
+ def template_path
43
+ return File.expand_path(File.join(File.dirname(__FILE__), "../../../templates/user/", platform))
44
+ end # def template_path
45
+
46
+ def render_template(name)
47
+ possibilities = [
48
+ File.join(template_path, "default", name),
49
+ File.join(template_path, name)
50
+ ]
51
+ possibilities.unshift(File.join(template_path, version, name)) if version
52
+
53
+ possibilities.each do |path|
54
+ next unless File.readable?(path) && File.file?(path)
55
+ return render(File.read(path))
56
+ end
57
+
58
+ raise InvalidTemplate, "Could not find template file for '#{name}'. Tried all of these: #{possibilities.inspect}"
59
+ end # def render_template
60
+
61
+ # Render a text input through Mustache based on this object.
62
+ def render(text)
63
+ return Mustache.render(text, self)
64
+ end # def render
65
+ end # class PleaseRun::User
data/pleaserun.gemspec CHANGED
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |spec|
2
- files = `git ls-files`.split("\n")
2
+ files = File.read(__FILE__)[/^__END__$.*/m].split("\n")[1..-1]
3
3
 
4
4
  spec.name = "pleaserun"
5
- spec.version = "0.0.12"
5
+ spec.version = "0.0.13"
6
6
  spec.summary = "pleaserun"
7
7
  spec.description = "pleaserun"
8
8
  spec.license = "Apache 2.0"
@@ -23,3 +23,59 @@ Gem::Specification.new do |spec|
23
23
  spec.email = ["jls@semicomplete.com"]
24
24
  spec.homepage = "https://github.com/jordansissel/pleaserun"
25
25
  end
26
+
27
+ # Files list, populate it with `git ls-files | grep -v gitignore`
28
+ __END__
29
+ .rubocop.yml
30
+ CHANGELOG.asciidoc
31
+ Gemfile
32
+ Gemfile.lock
33
+ Guardfile
34
+ LICENSE
35
+ Makefile
36
+ README.md
37
+ bin/pleaserun
38
+ examples/runit.rb
39
+ lib/pleaserun/cli.rb
40
+ lib/pleaserun/configurable.rb
41
+ lib/pleaserun/detector.rb
42
+ lib/pleaserun/errors.rb
43
+ lib/pleaserun/installer.rb
44
+ lib/pleaserun/mustache_methods.rb
45
+ lib/pleaserun/namespace.rb
46
+ lib/pleaserun/platform/base.rb
47
+ lib/pleaserun/platform/launchd.rb
48
+ lib/pleaserun/platform/runit.rb
49
+ lib/pleaserun/platform/systemd.rb
50
+ lib/pleaserun/platform/sysv.rb
51
+ lib/pleaserun/platform/upstart.rb
52
+ lib/pleaserun/user/base.rb
53
+ pleaserun.gemspec
54
+ spec/pleaserun/cli_spec.rb
55
+ spec/pleaserun/configurable_spec.rb
56
+ spec/pleaserun/mustache_methods_spec.rb
57
+ spec/pleaserun/platform/base_spec.rb
58
+ spec/pleaserun/platform/launchd_spec.rb
59
+ spec/pleaserun/platform/systemd_spec.rb
60
+ spec/pleaserun/platform/sysv_spec.rb
61
+ spec/pleaserun/platform/upstart_spec.rb
62
+ spec/pleaserun/user/base_spec.rb
63
+ spec/shared_examples.rb
64
+ spec/testenv.rb
65
+ templates/launchd/10.9
66
+ templates/launchd/default/program.plist
67
+ templates/runit/log
68
+ templates/runit/run
69
+ templates/systemd/default/prestart.sh
70
+ templates/systemd/default/program.service
71
+ templates/sysv/default
72
+ templates/sysv/lsb-3.1/default
73
+ templates/sysv/lsb-3.1/init.sh
74
+ templates/upstart/0.6.5/init.conf
75
+ templates/upstart/0.6.5/init.d.sh
76
+ templates/upstart/1.10
77
+ templates/upstart/1.5/init.conf
78
+ templates/upstart/1.5/init.d.sh
79
+ templates/upstart/default
80
+ templates/user/linux/default/installer.sh
81
+ templates/user/linux/default/remover.sh
@@ -9,7 +9,7 @@ describe PleaseRun::Platform::SYSV do
9
9
  context "deployment", :sysv => true do
10
10
  etc_initd_writable = File.lstat("/etc/init.d").writable? rescue false
11
11
  if !etc_initd_writable
12
- it "cannot write to /etc/init.d, so there's no deployment test to do. You'll need to run this as root, probably. Be careful, if you do run this as root."
12
+ it "cannot write to /etc/init.d, so there's no deployment test to do. To run these tests, you'll need to run this as root, and preferrably in a vm or other temporary system"
13
13
  else
14
14
  it_behaves_like PleaseRun::Platform do
15
15
  let(:skip) { "Cannot write to /etc/init.d" } unless etc_initd_writable
@@ -0,0 +1,116 @@
1
+ require "testenv"
2
+ require "pleaserun/user/base"
3
+ require "English"
4
+ require "etc"
5
+ require "stud/temporary"
6
+
7
+ describe PleaseRun::User::Base do
8
+ subject(:user) { PleaseRun::User::Base.new }
9
+ describe "defaults" do
10
+ it "should fail validation because there is no name" do
11
+ expect { user.validate }.to(raise_error(PleaseRun::Configurable::ValidationError))
12
+ end
13
+ end
14
+
15
+ [:name, :platform, :version].each do |attribute|
16
+ let(:method) { "#{attribute}=".to_sym }
17
+ context "###{attribute}=" do
18
+ let(:value) { Flores::Random.text(1..10) }
19
+ it "accepts a string" do
20
+ expect { user.send(method, value) }.not_to(raise_error)
21
+ end
22
+ end
23
+ end
24
+
25
+ # Things that can be set to nil
26
+ [:version].each do |attribute|
27
+ let(:method) { "#{attribute}=".to_sym }
28
+ context "###{attribute}=" do
29
+ let(:value) { nil }
30
+ it "accepts nil" do
31
+ expect { user.send(method, value) }.not_to(raise_error)
32
+ end
33
+ end
34
+ end
35
+
36
+ describe "rendering" do
37
+ let(:platform) { "linux" }
38
+ let(:name) { "example" }
39
+ before do
40
+ user.name = name
41
+ user.platform = platform
42
+ end
43
+
44
+ [:name, :platform].each do |attribute|
45
+ it "should have expected #{attribute}" do
46
+ expected = send(attribute) # get the name, platform, whatever
47
+ expect(user.send(attribute)).to(be == expected)
48
+ end
49
+ end
50
+
51
+ it "should pass validation" do
52
+ expect { user.validate }.not_to(raise_error)
53
+ end
54
+
55
+ context "#render_installer" do
56
+ subject(:render) { user.render_installer }
57
+ it "should be a String" do
58
+ expect(render).to(be_a(String))
59
+ end
60
+ end
61
+
62
+ context "#render_remover" do
63
+ subject(:render) { user.render_remover }
64
+ it "should be a String" do
65
+ expect(render).to(be_a(String))
66
+ end
67
+ end
68
+ end
69
+
70
+ describe "integration" do
71
+ let(:platform) { "linux" }
72
+ let(:name) { "example" }
73
+ let(:installer) { Stud::Temporary.pathname }
74
+ let(:remover) { Stud::Temporary.pathname }
75
+ let(:userinfo) { Etc.getpwnam(name) }
76
+
77
+ before do
78
+ user.name = name
79
+ user.platform = platform
80
+ File.write(installer, user.render_installer)
81
+ File.write(remover, user.render_remover)
82
+ end
83
+
84
+ after do
85
+ File.unlink(remover)
86
+ File.unlink(installer)
87
+ end
88
+
89
+ context "installer" do
90
+ it "should create the user" do
91
+ expect(system("sh", installer)).to(be_truthy)
92
+
93
+ # Look up the user
94
+ expect { userinfo }.not_to(raise_error)
95
+ expect(userinfo.name).to(be == name)
96
+ end
97
+ end
98
+
99
+ context "remover" do
100
+ before do
101
+ system("sh", installer)
102
+ end
103
+ it "should remove the user" do
104
+ system("sh", remover)
105
+ # User lookup should fail because the user doesn't exist
106
+ expect { userinfo }.to(raise_error(ArgumentError))
107
+ end
108
+ end
109
+
110
+ after do
111
+ # Ensure the user is gone after the test.
112
+ system("userdel #{name} > /dev/null 2>&1")
113
+ end
114
+
115
+ end
116
+ end
data/spec/testenv.rb CHANGED
@@ -2,6 +2,7 @@ require "English" # for $CHILD_STATUS
2
2
  require "pleaserun/namespace"
3
3
  require "insist"
4
4
  require "shared_examples"
5
+ require "flores/rspec"
5
6
 
6
7
  def superuser?
7
8
  return Process::UID.eid == 0
@@ -73,6 +74,7 @@ end
73
74
 
74
75
  RSpec.configure do |config|
75
76
  config.include Helpers
77
+ Flores::RSpec.configure(config)
76
78
 
77
79
  config.filter_run_excluding(
78
80
  :systemd => !(superuser? && platform?("linux") && program?("systemctl") && File.directory?("/lib/systemd")),
@@ -57,7 +57,7 @@ start() {
57
57
  {{{ulimit_shell}}}
58
58
  cd \"$chdir\"
59
59
  exec \"$program\" $args
60
- " >> {{{ sysv_log }}}.log 2>> {{{ sysv_log }}}.err &
60
+ " >> {{{ sysv_log }}}.stdout 2>> {{{ sysv_log }}}.stderr &
61
61
 
62
62
  # Generate the pidfile from here. If we instead made the forked process
63
63
  # generate it there will be a race condition between the pidfile writing
@@ -0,0 +1,13 @@
1
+ user_check() {
2
+ getent passwd "$1" > /dev/null 2>&1
3
+ }
4
+
5
+ user_create() {
6
+ # Create a system user. A system user is one within the system uid range and
7
+ # has no expiration
8
+ useradd -r "$1"
9
+ }
10
+
11
+ if ! user_check "{{{ name }}}" ; then
12
+ user_create "{{{ name }}}"
13
+ fi
@@ -0,0 +1,11 @@
1
+ user_check() {
2
+ getent passwd "$1" > /dev/null 2>&1
3
+ }
4
+
5
+ user_remove() {
6
+ userdel "$1"
7
+ }
8
+
9
+ if user_check "{{{ name }}}" ; then
10
+ user_remove "{{{ name }}}"
11
+ fi
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pleaserun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Sissel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-03 00:00:00.000000000 Z
11
+ date: 2015-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cabin
@@ -88,7 +88,6 @@ executables:
88
88
  extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
- - ".gitignore"
92
91
  - ".rubocop.yml"
93
92
  - CHANGELOG.asciidoc
94
93
  - Gemfile
@@ -112,6 +111,7 @@ files:
112
111
  - lib/pleaserun/platform/systemd.rb
113
112
  - lib/pleaserun/platform/sysv.rb
114
113
  - lib/pleaserun/platform/upstart.rb
114
+ - lib/pleaserun/user/base.rb
115
115
  - pleaserun.gemspec
116
116
  - spec/pleaserun/cli_spec.rb
117
117
  - spec/pleaserun/configurable_spec.rb
@@ -121,6 +121,7 @@ files:
121
121
  - spec/pleaserun/platform/systemd_spec.rb
122
122
  - spec/pleaserun/platform/sysv_spec.rb
123
123
  - spec/pleaserun/platform/upstart_spec.rb
124
+ - spec/pleaserun/user/base_spec.rb
124
125
  - spec/shared_examples.rb
125
126
  - spec/testenv.rb
126
127
  - templates/launchd/default/program.plist
@@ -134,6 +135,8 @@ files:
134
135
  - templates/upstart/0.6.5/init.d.sh
135
136
  - templates/upstart/1.5/init.conf
136
137
  - templates/upstart/1.5/init.d.sh
138
+ - templates/user/linux/default/installer.sh
139
+ - templates/user/linux/default/remover.sh
137
140
  homepage: https://github.com/jordansissel/pleaserun
138
141
  licenses:
139
142
  - Apache 2.0
@@ -155,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
158
  version: '0'
156
159
  requirements: []
157
160
  rubyforge_project:
158
- rubygems_version: 2.4.3
161
+ rubygems_version: 2.4.6
159
162
  signing_key:
160
163
  specification_version: 4
161
164
  summary: pleaserun
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- .rspec_system/
2
- .*.sw*
3
- .vagrant
4
- .bundle