summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jacob <adam@opscode.com>2009-12-29 16:12:49 -0800
committerAdam Jacob <adam@opscode.com>2009-12-29 16:12:49 -0800
commit2c5effd70f462286f65c9e0820150d9273252392 (patch)
tree1bda18bfd0dfbaec297281eef4ff4d374a417c57
parent5865aa435caef58a68cd4afbfff2bb34013dc638 (diff)
downloadchef-2c5effd70f462286f65c9e0820150d9273252392.tar.gz
Adding chef-server-webui binary, and rackup files
-rw-r--r--chef-server-webui/config/init.rb3
-rw-r--r--chef-server-webui/lib/chef-server-webui.rb3
-rwxr-xr-xchef-server/bin/chef-server-webui73
-rw-r--r--chef-server/config-webui.ru25
-rw-r--r--chef-server/config/dependencies-webui.rb27
-rw-r--r--chef-server/config/init-webui.rb34
-rw-r--r--chef-server/config/router.rb4
7 files changed, 163 insertions, 6 deletions
diff --git a/chef-server-webui/config/init.rb b/chef-server-webui/config/init.rb
index 6ee1a8f50e..2b508d96a6 100644
--- a/chef-server-webui/config/init.rb
+++ b/chef-server-webui/config/init.rb
@@ -35,8 +35,7 @@ use_template_engine :haml
Merb::Config.use do |c|
# BUGBUG [cb] For some reason, this next line
# causes a merb slice to vomit around openid
- # c[:fork_for_class_load] = false
-
+ #c[:fork_for_class_load] = false
c[:session_id_key] = '_chef_server_session_id'
c[:session_secret_key] = Chef::Config.manage_secret_key
c[:session_store] = 'cookie'
diff --git a/chef-server-webui/lib/chef-server-webui.rb b/chef-server-webui/lib/chef-server-webui.rb
index b73391311d..ec30b2363d 100644
--- a/chef-server-webui/lib/chef-server-webui.rb
+++ b/chef-server-webui/lib/chef-server-webui.rb
@@ -134,9 +134,8 @@ if defined?(Merb::Plugins)
user.name = Chef::Config[:web_ui_admin_user_name]
user.set_password(Chef::Config[:web_ui_admin_default_password])
user.admin = true
- user.cdb_save
+ user.save
end
-
end
diff --git a/chef-server/bin/chef-server-webui b/chef-server/bin/chef-server-webui
new file mode 100755
index 0000000000..39b68b94c6
--- /dev/null
+++ b/chef-server/bin/chef-server-webui
@@ -0,0 +1,73 @@
+#!/usr/bin/env ruby
+#
+# ./chef-server - Serving up piping hot infrastructure!
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Based on the 'merb' command, by Ezra
+
+# Add chef and chef-server-slice lib dirs to the load path
+# Load chef and chef-server slice from source rather than gem, if present
+
+require "rubygems"
+require "merb-core"
+
+[ 'chef', 'chef-server-webui' ].each do |lib|
+ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib")))
+ library = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", lib, "lib", "#{lib}.rb"))
+ require library if File.exists?(library)
+end
+
+ObjectSpace.each_object(Gem::Specification) do |gem|
+ next unless gem.name == "chef-server"
+ CHEF_SERVER_VERSION = gem.version.to_s
+ break
+end
+
+# Ensure the chef gem we load is the same version as the chef server
+unless defined?(Chef)
+ gem "chef", "=" + CHEF_SERVER_VERSION if CHEF_SERVER_VERSION
+ require 'chef'
+end
+
+Dir.chdir File.join(File.dirname(__FILE__),"..")
+__DIR__ = Dir.getwd
+
+if ARGV[0] && ARGV[0] =~ /^[^-]/
+ ARGV.push "-H"
+end
+unless %w[-a --adapter -i --irb-console -r --script-runner].any? { |o| ARGV.index(o) }
+ ARGV.push *%w[-a thin]
+end
+ARGV.push *[ "-I", File.join(__DIR__, "config", "init-webui.rb") ]
+ARGV.push *[ "-m", __DIR__]
+
+if index = ARGV.index("-C")
+ config = ARGV[index+1]
+ ARGV.delete("-C")
+ ARGV.delete(config)
+ Chef::Config.from_file(File.expand_path(config))
+else
+ Chef::Config.from_file(
+ File.join("/etc", "chef", "server.rb")
+ )
+end
+
+Chef::Log.init(Chef::Config[:log_location])
+Chef::Log.level = Chef::Config[:log_level]
+
+Merb.start
diff --git a/chef-server/config-webui.ru b/chef-server/config-webui.ru
new file mode 100644
index 0000000000..d40a35e679
--- /dev/null
+++ b/chef-server/config-webui.ru
@@ -0,0 +1,25 @@
+require 'rubygems'
+require 'merb-core'
+require 'chef'
+
+Chef::Config.from_file(File.join("/etc", "chef", "server.rb"))
+
+Merb::Config.setup(:merb_root => File.expand_path(File.dirname(__FILE__)),
+ :environment => 'production',
+ :fork_for_class_load => false,
+ :init_file => File.dirname(__FILE__) / "config/init-webui.rb")
+Merb.environment = Merb::Config[:environment]
+Merb.root = Merb::Config[:merb_root]
+Merb::BootLoader.run
+
+Merb::Slices.config.each do |slice_module, config|
+ slice_module = Object.full_const_get(slice_module.to_s.camel_case) if slice_module.class.in?(String, Symbol)
+ slice_module.send("public_components").each do |component|
+ slice_static_dir = slice_module.send("dir_for", :public)
+ use Merb::Rack::Static, slice_static_dir
+ end
+end
+
+run Merb::Rack::Application.new
+
+
diff --git a/chef-server/config/dependencies-webui.rb b/chef-server/config/dependencies-webui.rb
new file mode 100644
index 0000000000..14ba2796e7
--- /dev/null
+++ b/chef-server/config/dependencies-webui.rb
@@ -0,0 +1,27 @@
+# dependencies are generated using a strict version, don't forget to edit the dependency versions when upgrading.
+merb_gems_version = "> 1.0"
+
+%w{chef chef-server-webui}.each do |dep|
+ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "..", dep, "lib")))
+end
+
+dependency "chef", :immediate=>true unless defined?(Chef)
+
+begin
+ require 'chef'
+ require 'chef-server-webui'
+rescue
+end
+
+# For more information about each component, please read http://wiki.merbivore.com/faqs/merb_components
+dependency "merb-core", merb_gems_version
+dependency "merb-slices", merb_gems_version
+dependency "merb-haml", merb_gems_version
+dependency "merb-assets", merb_gems_version
+dependency "merb-helpers", merb_gems_version
+if defined?(CHEF_SERVER_VERSION)
+ dependency "chef-server-webui", CHEF_SERVER_VERSION unless defined?(ChefServerWebui)
+else
+ dependency "chef-server-webui" unless defined?(ChefServerWebui)
+end
+
diff --git a/chef-server/config/init-webui.rb b/chef-server/config/init-webui.rb
new file mode 100644
index 0000000000..0de477a4e4
--- /dev/null
+++ b/chef-server/config/init-webui.rb
@@ -0,0 +1,34 @@
+# Go to http://wiki.merbivore.com/pages/init-rb
+
+require 'config/dependencies-webui.rb'
+unless defined?(Chef)
+ gem "chef", "=" + CHEF_SERVER_VERSION if CHEF_SERVER_VERSION
+ require 'chef'
+end
+
+File.umask Chef::Config[:umask]
+
+use_test :rspec
+use_template_engine :haml
+
+Merb::Config.use do |c|
+ c[:use_mutex] = false
+ c[:fork_for_class_load] = false
+ c[:session_id_key] = '_chef_server_session_id'
+ c[:session_secret_key] = Chef::Config.manage_secret_key
+ c[:session_store] = 'cookie'
+ c[:log_level] = Chef::Config[:log_level]
+ if Chef::Config[:log_location].kind_of?(String)
+ c[:log_file] = Chef::Config[:log_location]
+ end
+end
+
+Merb::BootLoader.before_app_loads do
+ # This will get executed after dependencies have been loaded but before your app's classes have loaded.
+end
+
+Merb::BootLoader.after_app_loads do
+ # This will get executed after your app's classes have been loaded.
+ OpenID::Util.logger = Merb.logger
+end
+
diff --git a/chef-server/config/router.rb b/chef-server/config/router.rb
index cefef0c79a..f352c42f61 100644
--- a/chef-server/config/router.rb
+++ b/chef-server/config/router.rb
@@ -33,7 +33,7 @@ Merb::Router.prepare do
# Adds the required routes for merb-auth using the password slice
# slice(:merb_auth_slice_password, :name_prefix => nil, :path_prefix => "")
- slice(:chef_server_api)
- # slice(:chef_server_webui, :path_prefix => "html")
+ slice(:chef_server_api, :path_prefix => "") if defined?(ChefServerApi)
+ slice(:chef_server_webui, :path_prefix => "") if defined?(ChefServerWebui)
end