diff --git a/.gitignore b/.gitignore index e43b0f9..f31b3e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .DS_Store +*.swp 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 4cbebb1..cd519b1 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -9,42 +9,55 @@ # 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'] = '' + 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" 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']['proxy_server'] = "nginx" + 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']['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" -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']['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']['require_session'] = false +default['etherpad-lite']['require_authentication'] = false +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']['etherpad_git_repo_url'] = 'git://github.com/ether/etherpad-lite.git' -default['etherpad-lite']['etherpad_api_key'] = '' +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']['plugins'] = [] 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 diff --git a/metadata.rb b/metadata.rb index fa3369d..141ab9a 100644 --- a/metadata.rb +++ b/metadata.rb @@ -7,8 +7,11 @@ version '0.1.2' depends 'nodejs' + depends 'postgresql' -depends 'npm' +depends 'database' + depends 'nginx' +depends 'apache2' # Check README.md for attributes diff --git a/recipes/default.rb b/recipes/default.rb index 921c2c3..f626d05 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -18,99 +18,134 @@ # 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} - 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'] packages.each do |p| package p end -node.set['nodejs']['install_method'] = 'package' -include_recipe "nodejs" - +include_recipe 'nodejs' +nodejs_npm 'pg' -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 +# 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 + +# Settings template "#{project_path}/settings.json" do - owner user - group group - variables({ - :title => node['etherpad-lite']['title'], - :favicon_url => node['etherpad-lite']['favicon_url'], - :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_user => node['etherpad-lite']['db_user'], - :db_host => node['etherpad-lite']['db_host'], - :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'], - :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'], - :admin_enabled => node['etherpad-lite']['admin_enabled'], - :admin_password => node['etherpad-lite']['admin_password'], - :log_level => node['etherpad-lite']['log_level'] - }) + owner user; group group + variables node['etherpad-lite'] + notifies :restart, "service[#{node['etherpad-lite']['service_name']}]" 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 Nginx log dirs -log_dir = node['etherpad-lite']['logs_dir'] -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 -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, - }) +template "/etc/init/#{node['etherpad-lite']['service_name']}.conf" do + owner service_user; group service_group + source "upstart.conf.erb" + variables({ + :etherpad_installation_dir => project_path, + :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, :start] end -# Nginx config file -template node['nginx']['dir'] + "/sites-enabled/etherpad.conf" do +if node['etherpad-lite']['proxy_server'] == 'nginx' + template "#{node['nginx']['dir']}/sites-enabled/#{node['etherpad-lite']['service_name']}" do source "nginx.conf.erb" owner node['nginx']['user'] group node['nginx']['group'] @@ -122,47 +157,18 @@ :access_log => access_log, :error_log => error_log, }) - notifies :restart, "service[nginx]" + notifies :reload, "service[nginx]" action :create -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 + end +elsif node['etherpad-lite']['proxy_server'] == 'apache' + web_app node['etherpad-lite']['service_name'] do + enable true -# 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 - cwd project_path - code <<-EOH - ./bin/installDeps.sh >> #{error_log} - EOH -end - -# Create and set permissions for node_modules -directory node_modules do - owner user - group group - mode "770" - recursive true - action :create + server_name node['etherpad-lite']['domain'] + proxy_ip node['etherpad-lite']['ip_address'] + proxy_port node['etherpad-lite']['port_number'] + end + notifies :reload, "service[apache2]" end # Install plugins @@ -182,8 +188,3 @@ end end -# Register capture app as a service -service node['etherpad-lite']['service_name'] do - provider Chef::Provider::Service::Upstart - action :start -end diff --git a/templates/default/nginx.conf.erb b/templates/default/nginx.conf.erb index f24e0f2..c0cba21 100644 --- a/templates/default/nginx.conf.erb +++ b/templates/default/nginx.conf.erb @@ -1,7 +1,7 @@ # Based on https://github.com/ether/etherpad-lite/wiki/How-to-put-Etherpad-Lite-behind-a-reverse-Proxy server { - listen <%= @ssl_enabled ? 443 : 80 %>; + listen <%= node[:nginx][:listen_ports].first %>; server_name <%= @domain %>; access_log <%= @access_log %>; @@ -20,10 +20,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; } } diff --git a/templates/default/settings.json.erb b/templates/default/settings.json.erb index d5fcd3e..1c59d9a 100644 --- a/templates/default/settings.json.erb +++ b/templates/default/settings.json.erb @@ -5,91 +5,95 @@ */ { // 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 %>, + <% 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 %>", - + "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" : <%= 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. */ - "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! */ + <% if @admin_enabled %> "users": { "admin": { - "password": "<%= @admin_password %>", + "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 %>", + "loglevel": <%= @log_level.to_json %>, - // restrict socket.io transport methods - "socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"] + //Logging configuration. See log4js documentation for further information + // https://github.com/nomiddlename/log4js-node + "logconfig" : { + "appenders": [ { "type": "console" } ] + } } diff --git a/templates/default/upstart.conf.erb b/templates/default/upstart.conf.erb index ddbc813..3967eb2 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 @@ -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 %> -end script \ No newline at end of file + exec su -s /bin/sh -c 'exec "$0" "$@"' $EPUSER -- bin/safeRun.sh <%= @etherpad_log %> +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 + + +