Skip to content

Commit 50f0e79

Browse files
author
Christopher Brown
committed
clean up command handling in client
get javascript copied to the right place
1 parent a9cb979 commit 50f0e79

3 files changed

Lines changed: 27 additions & 35 deletions

File tree

‎chef-server/config/router.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# resources :posts
3232

3333
# Adds the required routes for merb-auth using the password slice
34-
slice(:merb_auth_slice_password, :name_prefix => nil, :path_prefix => "")
34+
# slice(:merb_auth_slice_password, :name_prefix => nil, :path_prefix => "")
3535
slice(:chefserverslice)
3636
# This is the default route for /:controller/:action/:id
3737
# This is fine for most cases. If you're heavily using resource-based

‎chef/bin/chef-client‎

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,23 @@ config = {
3030
}
3131
opts = OptionParser.new do |opts|
3232
opts.banner = "Usage: #{$0} [-d DIR|-r FILE] (options)"
33-
opts.on("-c CONFIG", "--config CONFIG", "The Chef Config file to use") do |c|
34-
config[:config_file] = c
35-
end
36-
opts.on("-u USER", "--user USER", "User to change uid to before daemonizing") do |u|
37-
config[:user] = u
38-
end
39-
opts.on("-g GROUP", "--group GROUP", "Group to change gid to before daemonizing") do |g|
40-
config[:group] = g
41-
end
42-
opts.on("-d", "--daemonize", "Daemonize the process") do |d|
43-
config[:daemonize] = true
44-
end
45-
opts.on("-i SECONDS", "--interval SECONDS", "Run chef-client peridoically, in seconds") do |i|
46-
config[:interval] = i
47-
end
48-
opts.on("-j JSON_ATTRIBS", "--json-attributes JSON_ATTRIBS", "Load attributes from a JSON file") do |j|
49-
config[:json_attribs] = j
50-
end
51-
opts.on("-N NODE_NAME", "--node-name NODE_NAME", "The node name for this client") do |n|
52-
config[:node_name] = n
53-
end
54-
opts.on("-s SECONDS", "--splay SECONDS", "The splay time for running at intervals, in seconds") do |s|
55-
config[:splay] = s
56-
end
57-
opts.on("-l LEVEL", "--loglevel LEVEL", "Set the log level (debug, info, warn, error, fatal)") do |l|
58-
config[:log_level] = l.to_sym
59-
end
60-
opts.on("-L LOGLOCATION", "--logfile LOGLOCATION", "Set the log file location, defaults to STDOUT - recommended for daemonizing") do |lf|
61-
config[:log_location] = lf
62-
end
63-
opts.on("-t TOKEN", "--token TOKEN", "Set the openid validation token") do |t|
64-
config[:validation_token] = t
33+
{
34+
:config_file=> { :short=>"-c CONFIG", :long=>"--config CONFIG", :description=>"The Chef Config file to use", :proc=>nil },
35+
:user=> { :short=>"-u USER", :long=>"--user USER", :description=>"User to change uid to before daemonizing", :proc=>nil },
36+
:group=> { :short=>"-g GROUP", :long=>"--group GROUP", :description=>"Group to change gid to before daemonizing", :proc=>nil },
37+
:daemonize=> { :short=>"-d", :long=>"--daemonize", :description=>"Daemonize the process", :proc=>{ |p| true} },
38+
:interval=> { :short=>"-i SECONDS", :long=>"--interval SECONDS", :description=>"Run chef-client periodically, in seconds", :proc=>nil },
39+
:json_attribs=>{ :short=>"-j JSON_ATTRIBS", :long=>"--json-attributes JSON_ATTRIBS", :description=>"Load attributes from a JSON file", :proc=>nil },
40+
:node_name=> { :short=>"-N NODE_NAME", :long=>"--node-name NODE_NAME", :description=>"The node name for this client", :proc=>nil },
41+
:splay=> { :short=>"-s SECONDS", :long=>"--splay SECONDS", :description=>"The splay time for running at intervals, in seconds", :proc=>nil },
42+
:log_level=> { :short=>"-l LEVEL", :long=>"--loglevel LEVEL", :description=>"Set the log level (debug, info, warn, error, fatal)", :proc=>{ |p| p.to_sym} },
43+
:log_location=>{ :short=>"-L LOGLOCATION", :long=>"--logfile LOGLOCATION", :description=>"Set the log file location, defaults to STDOUT - recommended for daemonizing", :proc=>nil },
44+
:validation_token=>{ :short=>"-t TOKEN", :long=>"--token TOKEN", :description=>"Set the openid validation token", :proc=>nil },}
45+
46+
opts.on(val[:short],val[:long],val[:description]) do |c|
47+
config[key] = (val[:proc] && val[:proc].call) || c
6548
end
49+
6650
opts.on_tail("-h", "--help", "Show this message") do
6751
puts opts
6852
exit 0

‎chefserverslice/lib/chefserverslice.rb‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010

1111
# Register the Slice for the current host application
1212
Merb::Slices::register(__FILE__)
13+
14+
Merb.disable :json
1315

1416
# Slice configuration - set this in a before_app_loads callback.
1517
# By default a Slice uses its own layout, so you can swicht to
1618
# the main application layout or no layout at all if needed.
1719
#
1820
# Configuration options:
19-
# :layout - the layout to use; defaults to :chefserver
21+
# :layout - the layout to use; defaults to :chefserverslice
2022
# :mirror - which path component types to use on copy operations; defaults to all
2123
Merb::Slices::config[:chefserverslice][:layout] ||= :chefserverslice
2224

@@ -115,7 +117,7 @@ def self.setup_router(scope)
115117
scope.match('/').to(:controller => 'nodes', :action =>'index').name(:top)
116118
# enable slice-level default routes by default
117119
# [cb] disable default routing in favor of explicit (see scope.resources above)
118-
# scope.default_routes
120+
#scope.default_routes
119121
end
120122

121123
end
@@ -134,5 +136,11 @@ def self.setup_router(scope)
134136
# Or just call setup_default_structure! to setup a basic Merb MVC structure.
135137
Chefserverslice.setup_default_structure!
136138

139+
# freaky path fix for javascript and stylesheets
140+
unless Chefserverslice.standalone?
141+
Chefserverslice.public_components.each do |component|
142+
Chefserverslice.push_app_path(component, Merb.dir_for(:public) / "#{component}s", nil)
143+
end
144+
end
137145
end
138146

0 commit comments

Comments
 (0)