From de1053db92096a5498f772749e709dd61bf39b99 Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Sat, 10 May 2014 20:45:54 +0000 Subject: [PATCH 01/10] Support (initial) for apache as proxy server --- .gitignore | 1 + attributes/default.rb | 33 ++++++++++++++++++------------ metadata.rb | 5 ++++- recipes/default.rb | 30 +++++++++++++++++++-------- templates/default/nginx.conf.erb | 1 - templates/default/upstart.conf.erb | 6 +++--- templates/default/web_app.conf.erb | 21 +++++++++++++++++++ 7 files changed, 70 insertions(+), 27 deletions(-) create mode 100644 templates/default/web_app.conf.erb diff --git a/.gitignore b/.gitignore index e43b0f9..f31b3e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .DS_Store +*.swp diff --git a/attributes/default.rb b/attributes/default.rb index 4cbebb1..03cd917 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -9,20 +9,33 @@ # Defaults based on https://github.com/ether/etherpad-lite/blob/develop/settings.json.template +default['etherpad-lite']['etherpad_git_repo_url'] = 'git://github.com/ether/etherpad-lite.git' +default['etherpad-lite']['etherpad_api_key'] = '' + default['etherpad-lite']['title'] = "Etherpad" default['etherpad-lite']['favicon_url'] = "favicon.ico" + +default['etherpad-lite']['domain'] = "example.com" default['etherpad-lite']['ip_address'] = "0.0.0.0" default['etherpad-lite']['port_number'] = 9001 default['etherpad-lite']['session_key'] = "" + default['etherpad-lite']['ssl_enabled'] = false default['etherpad-lite']['ssl_key_path'] = "" default['etherpad-lite']['ssl_cert_path'] = "" + default['etherpad-lite']['db_type'] = "postgres" default['etherpad-lite']['db_user'] = "postgres" default['etherpad-lite']['db_host'] = "localhost" +default['etherpad-lite']['db_port'] = nil default['etherpad-lite']['db_password'] = "" default['etherpad-lite']['db_name'] = "etherpad" + +default['etherpad-lite']['admin_enabled'] = false +default['etherpad-lite']['admin_password'] = "" + default['etherpad-lite']['default_text'] = "Welcome to Etherpad!\\n\\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\\n\\nGet involved with Etherpad at http:\/\/etherpad.org\\n" + default['etherpad-lite']['require_session'] = "false" default['etherpad-lite']['edit_only'] = "false" default['etherpad-lite']['minify'] = "true" @@ -30,21 +43,15 @@ default['etherpad-lite']['abiword_path'] = "null" default['etherpad-lite']['require_authentication'] = "false" default['etherpad-lite']['require_authorization'] = "false" -default['etherpad-lite']['admin_enabled'] = false -default['etherpad-lite']['admin_password'] = "" -default['etherpad-lite']['log_level'] = "INFO" -service_user = "etherpad-user" - -default['etherpad-lite']['service_user'] = service_user -default['etherpad-lite']['service_user_gid'] = 500 -default['etherpad-lite']['service_user_home'] = "/home/#{service_user}" -default['etherpad-lite']['service_name'] = "etherpad" -default['etherpad-lite']['logs_dir'] = "/var/logs/etherpad" -default['etherpad-lite']['domain'] = "example.com" +default['etherpad-lite']['service_user'] = 'etherpad' +default['etherpad-lite']['service_user_gid'] = node['etherpad-lite']['service_user'] +default['etherpad-lite']['service_user_home'] = "/home/#{node['etherpad-lite']['service_user']}" +default['etherpad-lite']['service_name'] = node['etherpad-lite']['service_user'] +default['etherpad-lite']['log_level'] = "INFO" +default['etherpad-lite']['logs_dir'] = "#{node['etherpad-lite']['service_user_home']}/etherpad-lite/log" -default['etherpad-lite']['etherpad_git_repo_url'] = 'git://github.com/ether/etherpad-lite.git' -default['etherpad-lite']['etherpad_api_key'] = '' +default['etherpad-lite']['proxy_server'] = "nginx" default['etherpad-lite']['plugins'] = [] diff --git a/metadata.rb b/metadata.rb index fa3369d..807eb55 100644 --- a/metadata.rb +++ b/metadata.rb @@ -7,8 +7,11 @@ version '0.1.2' depends 'nodejs' -depends 'postgresql' depends 'npm' + +depends 'postgresql' + depends 'nginx' +depends 'apache2' # Check README.md for attributes diff --git a/recipes/default.rb b/recipes/default.rb index 921c2c3..7eb2cf9 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -31,8 +31,6 @@ end node.set['nodejs']['install_method'] = 'package' -include_recipe "nodejs" - user = node['etherpad-lite']['service_user'] group = node['etherpad-lite']['service_user_gid'] @@ -57,11 +55,14 @@ :ssl_enabled => node['etherpad-lite']['ssl_enabled'], :ssl_key_path => node['etherpad-lite']['ssl_key_path'], :ssl_cert_path => node['etherpad-lite']['ssl_cert_path'], + :db_type => node['etherpad-lite']['db_type'], - :db_user => node['etherpad-lite']['db_user'], :db_host => node['etherpad-lite']['db_host'], + :db_port => node['etherpad-lite']['db_port'], + :db_user => node['etherpad-lite']['db_user'], :db_password => node['etherpad-lite']['db_password'], :db_name => node['etherpad-lite']['db_name'], + :default_text => node['etherpad-lite']['default_text'], :require_session => node['etherpad-lite']['require_session'], :edit_only => node['etherpad-lite']['edit_only'], @@ -70,8 +71,10 @@ :abiword_path => node['etherpad-lite']['abiword_path'], :require_authentication => node['etherpad-lite']['require_authentication'], :require_authorization => node['etherpad-lite']['require_authorization'], + :admin_enabled => node['etherpad-lite']['admin_enabled'], :admin_password => node['etherpad-lite']['admin_password'], + :log_level => node['etherpad-lite']['log_level'] }) end @@ -90,8 +93,7 @@ node_modules = project_path + "/node_modules" - -# Make Nginx log dirs +# Make log dirs log_dir = node['etherpad-lite']['logs_dir'] access_log = log_dir + '/access.log' error_log = log_dir + '/error.log' @@ -109,8 +111,9 @@ }) end -# Nginx config file -template node['nginx']['dir'] + "/sites-enabled/etherpad.conf" do +if node['etherpad-lite']['proxy_server'] == 'ngnix' + # Nginx config file + template node['nginx']['dir'] + "/sites-enabled/etherpad.conf" do source "nginx.conf.erb" owner node['nginx']['user'] group node['nginx']['group'] @@ -124,6 +127,15 @@ }) notifies :restart, "service[nginx]" action :create + end +elsif node['etherpad-lite']['proxy_server'] == 'apache' + web_app node['etherpad-lite']['service_name'] do + enable true + + server_name node['etherpad-lite']['domain'] + proxy_ip node['etherpad-lite']['ip_address'] + proxy_port node['etherpad-lite']['port_number'] + end end directory log_dir do @@ -134,14 +146,14 @@ end # Make service log file -file access_log do +file access_log do owner user group group action :create_if_missing # see actions section below end # Make service log file -file error_log do +file error_log do owner user group group action :create_if_missing # see actions section below diff --git a/templates/default/nginx.conf.erb b/templates/default/nginx.conf.erb index f24e0f2..c97b28a 100644 --- a/templates/default/nginx.conf.erb +++ b/templates/default/nginx.conf.erb @@ -1,7 +1,6 @@ # Based on https://github.com/ether/etherpad-lite/wiki/How-to-put-Etherpad-Lite-behind-a-reverse-Proxy server { - listen <%= @ssl_enabled ? 443 : 80 %>; server_name <%= @domain %>; access_log <%= @access_log %>; diff --git a/templates/default/upstart.conf.erb b/templates/default/upstart.conf.erb index ddbc813..3bbe747 100644 --- a/templates/default/upstart.conf.erb +++ b/templates/default/upstart.conf.erb @@ -1,7 +1,7 @@ -console log - # From https://github.com/ether/etherpad-lite/wiki/How-to-deploy-Etherpad-Lite-as-a-service +console log + description "etherpad-lite" start on started networking @@ -17,4 +17,4 @@ script exec su -s /bin/sh -c 'exec "$0" "$@"' $EPUSER -- node node_modules/ep_etherpad-lite/node/server.js \ >> <%= @etherpad_access_log %> \ 2>> <%= @etherpad_error_log %> -end script \ No newline at end of file +end script diff --git a/templates/default/web_app.conf.erb b/templates/default/web_app.conf.erb new file mode 100644 index 0000000..d92b81e --- /dev/null +++ b/templates/default/web_app.conf.erb @@ -0,0 +1,21 @@ +# Based on https://github.com/ether/etherpad-lite/wiki/How-to-put-Etherpad-Lite-behind-a-reverse-Proxy + + + ServerName <%= @params[:server_name] %> + + RewriteEngine On + ProxyPreserveHost On + + ProxyVia On + ProxyRequests Off + ProxyPass / http://<%= "#{@params[:proxy_ip]}:#{@params[:proxy_port]}/" %> + ProxyPassReverse / http://<%= "#{@params[:proxy_ip]}:#{@params[:proxy_port]}/" %> + ProxyPreserveHost on + + Options FollowSymLinks MultiViews + AllowOverride All + Order allow,deny + allow from all + + + From 4a9e72e90edbdcf98a305c3cf977395ac8ca976f Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Sun, 11 May 2014 15:46:15 +0000 Subject: [PATCH 02/10] Fix nginx and upstart templates --- attributes/default.rb | 13 +++-- recipes/default.rb | 29 ++++++----- templates/default/settings.json.erb | 75 +++++++++++++++-------------- templates/default/upstart.conf.erb | 4 +- 4 files changed, 65 insertions(+), 56 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 03cd917..c1ce295 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -14,6 +14,7 @@ default['etherpad-lite']['title'] = "Etherpad" default['etherpad-lite']['favicon_url'] = "favicon.ico" +default['etherpad-lite']['default_text'] = "Welcome to Etherpad!\\n\\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\\n\\nGet involved with Etherpad at http:\/\/etherpad.org\\n" default['etherpad-lite']['domain'] = "example.com" default['etherpad-lite']['ip_address'] = "0.0.0.0" @@ -34,15 +35,16 @@ default['etherpad-lite']['admin_enabled'] = false default['etherpad-lite']['admin_password'] = "" -default['etherpad-lite']['default_text'] = "Welcome to Etherpad!\\n\\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\\n\\nGet involved with Etherpad at http:\/\/etherpad.org\\n" - default['etherpad-lite']['require_session'] = "false" +default['etherpad-lite']['require_authentication'] = "false" +default['etherpad-lite']['require_authorization'] = "false" default['etherpad-lite']['edit_only'] = "false" + +default['etherpad-lite']['abiword_path'] = "/usr/bin/abiword" + default['etherpad-lite']['minify'] = "true" default['etherpad-lite']['max_age'] = 21600 # // 60 * 60 * 6 = 6 hours -default['etherpad-lite']['abiword_path'] = "null" -default['etherpad-lite']['require_authentication'] = "false" -default['etherpad-lite']['require_authorization'] = "false" +default['etherpad-lite']['socketTransportProtocols'] = ["websocket", "xhr-polling", "jsonp-polling", "htmlfile"], default['etherpad-lite']['service_user'] = 'etherpad' default['etherpad-lite']['service_user_gid'] = node['etherpad-lite']['service_user'] @@ -54,4 +56,5 @@ default['etherpad-lite']['proxy_server'] = "nginx" + default['etherpad-lite']['plugins'] = [] diff --git a/recipes/default.rb b/recipes/default.rb index 7eb2cf9..b259897 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -49,9 +49,12 @@ variables({ :title => node['etherpad-lite']['title'], :favicon_url => node['etherpad-lite']['favicon_url'], + :default_text => node['etherpad-lite']['default_text'], + :ip_address => node['etherpad-lite']['ip_address'], :port_number => node['etherpad-lite']['port_number'], :session_key => node['etherpad-lite']['session_key'], + :ssl_enabled => node['etherpad-lite']['ssl_enabled'], :ssl_key_path => node['etherpad-lite']['ssl_key_path'], :ssl_cert_path => node['etherpad-lite']['ssl_cert_path'], @@ -63,19 +66,21 @@ :db_password => node['etherpad-lite']['db_password'], :db_name => node['etherpad-lite']['db_name'], - :default_text => node['etherpad-lite']['default_text'], :require_session => node['etherpad-lite']['require_session'], + :require_authentication => node['etherpad-lite']['require_authentication'], + :require_authorization => node['etherpad-lite']['require_authorization'], :edit_only => node['etherpad-lite']['edit_only'], + + :abiword_path => node['etherpad-lite']['abiword_path'], + :minify => node['etherpad-lite']['minify'], :max_age => node['etherpad-lite']['max_age'], - :abiword_path => node['etherpad-lite']['abiword_path'], - :require_authentication => node['etherpad-lite']['require_authentication'], - :require_authorization => node['etherpad-lite']['require_authorization'], + :socketTransportProtocols => node['etherpad-lite']['socketTransportProtocols'], :admin_enabled => node['etherpad-lite']['admin_enabled'], :admin_password => node['etherpad-lite']['admin_password'], - :log_level => node['etherpad-lite']['log_level'] + :log_level => node['etherpad-lite']['log_level'], }) end @@ -95,25 +100,25 @@ # Make log dirs log_dir = node['etherpad-lite']['logs_dir'] -access_log = log_dir + '/access.log' -error_log = log_dir + '/error.log' +log_file = "#{log_dir}/etherpad.log" +access_log = "#{log_dir}/access.log" +error_log = "#{log_dir}/error.log" # Upstart service config file -template "/etc/init/" + node['etherpad-lite']['service_name'] + ".conf" do +template "/etc/init/#{node['etherpad-lite']['service_name']}.conf" do source "upstart.conf.erb" owner user group group variables({ :etherpad_installation_dir => project_path, :etherpad_service_user => user, - :etherpad_access_log => access_log, - :etherpad_error_log => error_log, + :etherpad_log => log_file, }) end -if node['etherpad-lite']['proxy_server'] == 'ngnix' +if node['etherpad-lite']['proxy_server'] == 'nginx' # Nginx config file - template node['nginx']['dir'] + "/sites-enabled/etherpad.conf" do + template "#{node['nginx']['dir']}/sites-enabled/#{node['etherpad-lite']['service_name']}" do source "nginx.conf.erb" owner node['nginx']['user'] group node['nginx']['group'] diff --git a/templates/default/settings.json.erb b/templates/default/settings.json.erb index d5fcd3e..efdf783 100644 --- a/templates/default/settings.json.erb +++ b/templates/default/settings.json.erb @@ -5,91 +5,94 @@ */ { // Name your instance! - "title": "<%= @title %>", + "title": <%= @title.to_json %>, // favicon default name // alternatively, set up a fully specified Url to your own favicon - "favicon": "<%= @favicon_url %>", - + "favicon": <%= @favicon_url.to_json %>, + //IP and port which etherpad should bind at - "ip": "<%= @ip_address %>", - "port" : <%= @port_number %>, + "ip": <%= @ip_address.to_json %>, + "port" : <%= @port_number.to_json %>, // Session Key, used for reconnecting user sessions // Set this to a secure string at least 10 characters long. Do not share this value. - "sessionKey" : "<%= @session_key %>", + "sessionKey" : <%= @session_key.to_json %>, - <% if :ssl_enabled == true -%> + <% if @ssl_enabled == true -%> // Node native SSL support // this is disabled by default // // make sure to have the minimum and correct file access permissions set // so that the Etherpad server can access them "ssl" : { - "key" : "<%= @ssl_key_path %>", - "cert" : "<%= @ssl_cert_path %>" + "key" : <%= @ssl_key_path.to_json %>, + "cert" : <%= @ssl_cert_path.to_json %> }, <% end -%> //The Type of the database. You can choose between dirty, postgres, sqlite and mysql //You shouldn't use "dirty" for for anything else than testing or development - "dbType" : "<%= @db_type %>", + "dbType" : <%= @db_type.to_json %>, //the database specific settings "dbSettings" : { - "user" : "<%= @db_user %>", - "host" : "<%= @db_host %>", - "password": "<%= @db_password %>", - "database": "<%= @db_name %>" + "user" : <%= @db_user.to_json %>, + "password": <%= @db_password.to_json %>, + "host" : <%= @db_host.to_json %>, + "port" : <%= @db_port.to_json %>, + "database": <%= @db_name.to_json %> }, - + //Logging configuration. See log4js documentation for further information // https://github.com/nomiddlename/log4js-node "logconfig" : { "appenders": [ { "type": "console" } ] }, - + //the default text of a pad - "defaultPadText" : "<%= @default_text %>", - + "defaultPadText" : <%= @default_text.to_json %>, + /* Users must have a session to access pads. This effectively allows only group pads to be accessed. */ - "requireSession" : <%= @require_session %>, + "requireSession" : <%= @require_session.to_json %>, /* Users may edit pads but not create new ones. Pad creation is only via the API. This applies both to group pads and regular pads. */ - "editOnly" : <%= @edit_only %>, - + "editOnly" : <%= @edit_only.to_json %>, + /* if true, all css & js will be minified before sending to the client. This will improve the loading performance massivly, but makes it impossible to debug the javascript/css */ - "minify" : <%= @minify %>, + "minify" : <%= @minify.to_json %>, /* How long may clients use served javascript code (in seconds)? Without versioning this may cause problems during deployment. Set to 0 to disable caching */ - "maxAge" : <%= @max_age %>, // 60 * 60 * 6 = 6 hours - + "maxAge" : <%= @max_age.to_json %>, // 60 * 60 * 6 = 6 hours + /* This is the path to the Abiword executable. Setting it to null, disables abiword. Abiword is needed to advanced import/export features of pads*/ - "abiword" : "<%= @abiword_path %>", - + "abiword" : <%= @abiword_path.to_json %>, + /* This setting is used if you require authentication of all users. Note: /admin always requires authentication. */ - "requireAuthentication": <%= @require_authentication %>, + "requireAuthentication": <%= @require_authentication.to_json %>, /* Require authorization by a module, or a user with is_admin set, see below. */ - "requireAuthorization": <%= @require_authorization %>, + "requireAuthorization": <%= @require_authorization.to_json %>, /* Users for basic authentication. is_admin = true gives access to /admin. If you do not uncomment this, /admin will not be available! */ - "users": { - "admin": { - "password": "<%= @admin_password %>", - "is_admin": true - } - }, + <% if @admin_enabled %> + "users": { + "admin": { + "password": <%= @admin_password.to_json %>, + "is_admin": true + } + }, + <% end %> /* The log level we are using, can be: DEBUG, INFO, WARN, ERROR */ - "loglevel": "<%= @log_level %>", + "loglevel": <%= @log_level.to_json %>, // restrict socket.io transport methods - "socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"] + "socketTransportProtocols" : <%= @socketTransportProtocols.to_json %>, } diff --git a/templates/default/upstart.conf.erb b/templates/default/upstart.conf.erb index 3bbe747..3967eb2 100644 --- a/templates/default/upstart.conf.erb +++ b/templates/default/upstart.conf.erb @@ -14,7 +14,5 @@ respawn script cd $EPHOME/ - exec su -s /bin/sh -c 'exec "$0" "$@"' $EPUSER -- node node_modules/ep_etherpad-lite/node/server.js \ - >> <%= @etherpad_access_log %> \ - 2>> <%= @etherpad_error_log %> + exec su -s /bin/sh -c 'exec "$0" "$@"' $EPUSER -- bin/safeRun.sh <%= @etherpad_log %> end script From 54c3fea9bdef1a2ecf9cbdcb3d034e0d89349059 Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Sun, 11 May 2014 16:12:53 +0000 Subject: [PATCH 03/10] Fix errrors on configuration file --- attributes/default.rb | 12 +++++------ recipes/default.rb | 2 +- templates/default/settings.json.erb | 31 +++++++++++++++-------------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index c1ce295..8dab12a 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -35,16 +35,16 @@ default['etherpad-lite']['admin_enabled'] = false default['etherpad-lite']['admin_password'] = "" -default['etherpad-lite']['require_session'] = "false" -default['etherpad-lite']['require_authentication'] = "false" -default['etherpad-lite']['require_authorization'] = "false" -default['etherpad-lite']['edit_only'] = "false" +default['etherpad-lite']['require_session'] = false +default['etherpad-lite']['require_authentication'] = false +default['etherpad-lite']['require_authorization'] = false +default['etherpad-lite']['edit_only'] = false default['etherpad-lite']['abiword_path'] = "/usr/bin/abiword" -default['etherpad-lite']['minify'] = "true" +default['etherpad-lite']['minify'] = true default['etherpad-lite']['max_age'] = 21600 # // 60 * 60 * 6 = 6 hours -default['etherpad-lite']['socketTransportProtocols'] = ["websocket", "xhr-polling", "jsonp-polling", "htmlfile"], +default['etherpad-lite']['socketTransportProtocols'] = ["websocket", "xhr-polling", "jsonp-polling", "htmlfile"] default['etherpad-lite']['service_user'] = 'etherpad' default['etherpad-lite']['service_user_gid'] = node['etherpad-lite']['service_user'] diff --git a/recipes/default.rb b/recipes/default.rb index b259897..8822d3e 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -202,5 +202,5 @@ # Register capture app as a service service node['etherpad-lite']['service_name'] do provider Chef::Provider::Service::Upstart - action :start + action :restart end diff --git a/templates/default/settings.json.erb b/templates/default/settings.json.erb index efdf783..b1135a5 100644 --- a/templates/default/settings.json.erb +++ b/templates/default/settings.json.erb @@ -40,17 +40,12 @@ "user" : <%= @db_user.to_json %>, "password": <%= @db_password.to_json %>, "host" : <%= @db_host.to_json %>, + <% if @db_port %> "port" : <%= @db_port.to_json %>, + <% end %> "database": <%= @db_name.to_json %> }, - //Logging configuration. See log4js documentation for further information - // https://github.com/nomiddlename/log4js-node - "logconfig" : -{ "appenders": [ -{ "type": "console" } -] }, - //the default text of a pad "defaultPadText" : <%= @default_text.to_json %>, @@ -82,17 +77,23 @@ /* Users for basic authentication. is_admin = true gives access to /admin. If you do not uncomment this, /admin will not be available! */ <% if @admin_enabled %> - "users": { - "admin": { - "password": <%= @admin_password.to_json %>, - "is_admin": true - } - }, + "users": { + "admin": { + "password": <%= @admin_password.to_json %>, + "is_admin": true + } + }, <% end %> + // restrict socket.io transport methods + "socketTransportProtocols" : <%= @socketTransportProtocols.to_json %>, + /* The log level we are using, can be: DEBUG, INFO, WARN, ERROR */ "loglevel": <%= @log_level.to_json %>, - // restrict socket.io transport methods - "socketTransportProtocols" : <%= @socketTransportProtocols.to_json %>, + //Logging configuration. See log4js documentation for further information + // https://github.com/nomiddlename/log4js-node + "logconfig" : { + "appenders": [ { "type": "console" } ] + } } From 71200257f312084aca904b27ab8d28cb902f9508 Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Sun, 11 May 2014 23:25:15 +0000 Subject: [PATCH 04/10] Don't restart pad service every time --- recipes/default.rb | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/recipes/default.rb b/recipes/default.rb index 8822d3e..769ab5d 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -105,19 +105,23 @@ error_log = "#{log_dir}/error.log" # Upstart service config file +service node['etherpad-lite']['service_name'] do + provider Chef::Provider::Service::Upstart + action :enable +end template "/etc/init/#{node['etherpad-lite']['service_name']}.conf" do - source "upstart.conf.erb" - owner user - group group - variables({ - :etherpad_installation_dir => project_path, - :etherpad_service_user => user, - :etherpad_log => log_file, - }) + source "upstart.conf.erb" + owner user + group group + variables({ + :etherpad_installation_dir => project_path, + :etherpad_service_user => user, + :etherpad_log => log_file, + }) + notifies :restart, "service[#{node['etherpad-lite']['service_name']}]" end if node['etherpad-lite']['proxy_server'] == 'nginx' - # Nginx config file template "#{node['nginx']['dir']}/sites-enabled/#{node['etherpad-lite']['service_name']}" do source "nginx.conf.erb" owner node['nginx']['user'] @@ -130,7 +134,7 @@ :access_log => access_log, :error_log => error_log, }) - notifies :restart, "service[nginx]" + notifies :reload, "service[nginx]" action :create end elsif node['etherpad-lite']['proxy_server'] == 'apache' @@ -141,6 +145,7 @@ proxy_ip node['etherpad-lite']['ip_address'] proxy_port node['etherpad-lite']['port_number'] end + notifies :reload, "service[apache2]" end directory log_dir do @@ -199,8 +204,3 @@ end end -# Register capture app as a service -service node['etherpad-lite']['service_name'] do - provider Chef::Provider::Service::Upstart - action :restart -end From 6c962eb47a8adad9685ae05b38c1120fc6a03f4c Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Wed, 14 May 2014 03:15:52 +0000 Subject: [PATCH 05/10] Improve reverse proxy with remote address --- templates/default/nginx.conf.erb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/templates/default/nginx.conf.erb b/templates/default/nginx.conf.erb index c97b28a..aed56b2 100644 --- a/templates/default/nginx.conf.erb +++ b/templates/default/nginx.conf.erb @@ -19,10 +19,12 @@ server { <% end -%> location / { - proxy_pass http://localhost:<%= @internal_port %>/; - proxy_set_header Host $host; - # be carefull, this line doesn't override any proxy_buffering on set in a conf.d/file.conf - proxy_buffering off; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header Host $host; + proxy_pass http://localhost:<%= @internal_port %>/; + # be carefull, this line doesn't override any proxy_buffering on set in a conf.d/file.conf + proxy_buffering off; } } From ea05da2622833eabc62bbabdb779fa3a1da5e9bd Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Wed, 21 May 2014 22:00:35 -0300 Subject: [PATCH 06/10] Set default port --- templates/default/nginx.conf.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/default/nginx.conf.erb b/templates/default/nginx.conf.erb index aed56b2..c0cba21 100644 --- a/templates/default/nginx.conf.erb +++ b/templates/default/nginx.conf.erb @@ -1,6 +1,7 @@ # Based on https://github.com/ether/etherpad-lite/wiki/How-to-put-Etherpad-Lite-behind-a-reverse-Proxy server { + listen <%= node[:nginx][:listen_ports].first %>; server_name <%= @domain %>; access_log <%= @access_log %>; From 640a22504ad28dcebcde4ef231ac98bbc5533d48 Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Fri, 30 May 2014 20:24:22 -0300 Subject: [PATCH 07/10] Fix abiword disable, manage user and db and support git submodules --- README.md | 28 +++-- attributes/default.rb | 25 ++-- metadata.rb | 1 + recipes/default.rb | 179 ++++++++++++++-------------- templates/default/settings.json.erb | 2 +- 5 files changed, 121 insertions(+), 114 deletions(-) diff --git a/README.md b/README.md index 02d1be1..744e84b 100644 --- a/README.md +++ b/README.md @@ -18,37 +18,43 @@ Attributes The following attributes should be set based on your specific deployment, see the `attributes/default.rb` file for default values. All values should be strings unless otherwise specified. +* `node['etherpad-lite']['service_name']` = Name of service +* `node['etherpad-lite']['service_user']` - user to run etherpad +* `node['etherpad-lite']['service_user_group']` - group to run etherpad +* `node['etherpad-lite']['service_user_home']`- home dir +* `node['etherpad-lite']['etherpad_git_repo_url']` = set this to the git repo of your fork of etherpad-lite, or leave as default +* `node['etherpad-lite']['etherpad_api_key']` = sets the API key for the HTTP API (APIKEY.txt), if you leave it blank it will be generated for you by the app on first launch +* `node['etherpad-lite']['logs_dir']` = Path to logs directory + * `node['etherpad-lite']['title']` - Name your instance! * `node['etherpad-lite']['favicon_url']` - favicon_url favicon default name, alternatively, set up a fully specified Url to your own favicon +* `node['etherpad-lite']['default_text']` - the default text of a pad + +* `node['etherpad-lite']['domain']` = Domain where it is running * `node['etherpad-lite']['ip_address']` - IP address to bind * `node['etherpad-lite']['port_number']` - (number) port number to bind + * `node['etherpad-lite']['ssl_enabled']` - (boolean) make sure to have the minimum and correct file access permissions set so that the Etherpad server can access them * `node['etherpad-lite']['ssl_key_path']` - ssl key path * `node['etherpad-lite']['ssl_cert_path']` - ssl cert path + * `node['etherpad-lite']['db_type']` - postgres, sqlite or mysql * `node['etherpad-lite']['db_user']` - db user * `node['etherpad-lite']['db_host']` - db host * `node['etherpad-lite']['db_password']` - db password * `node['etherpad-lite']['db_name']` - db name -* `node['etherpad-lite']['default_text']` - the default text of a pad + * `node['etherpad-lite']['require_session']` - (boolean) Users must have a session to access pads. This effectively allows only group pads to be accessed. * `node['etherpad-lite']['edit_only']` - (boolean) Users may edit pads but not create new ones. Pad creation is only via the API. This applies both to group pads and regular pads. * `node['etherpad-lite']['minify']` - if true, all css & js will be minified before sending to the client. This will improve the loading performance massivly, but makes it impossible to debug the javascript/css * `node['etherpad-lite']['max_age']` - How long may clients use served javascript code (in seconds)? Without versioning this may cause problems during deployment. Set to 0 to disable caching -* `node['etherpad-lite']['abiword_path']` - This is the path to the Abiword executable. Setting it to null, disables abiword. Abiword is needed to advanced import/export features of pads +* `node['etherpad-lite']['use_abiword']` - Set to false to disable. Default is true +* `node['etherpad-lite']['abiword_path']` - This is the path to the Abiword executable. Abiword is needed to advanced import/export features of pads * `node['etherpad-lite']['require_authentication']` - This setting is used if you require authentication of all users. Note: /admin always requires authentication. * `node['etherpad-lite']['require_authorization']` - Require authorization by a module, or a user with is_admin set, see below. * `node['etherpad-lite']['admin_enabled']` - Enable the admin interface * `node['etherpad-lite']['admin_password']` - Password for "admin" user. * `node['etherpad-lite']['log_level']` - The log level we are using, can be: DEBUG, INFO, WARN, ERROR -* `node['etherpad-lite']['service_user']` - user to run etherpad -* `node['etherpad-lite']['service_user_gid']` - group to run etherpad -* `node['etherpad-lite']['service_user_home']`- home dir -* `node['etherpad-lite']['etherpad_git_repo_url']` = set this to the git repo of your fork of etherpad-lite, or leave as default -* `node['etherpad-lite']['etherpad_api_key']` = sets the API key for the HTTP API (APIKEY.txt), if you leave it blank it will be generated for you by the app on first launch -* `node['etherpad-lite']['service_name']` = Name of service -* `node['etherpad-lite']['logs_dir']` = Path to logs directory -* `node['etherpad-lite']['domain']` = Domain where it is running * `node['etherpad-lite']['plugins']` = An array of plugins to install. These should be strings of the plugin name, without the ep_ prefix (as seen in the etherpad-lite admin's plugin manager). Usage @@ -88,4 +94,4 @@ Authors: * OpenWatch FPC * @computerlyrik original version (https://github.com/computerlyrik/chef-etherpad) -* @reidab \ No newline at end of file +* @reidab diff --git a/attributes/default.rb b/attributes/default.rb index 8dab12a..cd519b1 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -9,6 +9,17 @@ # Defaults based on https://github.com/ether/etherpad-lite/blob/develop/settings.json.template +default['etherpad-lite']['service_name'] = node['etherpad-lite']['service_user'] +default['etherpad-lite']['service_user'] = 'etherpad' +default['etherpad-lite']['service_group'] = node['etherpad-lite']['service_user'] + +default['etherpad-lite']['service_user_home'] = "/home/#{node['etherpad-lite']['service_user']}" +default['etherpad-lite']['project_path'] = "#{node['etherpad-lite']['service_user_home']}/etherpad-lite" +default['etherpad-lite']['node_modules'] = "#{node['etherpad-lite']['project_path']}/node_modules" + +default['etherpad-lite']['log_level'] = "INFO" +default['etherpad-lite']['logs_dir'] = "#{node['etherpad-lite']['service_user_home']}/etherpad-lite/log" + default['etherpad-lite']['etherpad_git_repo_url'] = 'git://github.com/ether/etherpad-lite.git' default['etherpad-lite']['etherpad_api_key'] = '' @@ -25,6 +36,8 @@ default['etherpad-lite']['ssl_key_path'] = "" default['etherpad-lite']['ssl_cert_path'] = "" +default['etherpad-lite']['proxy_server'] = "nginx" + default['etherpad-lite']['db_type'] = "postgres" default['etherpad-lite']['db_user'] = "postgres" default['etherpad-lite']['db_host'] = "localhost" @@ -40,21 +53,11 @@ default['etherpad-lite']['require_authorization'] = false default['etherpad-lite']['edit_only'] = false +default['etherpad-lite']['use_abiword'] = true default['etherpad-lite']['abiword_path'] = "/usr/bin/abiword" default['etherpad-lite']['minify'] = true default['etherpad-lite']['max_age'] = 21600 # // 60 * 60 * 6 = 6 hours default['etherpad-lite']['socketTransportProtocols'] = ["websocket", "xhr-polling", "jsonp-polling", "htmlfile"] -default['etherpad-lite']['service_user'] = 'etherpad' -default['etherpad-lite']['service_user_gid'] = node['etherpad-lite']['service_user'] -default['etherpad-lite']['service_user_home'] = "/home/#{node['etherpad-lite']['service_user']}" -default['etherpad-lite']['service_name'] = node['etherpad-lite']['service_user'] - -default['etherpad-lite']['log_level'] = "INFO" -default['etherpad-lite']['logs_dir'] = "#{node['etherpad-lite']['service_user_home']}/etherpad-lite/log" - -default['etherpad-lite']['proxy_server'] = "nginx" - - default['etherpad-lite']['plugins'] = [] diff --git a/metadata.rb b/metadata.rb index 807eb55..d690d2c 100644 --- a/metadata.rb +++ b/metadata.rb @@ -10,6 +10,7 @@ depends 'npm' depends 'postgresql' +depends 'database' depends 'nginx' depends 'apache2' diff --git a/recipes/default.rb b/recipes/default.rb index 769ab5d..62355e8 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -18,6 +18,18 @@ # limitations under the License. # +service_user = node['etherpad-lite']['service_user'] +service_group = node['etherpad-lite']['service_group'] +user_home = node['etherpad-lite']['service_user_home'] +project_path = node['etherpad-lite']['project_path'] + +node_modules = node['etherpad-lite']['node_modules'] +log_dir = node['etherpad-lite']['logs_dir'] +log_file = "#{log_dir}/etherpad.log" +access_log = "#{log_dir}/access.log" +error_log = "#{log_dir}/error.log" + +# System deps case node['platform_family'] when "debian", "ubuntu" packages = %w{gzip git-core curl python libssl-dev pkg-config build-essential} @@ -25,101 +37,108 @@ packages = %w{gzip git-core curl python openssl-devel} # && yum groupinstall "Development Tools" end - +packages << 'abiword' if node['etherpad-lite']['use_abiword'] packages.each do |p| package p end -node.set['nodejs']['install_method'] = 'package' - -user = node['etherpad-lite']['service_user'] -group = node['etherpad-lite']['service_user_gid'] -user_home = node['etherpad-lite']['service_user_home'] -project_path = "#{user_home}/etherpad-lite" +# User/group +group service_group do + action :create +end +user service_user do + supports :manage_home => true + home user_home + gid service_group + action :create +end +# Code and directories git project_path do + user service_user; group service_group repository node['etherpad-lite']['etherpad_git_repo_url'] + enable_submodules true action :sync - user user end -template "#{project_path}/settings.json" do - owner user - group group - variables({ - :title => node['etherpad-lite']['title'], - :favicon_url => node['etherpad-lite']['favicon_url'], - :default_text => node['etherpad-lite']['default_text'], - - :ip_address => node['etherpad-lite']['ip_address'], - :port_number => node['etherpad-lite']['port_number'], - :session_key => node['etherpad-lite']['session_key'], - - :ssl_enabled => node['etherpad-lite']['ssl_enabled'], - :ssl_key_path => node['etherpad-lite']['ssl_key_path'], - :ssl_cert_path => node['etherpad-lite']['ssl_cert_path'], - - :db_type => node['etherpad-lite']['db_type'], - :db_host => node['etherpad-lite']['db_host'], - :db_port => node['etherpad-lite']['db_port'], - :db_user => node['etherpad-lite']['db_user'], - :db_password => node['etherpad-lite']['db_password'], - :db_name => node['etherpad-lite']['db_name'], - - :require_session => node['etherpad-lite']['require_session'], - :require_authentication => node['etherpad-lite']['require_authentication'], - :require_authorization => node['etherpad-lite']['require_authorization'], - :edit_only => node['etherpad-lite']['edit_only'], - - :abiword_path => node['etherpad-lite']['abiword_path'], - - :minify => node['etherpad-lite']['minify'], - :max_age => node['etherpad-lite']['max_age'], - :socketTransportProtocols => node['etherpad-lite']['socketTransportProtocols'], - - :admin_enabled => node['etherpad-lite']['admin_enabled'], - :admin_password => node['etherpad-lite']['admin_password'], +# Log dir +directory log_dir do + owner service_user; group service_group + recursive true + action :create +end +# Make service log file +file access_log do + owner service_user; group service_group + action :create_if_missing +end +# Make service log file +file error_log do + owner service_user; group service_group + action :create_if_missing +end - :log_level => node['etherpad-lite']['log_level'], - }) +# Settings +template "#{project_path}/settings.json" do + owner user; group group + variables node['etherpad-lite'] end -etherpad_api_key = node['etherpad-lite']['etherpad_api_key'] +# API KEY +template "#{project_path}/APIKEY.txt" do + owner service_user; group service_group + variables node['etherpad-lite'] +end if not node['etherpad-lite'][:etherpad_api_key].empty? -if etherpad_api_key != '' - template "#{project_path}/APIKEY.txt" do - owner user - group group - variables({ - :etherpad_api_key => etherpad_api_key - }) +# Database +if Chef::Config[:solo] + if node['etherpad-lite'][:db_password].nil? + Chef::Application.fatal! "The db password is necessary when using Chef::Solo" end +else + node.set_unless['etherpad-lite'][:db_password] = secure_password + node.save end -node_modules = project_path + "/node_modules" +postgresql_connection = { + :host => '127.0.0.1', + :port => node[:postgresql][:config][:port], + :username => 'postgres', + :password => node[:postgresql][:password][:postgres], +} -# Make log dirs -log_dir = node['etherpad-lite']['logs_dir'] -log_file = "#{log_dir}/etherpad.log" -access_log = "#{log_dir}/access.log" -error_log = "#{log_dir}/error.log" +postgresql_database_user node['etherpad-lite'][:db_user] do + connection postgresql_connection + password node['etherpad-lite'][:db_password] + action :create +end +postgresql_database node['etherpad-lite'][:db_name] do + connection postgresql_connection + action :create +end +postgresql_database_user node['etherpad-lite'][:db_user] do + connection postgresql_connection + password node['etherpad-lite'][:db_password] + database_name node['etherpad-lite'][:db_name] + action :grant +end # Upstart service config file -service node['etherpad-lite']['service_name'] do - provider Chef::Provider::Service::Upstart - action :enable -end template "/etc/init/#{node['etherpad-lite']['service_name']}.conf" do + owner service_user; group service_group source "upstart.conf.erb" - owner user - group group variables({ :etherpad_installation_dir => project_path, - :etherpad_service_user => user, + :etherpad_service_user => service_user, :etherpad_log => log_file, }) + action :create notifies :restart, "service[#{node['etherpad-lite']['service_name']}]" end +service node['etherpad-lite']['service_name'] do + provider Chef::Provider::Service::Upstart + action :enable +end if node['etherpad-lite']['proxy_server'] == 'nginx' template "#{node['nginx']['dir']}/sites-enabled/#{node['etherpad-lite']['service_name']}" do @@ -148,30 +167,9 @@ notifies :reload, "service[apache2]" end -directory log_dir do - owner user - group group - recursive true - action :create -end - -# Make service log file -file access_log do - owner user - group group - action :create_if_missing # see actions section below -end - -# Make service log file -file error_log do - owner user - group group - action :create_if_missing # see actions section below -end - ## Install dependencies bash "installdeps" do - user 0 + user "root" cwd project_path code <<-EOH ./bin/installDeps.sh >> #{error_log} @@ -180,8 +178,7 @@ # Create and set permissions for node_modules directory node_modules do - owner user - group group + owner service_user; group service_group mode "770" recursive true action :create diff --git a/templates/default/settings.json.erb b/templates/default/settings.json.erb index b1135a5..1c59d9a 100644 --- a/templates/default/settings.json.erb +++ b/templates/default/settings.json.erb @@ -65,7 +65,7 @@ /* This is the path to the Abiword executable. Setting it to null, disables abiword. Abiword is needed to advanced import/export features of pads*/ - "abiword" : <%= @abiword_path.to_json %>, + "abiword" : <%= if @use_abiword then @abiword_path.to_json else nil.to_json end %>, /* This setting is used if you require authentication of all users. Note: /admin always requires authentication. */ From a04b82e01e34e893a49bef125cb6756e11fce909 Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Wed, 10 Sep 2014 18:09:17 -0300 Subject: [PATCH 08/10] Remove old json metadata --- metadata.json | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 metadata.json diff --git a/metadata.json b/metadata.json deleted file mode 100644 index a8d4b28..0000000 --- a/metadata.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "etherpad-lite", - "description": "Installs etherpad-lite", - "long_description": "etherpad-lite Cookbook\n======================\n\n#### etherpad-lite::default\ninstalls etherpad-lite\n\nRequirements\n------------\n#### cookbooks\n- `nodejs` - etherpad-lite runs on javascript\n- `postgresql` - we use postgres\n- `npm` - pg gem needs to be installed\n- `nginx` - Might not be the optimal way to run it\n\nAttributes\n----------\n\nThe following attributes should be set based on your specific deployment, see the\n`attributes/default.rb` file for default values. All values should be strings unless otherwise specified.\n\n* `node['etherpad-lite']['title']` - Name your instance!\n* `node['etherpad-lite']['favicon_url']` - favicon_url favicon default name, alternatively, set up a fully specified Url to your own favicon\n* `node['etherpad-lite']['ip_address']` - IP address to bind\n* `node['etherpad-lite']['port_number']` - (number) port number to bind\n* `node['etherpad-lite']['ssl_enabled']` - (boolean) make sure to have the minimum and correct file access permissions set so that the Etherpad server can access them\n* `node['etherpad-lite']['ssl_key_path']` - ssl key path\n* `node['etherpad-lite']['ssl_cert_path']` - ssl cert path\n* `node['etherpad-lite']['db_type']` - postgres, sqlite or mysql\n* `node['etherpad-lite']['db_user']` - db user\n* `node['etherpad-lite']['db_host']` - db host\n* `node['etherpad-lite']['db_password']` - db password\n* `node['etherpad-lite']['db_name']` - db name\n* `node['etherpad-lite']['default_text']` - the default text of a pad\n* `node['etherpad-lite']['require_session']` - (boolean) Users must have a session to access pads. This effectively allows only group pads to be accessed.\n* `node['etherpad-lite']['edit_only']` - (boolean) Users may edit pads but not create new ones. Pad creation is only via the API. This applies both to group pads and regular pads. \n* `node['etherpad-lite']['minify']` - if true, all css & js will be minified before sending to the client. This will improve the loading performance massivly, but makes it impossible to debug the javascript/css\n* `node['etherpad-lite']['max_age']` - How long may clients use served javascript code (in seconds)? Without versioning this may cause problems during deployment. Set to 0 to disable caching\n* `node['etherpad-lite']['abiword_path']` - This is the path to the Abiword executable. Setting it to null, disables abiword. Abiword is needed to advanced import/export features of pads\n* `node['etherpad-lite']['require_authentication']` - This setting is used if you require authentication of all users. Note: /admin always requires authentication.\n* `node['etherpad-lite']['require_authorization']` - Require authorization by a module, or a user with is_admin set, see below.\n* `node['etherpad-lite']['admin_enabled']` - Enable the admin interface\n* `node['etherpad-lite']['admin_password']` - Password for \"admin\" user.\n* `node['etherpad-lite']['log_level']` - The log level we are using, can be: DEBUG, INFO, WARN, ERROR\n* `node['etherpad-lite']['service_user']` - user to run etherpad\n* `node['etherpad-lite']['service_user_gid']` - group to run etherpad\n* `node['etherpad-lite']['service_user_home']`- home dir\n* `node['etherpad-lite']['etherpad_git_repo_url']` = set this to the git repo of your fork of etherpad-lite, or leave as default\n* `node['etherpad-lite']['etherpad_api_key']` = sets the API key for the HTTP API (APIKEY.txt), if you leave it blank it will be generated for you by the app on first launch\n* `node['etherpad-lite']['service_name']` = Name of service\n* `node['etherpad-lite']['logs_dir']` = Path to logs directory\n* `node['etherpad-lite']['domain']` = Domain where it is running\n\nUsage\n-----\n#### etherpad-lite::default\n\nOverride any defaults and then include the recipe in your run list or cookbook.\n\ne.g.\nJust include `etherpad-lite` in your node's `run_list`:\n\n```json\n{\n \"name\":\"my_node\",\n \"run_list\": [\n \"recipe[etherpad-lite]\"\n ]\n}\n```\n\nContributing\n------------\n\n1. Fork the repository on Github\n2. Create a named feature branch (like `add_component_x`)\n3. Write your change\n4. Write tests for your change (if applicable)\n5. Run the tests, ensuring they all pass\n6. Submit a Pull Request using Github\n\nLicense and Authors\n-------------------\n\nLicense: Apache 2.0\n\nAuthors: \n\n* OpenWatch FPC\n* computerlyrik original version (https://github.com/computerlyrik/chef-etherpad)\n", - "maintainer": "OpenWatch FPC", - "maintainer_email": "chris@openwatch.net", - "license": "Apache 2.0", - "platforms": { - }, - "dependencies": { - "nodejs": ">= 0.0.0", - "postgresql": ">= 0.0.0", - "npm": ">= 0.0.0", - "nginx": ">= 0.0.0" - }, - "recommendations": { - }, - "suggestions": { - }, - "conflicting": { - }, - "providing": { - }, - "replacing": { - }, - "attributes": { - }, - "groupings": { - }, - "recipes": { - }, - "version": "0.1.2" -} \ No newline at end of file From c18ae66e520a59ddbd6638722376de6397658f52 Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Wed, 10 Sep 2014 18:09:32 -0300 Subject: [PATCH 09/10] Fix dependencies install using nodejs cookbook --- metadata.rb | 1 - recipes/default.rb | 28 +++++++--------------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/metadata.rb b/metadata.rb index d690d2c..141ab9a 100644 --- a/metadata.rb +++ b/metadata.rb @@ -7,7 +7,6 @@ version '0.1.2' depends 'nodejs' -depends 'npm' depends 'postgresql' depends 'database' diff --git a/recipes/default.rb b/recipes/default.rb index 62355e8..720837a 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -32,9 +32,9 @@ # System deps case node['platform_family'] when "debian", "ubuntu" - packages = %w{gzip git-core curl python libssl-dev pkg-config build-essential} - when "fedora","centos","rhel" - packages = %w{gzip git-core curl python openssl-devel} + packages = %w[gzip git-core curl python libssl-dev pkg-config build-essential] + when "fedora", "centos", "rhel" + packages = %w[gzip git-core curl python openssl-devel] # && yum groupinstall "Development Tools" end packages << 'abiword' if node['etherpad-lite']['use_abiword'] @@ -42,6 +42,9 @@ package p end +include_recipe 'nodejs' +nodejs_npm 'pg' + # User/group group service_group do action :create @@ -137,7 +140,7 @@ end service node['etherpad-lite']['service_name'] do provider Chef::Provider::Service::Upstart - action :enable + action [:enable, :start] end if node['etherpad-lite']['proxy_server'] == 'nginx' @@ -167,23 +170,6 @@ notifies :reload, "service[apache2]" end -## Install dependencies -bash "installdeps" do - user "root" - cwd project_path - code <<-EOH - ./bin/installDeps.sh >> #{error_log} - EOH -end - -# Create and set permissions for node_modules -directory node_modules do - owner service_user; group service_group - mode "770" - recursive true - action :create -end - # Install plugins unless node['etherpad-lite']['plugins'].empty? node['etherpad-lite']['plugins'].each do |plugin| From 0979b71cff70bd88c197f3b5e2ade9052687c85e Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Thu, 11 Sep 2014 12:21:57 -0300 Subject: [PATCH 10/10] Restart server on settings.json update --- recipes/default.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/default.rb b/recipes/default.rb index 720837a..f626d05 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -85,6 +85,7 @@ template "#{project_path}/settings.json" do owner user; group group variables node['etherpad-lite'] + notifies :restart, "service[#{node['etherpad-lite']['service_name']}]" end # API KEY