# File lib/puppet/application/agent.rb, line 197
197:   def setup
198:     setup_test if options[:test]
199: 
200:     setup_logs
201: 
202:     exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs?
203: 
204:     # If noop is set, then also enable diffs
205:     Puppet[:show_diff] = true if Puppet[:noop]
206: 
207:     args[:Server] = Puppet[:server]
208:     if options[:fqdn]
209:       args[:FQDN] = options[:fqdn]
210:       Puppet[:certname] = options[:fqdn]
211:     end
212: 
213:     if options[:centrallogs]
214:       logdest = args[:Server]
215: 
216:       logdest += ":" + args[:Port] if args.include?(:Port)
217:       Puppet::Util::Log.newdestination(logdest)
218:     end
219: 
220:     Puppet.settings.use :main, :agent, :ssl
221: 
222:     # Always ignoreimport for agent. It really shouldn't even try to import,
223:     # but this is just a temporary band-aid.
224:     Puppet[:ignoreimport] = true
225: 
226:     # We need to specify a ca location for all of the SSL-related i
227:     # indirected classes to work; in fingerprint mode we just need
228:     # access to the local files and we don't need a ca.
229:     Puppet::SSL::Host.ca_location = options[:fingerprint] ? :none : :remote
230: 
231:     Puppet::Transaction::Report.terminus_class = :rest
232: 
233:     # Override the default; puppetd needs this, usually.
234:     # You can still override this on the command-line with, e.g., :compiler.
235:     Puppet[:catalog_terminus] = :rest
236: 
237:     # Override the default.
238:     Puppet[:facts_terminus] = :facter
239: 
240:     Puppet::Resource::Catalog.cache_class = :yaml
241: 
242: 
243:     # We need tomake the client either way, we just don't start it
244:     # if --no-client is set.
245:     require 'puppet/agent'
246:     require 'puppet/configurer'
247:     @agent = Puppet::Agent.new(Puppet::Configurer)
248: 
249:     enable_disable_client(@agent) if options[:enable] or options[:disable]
250: 
251:     @daemon.agent = agent if options[:client]
252: 
253:     # It'd be nice to daemonize later, but we have to daemonize before the
254:     # waitforcert happens.
255:     @daemon.daemonize if Puppet[:daemonize]
256: 
257:     setup_host
258: 
259:     @objects = []
260: 
261:     # This has to go after the certs are dealt with.
262:     if Puppet[:listen]
263:       unless Puppet[:onetime]
264:         setup_listen
265:       else
266:         Puppet.notice "Ignoring --listen on onetime run"
267:       end
268:     end
269:   end