module HeadStartApp module Marionette # Setup method configures the server for running marionette as a service at boot up. def setup(options={}) # Set default(s) ip = `sudo /sbin/ifconfig eth1 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'` options = { :uri => "tcp://#{ip}:5555" } if options.nil? # Set up marionette as a service to start at boot. # define task: # 1) write to init.d/marionette # 2) set permissions # 3) set ifconfig # 4) start service script = <&2 exit 3 ;; esac exit 0 CODE file = File.open('/etc/marionette.tcp','w') file.write "tcp://#{ip.strip}:5555" file.close file = File.open('/etc/init.d/marionette','w') file.write script file.close system "sudo chmod 755 /etc/init.d/marionette" end module_function :setup end end