brew-launchd 1.1.1
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.
- data/.document +5 -0
- data/.gitignore +43 -0
- data/.yardopts +4 -0
- data/Gemfile +24 -0
- data/LICENSE +20 -0
- data/README.rdoc +63 -0
- data/Rakefile +78 -0
- data/VERSION +1 -0
- data/bin/brew-launchd.rb +24 -0
- data/bin/brew-restart.rb +22 -0
- data/bin/brew-start.rb +24 -0
- data/bin/brew-stop.rb +24 -0
- data/features/launchr.feature +9 -0
- data/features/step_definitions/launchr_steps.rb +0 -0
- data/features/support/env.rb +14 -0
- data/lib/launchr.rb +105 -0
- data/lib/launchr/application.rb +24 -0
- data/lib/launchr/cli.rb +142 -0
- data/lib/launchr/commands.rb +118 -0
- data/lib/launchr/extend/pathname.rb +27 -0
- data/lib/launchr/mixin/mixlib_cli.rb +693 -0
- data/lib/launchr/mixin/ordered_hash.rb +189 -0
- data/lib/launchr/mixin/popen4.rb +219 -0
- data/lib/launchr/path.rb +106 -0
- data/lib/launchr/service.rb +522 -0
- data/man1/brew-launchd.1 +95 -0
- data/man1/brew-launchd.1.html +140 -0
- data/man1/brew-launchd.1.ronn +71 -0
- data/spec/launchr/application_spec.rb +37 -0
- data/spec/launchr/cli_spec.rb +25 -0
- data/spec/launchr/commands_spec.rb +20 -0
- data/spec/launchr/config_spec.rb +38 -0
- data/spec/launchr_spec.rb +7 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- metadata +213 -0
data/.document
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
|
4
|
+
# rdoc generated
|
5
|
+
rdoc
|
6
|
+
|
7
|
+
# yard generated
|
8
|
+
doc
|
9
|
+
.yardoc
|
10
|
+
|
11
|
+
# jeweler generated
|
12
|
+
pkg
|
13
|
+
|
14
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
15
|
+
#
|
16
|
+
# * Create a file at ~/.gitignore
|
17
|
+
# * Include files you want ignored
|
18
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
19
|
+
#
|
20
|
+
# After doing this, these files will be ignored in all your git projects,
|
21
|
+
# saving you from having to 'pollute' every project you touch with them
|
22
|
+
#
|
23
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
24
|
+
#
|
25
|
+
# For MacOS:
|
26
|
+
#
|
27
|
+
#.DS_Store
|
28
|
+
#
|
29
|
+
# For TextMate
|
30
|
+
#*.tmproj
|
31
|
+
#tmtags
|
32
|
+
#
|
33
|
+
# For emacs:
|
34
|
+
#*~
|
35
|
+
#\#*
|
36
|
+
#.\#*
|
37
|
+
#
|
38
|
+
# For vim:
|
39
|
+
#*.swp
|
40
|
+
|
41
|
+
ext/*.o
|
42
|
+
|
43
|
+
|
data/.yardopts
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Add dependencies required to use your gem here.
|
2
|
+
group :runtime do
|
3
|
+
#gem 'bundler', '>= 0.9.5'
|
4
|
+
end
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
|
10
|
+
gem "yard", ">= 0"
|
11
|
+
|
12
|
+
gem "bundler", ">= 0.9.5"
|
13
|
+
|
14
|
+
gem "jeweler", ">= 1.4.0"
|
15
|
+
|
16
|
+
gem "rcov", ">= 0"
|
17
|
+
|
18
|
+
gem "rspec", ">= 1.3.0"
|
19
|
+
|
20
|
+
gem "cucumber", ">= 0"
|
21
|
+
|
22
|
+
gem "grancher", ">= 0"
|
23
|
+
|
24
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Dreamcat4
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
= brew launchd
|
2
|
+
|
3
|
+
An extension to start and stop Launchd services.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
* Get the launchd core changes for homebrew (until they merge it)
|
8
|
+
|
9
|
+
brew update
|
10
|
+
git config core.whitespace nowarn
|
11
|
+
git remote add dreamcat4 git://github.com/dreamcat4/homebrew.git
|
12
|
+
git fetch --no-tags dreamcat4 +issue-148-launchd:launchd-core-changes
|
13
|
+
git rebase launchd-core-changes
|
14
|
+
|
15
|
+
== Usage
|
16
|
+
|
17
|
+
$ brew launchd --help
|
18
|
+
start service,(s) Start launchd service(s)
|
19
|
+
Equivalent to launchctl load -w files...
|
20
|
+
Example $ brew start dnsmasq memcached couchdb
|
21
|
+
|
22
|
+
stop service,(s) Stop launchd service(s)
|
23
|
+
Equivalent to launchctl unload -w files...
|
24
|
+
Example $ brew stop mamcached dnsmasq
|
25
|
+
|
26
|
+
restart service,(s) Restart launchd service(s)
|
27
|
+
Example $ brew restart couchdb
|
28
|
+
|
29
|
+
--user At user login.
|
30
|
+
Otherwise, the default setting will be used.
|
31
|
+
Example $ brew start --user openvpn ddclient
|
32
|
+
|
33
|
+
--boot At boot time. Requires sudo/root privelidges.
|
34
|
+
Otherwise, the default setting will be used.
|
35
|
+
Example $ sudo brew start --boot nginx mysql
|
36
|
+
|
37
|
+
info [service,(s)] Info for launchd service(s)
|
38
|
+
With no arguments prints info for all services.
|
39
|
+
Example $ brew launchd info
|
40
|
+
|
41
|
+
clean Clean missing/broken launchd service(s).
|
42
|
+
|
43
|
+
Examples $ brew launchd clean
|
44
|
+
$ sudo brew launchd clean
|
45
|
+
|
46
|
+
default [--user|--boot] Set the default target to start launchd services.
|
47
|
+
The initial setting, --user will start daemons at
|
48
|
+
user login - from the Loginwindow (not over ssh).
|
49
|
+
|
50
|
+
Wheras --boot will set services to start at boot
|
51
|
+
time. But be aware that brew should be installed
|
52
|
+
to the root filesystem, not on a mounted volume.
|
53
|
+
|
54
|
+
Examples $ brew launchd default --boot
|
55
|
+
$ brew launchd default --user
|
56
|
+
|
57
|
+
--help Show this message
|
58
|
+
|
59
|
+
--version Print version information
|
60
|
+
|
61
|
+
== Copyright
|
62
|
+
|
63
|
+
Copyright (c) 2010 Dreamcat4. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
|
5
|
+
# require 'bundler'
|
6
|
+
# begin
|
7
|
+
# Bundler.setup(:runtime, :development)
|
8
|
+
# rescue Bundler::BundlerError => e
|
9
|
+
# $stderr.puts e.message
|
10
|
+
# $stderr.puts "Run `bundle install` to install missing gems"
|
11
|
+
# exit e.status_code
|
12
|
+
# end
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
require 'jeweler'
|
17
|
+
Jeweler::Tasks.new do |gem|
|
18
|
+
gem.name = "brew-launchd"
|
19
|
+
gem.summary = %Q{Dreamcat4's brew-launchd. For managing launchd plists}
|
20
|
+
gem.description = %Q{Companion tool for Brew (Mac Homebrew). An extension to start and stop Launchd services.}
|
21
|
+
gem.email = "dreamcat4@gmail.com"
|
22
|
+
gem.homepage = "http://github.com/dreamcat4/brew-launchd"
|
23
|
+
gem.authors = ["Dreamcat4"]
|
24
|
+
|
25
|
+
# Have dependencies? Add them to Gemfile
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
require 'yard'
|
35
|
+
YARD::Rake::YardocTask.new do |t|
|
36
|
+
t.after = lambda { `touch doc/.nojekyll` }
|
37
|
+
end
|
38
|
+
|
39
|
+
task :man do
|
40
|
+
`cd man1 && ronn *.ronn --manual=brew --organization=Homebrew`
|
41
|
+
end
|
42
|
+
|
43
|
+
require 'spec/rake/spectask'
|
44
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
45
|
+
spec.libs << 'lib' << 'spec'
|
46
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
47
|
+
end
|
48
|
+
|
49
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
50
|
+
spec.libs << 'lib' << 'spec'
|
51
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
52
|
+
spec.rcov = true
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
require 'cucumber/rake/task'
|
59
|
+
Cucumber::Rake::Task.new(:features)
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
Jeweler::GhpagesTasks.new do |ghpages|
|
65
|
+
ghpages.push_on_release = true
|
66
|
+
ghpages.set_repo_homepage = true
|
67
|
+
ghpages.user_github_com = false
|
68
|
+
ghpages.doc_task = "yard"
|
69
|
+
ghpages.keep_files = []
|
70
|
+
ghpages.map_paths = {
|
71
|
+
"doc" => "",
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
task :default => :spec
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.1.1
|
data/bin/brew-launchd.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Put back the command name onto ARGV
|
4
|
+
launchr_subcommand = File.basename(__FILE__).gsub(/^brew-|\.rb$/,"")
|
5
|
+
unless ["launchd"].include?(launchr_subcommand)
|
6
|
+
ARGV.unshift launchr_subcommand
|
7
|
+
end
|
8
|
+
|
9
|
+
# Get the real path if was executed as a symlink
|
10
|
+
require 'pathname'
|
11
|
+
__FILE_REALPATH__ = Pathname.new(__FILE__).realpath
|
12
|
+
LAUNCHR_BIN = File.expand_path(File.dirname(__FILE_REALPATH__)+"/launchr")
|
13
|
+
|
14
|
+
|
15
|
+
dir = File.expand_path "../lib", File.dirname(LAUNCHR_BIN)
|
16
|
+
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
|
17
|
+
|
18
|
+
|
19
|
+
# Into the rabbit hole
|
20
|
+
require 'launchr/application'
|
21
|
+
app = Launchr::Application.new
|
22
|
+
|
23
|
+
|
24
|
+
|
data/bin/brew-restart.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Put back the command name onto ARGV
|
4
|
+
launchr_subcommand = File.basename(__FILE__).gsub(/^brew-|\.rb$/,"")
|
5
|
+
unless ["launchd"].include?(launchr_subcommand)
|
6
|
+
ARGV.unshift launchr_subcommand
|
7
|
+
end
|
8
|
+
|
9
|
+
# Get the real path if was executed as a symlink
|
10
|
+
require 'pathname'
|
11
|
+
__FILE_REALPATH__ = Pathname.new(__FILE__).realpath
|
12
|
+
LAUNCHR_BIN = File.expand_path(File.dirname(__FILE_REALPATH__)+"/launchr")
|
13
|
+
|
14
|
+
|
15
|
+
dir = File.expand_path "../lib", File.dirname(LAUNCHR_BIN)
|
16
|
+
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
|
17
|
+
|
18
|
+
|
19
|
+
# Into the rabbit hole
|
20
|
+
require 'launchr/application'
|
21
|
+
app = Launchr::Application.new
|
22
|
+
|
data/bin/brew-start.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Put back the command name onto ARGV
|
4
|
+
launchr_subcommand = File.basename(__FILE__).gsub(/^brew-|\.rb$/,"")
|
5
|
+
unless ["launchd"].include?(launchr_subcommand)
|
6
|
+
ARGV.unshift launchr_subcommand
|
7
|
+
end
|
8
|
+
|
9
|
+
# Get the real path if was executed as a symlink
|
10
|
+
require 'pathname'
|
11
|
+
__FILE_REALPATH__ = Pathname.new(__FILE__).realpath
|
12
|
+
LAUNCHR_BIN = File.expand_path(File.dirname(__FILE_REALPATH__)+"/launchr")
|
13
|
+
|
14
|
+
|
15
|
+
dir = File.expand_path "../lib", File.dirname(LAUNCHR_BIN)
|
16
|
+
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
|
17
|
+
|
18
|
+
|
19
|
+
# Into the rabbit hole
|
20
|
+
require 'launchr/application'
|
21
|
+
app = Launchr::Application.new
|
22
|
+
|
23
|
+
|
24
|
+
|
data/bin/brew-stop.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Put back the command name onto ARGV
|
4
|
+
launchr_subcommand = File.basename(__FILE__).gsub(/^brew-|\.rb$/,"")
|
5
|
+
unless ["launchd"].include?(launchr_subcommand)
|
6
|
+
ARGV.unshift launchr_subcommand
|
7
|
+
end
|
8
|
+
|
9
|
+
# Get the real path if was executed as a symlink
|
10
|
+
require 'pathname'
|
11
|
+
__FILE_REALPATH__ = Pathname.new(__FILE__).realpath
|
12
|
+
LAUNCHR_BIN = File.expand_path(File.dirname(__FILE_REALPATH__)+"/launchr")
|
13
|
+
|
14
|
+
|
15
|
+
dir = File.expand_path "../lib", File.dirname(LAUNCHR_BIN)
|
16
|
+
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
|
17
|
+
|
18
|
+
|
19
|
+
# Into the rabbit hole
|
20
|
+
require 'launchr/application'
|
21
|
+
app = Launchr::Application.new
|
22
|
+
|
23
|
+
|
24
|
+
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
begin
|
3
|
+
Bundler.setup(:runtime, :development)
|
4
|
+
rescue Bundler::BundlerError => e
|
5
|
+
$stderr.puts e.message
|
6
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
7
|
+
exit e.status_code
|
8
|
+
end
|
9
|
+
|
10
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
11
|
+
require 'launchr'
|
12
|
+
|
13
|
+
require 'spec/expectations'
|
14
|
+
|
data/lib/launchr.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
|
2
|
+
dir = File.dirname(__FILE__)
|
3
|
+
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
|
4
|
+
|
5
|
+
require 'launchr/path'
|
6
|
+
|
7
|
+
module Launchr
|
8
|
+
class << self
|
9
|
+
def config
|
10
|
+
@config ||= {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def load_default
|
14
|
+
if Launchr::Path.launchr_default_boot.exist?
|
15
|
+
config[:boot] = true
|
16
|
+
else
|
17
|
+
config[:boot] = nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def import_args
|
22
|
+
if config[:args][:user]
|
23
|
+
config[:boot] = nil
|
24
|
+
|
25
|
+
elsif config[:args][:boot]
|
26
|
+
config[:boot] = true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def label
|
31
|
+
# "com.github.homebrew.launchr"
|
32
|
+
"com.github.launchr"
|
33
|
+
end
|
34
|
+
|
35
|
+
def launchctl_timeout
|
36
|
+
5
|
37
|
+
end
|
38
|
+
|
39
|
+
def real_user
|
40
|
+
Etc.getpwuid(Process.uid).name
|
41
|
+
end
|
42
|
+
|
43
|
+
def real_group
|
44
|
+
Etc.getgrgid(Process.gid).name
|
45
|
+
end
|
46
|
+
|
47
|
+
def superuser?
|
48
|
+
real_user == "root"
|
49
|
+
end
|
50
|
+
|
51
|
+
def sudo_user
|
52
|
+
if ENV["SUDO_USER"]
|
53
|
+
ENV["SUDO_USER"]
|
54
|
+
elsif ENV["SUDO_UID"]
|
55
|
+
Etc.getpwuid(ENV["SUDO_UID"].to_i).name
|
56
|
+
else
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def sudo_group
|
62
|
+
if ENV["SUDO_GROUP"]
|
63
|
+
ENV["SUDO_GROUP"]
|
64
|
+
elsif ENV["SUDO_GID"]
|
65
|
+
Etc.getgrgid(ENV["SUDO_GID"].to_i).name
|
66
|
+
else
|
67
|
+
nil
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def user
|
72
|
+
if superuser?
|
73
|
+
sudo_user || real_user
|
74
|
+
else
|
75
|
+
real_user
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def group
|
80
|
+
if superuser?
|
81
|
+
sudo_group || real_group
|
82
|
+
else
|
83
|
+
real_group
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def uid
|
88
|
+
Etc.getpwnam(user).uid
|
89
|
+
end
|
90
|
+
|
91
|
+
def gid
|
92
|
+
Etc.getgrnam(group).gid
|
93
|
+
end
|
94
|
+
|
95
|
+
def version
|
96
|
+
if Launchr::Path.launchr_version.exist?
|
97
|
+
Launchr::Path.launchr_version.read.strip
|
98
|
+
else
|
99
|
+
"0.0.0"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
|