Module: Launchr
- Defined in:
- lib/launchr.rb,
lib/launchr/cli.rb,
lib/launchr/path.rb,
lib/launchr/service.rb,
lib/launchr/commands.rb,
lib/launchr/application.rb,
lib/launchr/mixin/popen4.rb,
lib/launchr/mixin/mixlib_cli.rb,
lib/launchr/mixin/ordered_hash.rb,
lib/launchr/mixin/ordered_hash.rb
Defined Under Namespace
Modules: ActiveSupport, Mixlib, Path, Popen4
Classes: Application, CLI, Commands, OrderedHash, Service
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
9
10
11
|
# File 'lib/launchr.rb', line 9
def config
@config ||= {}
end
|
.gid ⇒ Object
91
92
93
|
# File 'lib/launchr.rb', line 91
def gid
Etc.getgrnam(group).gid
end
|
.group ⇒ Object
79
80
81
82
83
84
85
|
# File 'lib/launchr.rb', line 79
def group
if superuser?
sudo_group || real_group
else
real_group
end
end
|
.import_args ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/launchr.rb', line 21
def import_args
if config[:args][:user]
config[:boot] = nil
elsif config[:args][:boot]
config[:boot] = true
end
end
|
.label ⇒ Object
30
31
32
33
|
# File 'lib/launchr.rb', line 30
def label
"com.github.launchr"
end
|
.launchctl_timeout ⇒ Object
35
36
37
|
# File 'lib/launchr.rb', line 35
def launchctl_timeout
5
end
|
.load_default ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/launchr.rb', line 13
def load_default
if Launchr::Path.launchr_default_boot.exist?
config[:boot] = true
else
config[:boot] = nil
end
end
|
.real_group ⇒ Object
43
44
45
|
# File 'lib/launchr.rb', line 43
def real_group
Etc.getgrgid(Process.gid).name
end
|
.real_user ⇒ Object
39
40
41
|
# File 'lib/launchr.rb', line 39
def real_user
Etc.getpwuid(Process.uid).name
end
|
.sudo_group ⇒ Object
61
62
63
64
65
66
67
68
69
|
# File 'lib/launchr.rb', line 61
def sudo_group
if ENV["SUDO_GROUP"]
ENV["SUDO_GROUP"]
elsif ENV["SUDO_GID"]
Etc.getgrgid(ENV["SUDO_GID"].to_i).name
else
nil
end
end
|
.sudo_user ⇒ Object
51
52
53
54
55
56
57
58
59
|
# File 'lib/launchr.rb', line 51
def sudo_user
if ENV["SUDO_USER"]
ENV["SUDO_USER"]
elsif ENV["SUDO_UID"]
Etc.getpwuid(ENV["SUDO_UID"].to_i).name
else
nil
end
end
|
.superuser? ⇒ Boolean
47
48
49
|
# File 'lib/launchr.rb', line 47
def superuser?
real_user == "root"
end
|
.uid ⇒ Object
87
88
89
|
# File 'lib/launchr.rb', line 87
def uid
Etc.getpwnam(user).uid
end
|
.user ⇒ Object
71
72
73
74
75
76
77
|
# File 'lib/launchr.rb', line 71
def user
if superuser?
sudo_user || real_user
else
real_user
end
end
|