Module: LaunchDr
- Defined in:
- lib/launchdr.rb,
lib/launchdr/task.rb,
lib/launchdr/launchd.rb,
lib/launchdr/property_list.rb
Defined Under Namespace
Modules: Task
Classes: Launchd, PropertyList
Constant Summary
collapse
- Version =
2
- Options =
Hash.new
Class Method Summary
collapse
Class Method Details
.allow_system_agents! ⇒ Object
26
27
28
|
# File 'lib/launchdr.rb', line 26
def self.allow_system_agents!
Options[:system_agents_allowed] = true
end
|
.allow_system_daemons! ⇒ Object
30
31
32
33
|
# File 'lib/launchdr.rb', line 30
def self.allow_system_daemons!
raise "You must allow System-owned agents to allow System-owned daemons!" unless Options[:system_agents_allowed]
Options[:system_daemon_allowed] = true
end
|
.create(label, opts = {}) {|plist| ... } ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/launchdr.rb', line 12
def self.create label, opts = {}
plist = Launchd.new label
yield plist if block_given?
raise "You must run as a root user and allow_system_agents! if you wish to preform the dangerous act of writing to #{Launchd::Paths[:system_agent]}!" unless !(opts[:type] == :system_agent) or Options[:system_agents_allowed]
raise "You must run as a root user, allow_system_agents!, *and* allow_system_daemons! if you wish to preform the very dangerous act of writing to #{Launchd::Paths[:system_daemon]}!" unless !(opts[:type] == :system_daemon) or Options[:system_daemon_allowed]
path = Launchd::Paths[opts[:type] || :user_agent]
raise "Type error! Must be one of #{Launchd::Paths.keys.join(", ")}" unless path
plist.dump File.expand_path(path)
plist.load!
end
|