7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/launchd_handler.rb', line 7
def self.start
if !internet_connection?
puts "No internet connection detected - unable to verify correct configuration."
return if !agree("Launch henchman anyways? (y/n) ")
else
puts "Checking configuration"
return if !Henchman.connect
end
puts "Creating agent"
plist = Henchman::Templates.plist
plist_path = File.expand_path("~/Library/LaunchAgents/com.henchman.plist")
shell_script_path = File.expand_path("~/.henchman/run.sh")
cache_path = File.expand_path("~/.henchman/cache")
File.write(plist_path, plist)
File.write(shell_script_path, Henchman::Templates.shell_script)
File.open(cache_path, "w") { |f| f.write( {}.to_yaml ) }
puts "Launching agent"
`chmod +x #{shell_script_path}`
`launchctl load #{plist_path}`
puts "Launched successful! You are now running henchman."
end
|