From e4be5b4feb9558b01e6cb48225dd6ddbb9c3f28d Mon Sep 17 00:00:00 2001 From: James Allen Date: Mon, 31 Mar 2014 16:41:13 +0100 Subject: [PATCH] Add in TeXLive and imagemagick --- server-ce/Vagrantfile | 1 + .../chef/cookbooks/sharelatex/metadata.rb | 1 + .../cookbooks/sharelatex/providers/app.rb | 9 ++- .../cookbooks/sharelatex/recipes/default.rb | 12 +++- .../cookbooks/sharelatex/resources/app.rb | 2 + server-ce/chef/cookbooks/texlive/CHANGELOG.md | 12 ++++ server-ce/chef/cookbooks/texlive/README.md | 68 +++++++++++++++++++ .../cookbooks/texlive/attributes/default.rb | 2 + server-ce/chef/cookbooks/texlive/metadata.rb | 7 ++ .../chef/cookbooks/texlive/recipes/default.rb | 42 ++++++++++++ 10 files changed, 153 insertions(+), 3 deletions(-) create mode 100644 server-ce/chef/cookbooks/texlive/CHANGELOG.md create mode 100644 server-ce/chef/cookbooks/texlive/README.md create mode 100644 server-ce/chef/cookbooks/texlive/attributes/default.rb create mode 100644 server-ce/chef/cookbooks/texlive/metadata.rb create mode 100644 server-ce/chef/cookbooks/texlive/recipes/default.rb diff --git a/server-ce/Vagrantfile b/server-ce/Vagrantfile index 40fa80750f..0f9f595fce 100644 --- a/server-ce/Vagrantfile +++ b/server-ce/Vagrantfile @@ -21,6 +21,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| chef.add_recipe 'redis-server' chef.add_recipe 'mongodb' chef.add_recipe 'nodejs' + chef.add_recipe 'texlive' chef.add_recipe 'sharelatex' # You may also specify custom JSON attributes: diff --git a/server-ce/chef/cookbooks/sharelatex/metadata.rb b/server-ce/chef/cookbooks/sharelatex/metadata.rb index a6562c6cff..319ee0441b 100644 --- a/server-ce/chef/cookbooks/sharelatex/metadata.rb +++ b/server-ce/chef/cookbooks/sharelatex/metadata.rb @@ -5,3 +5,4 @@ license 'All rights reserved' description 'Installs/Configures sharelatex' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version '0.1.0' +depends 'texlive' diff --git a/server-ce/chef/cookbooks/sharelatex/providers/app.rb b/server-ce/chef/cookbooks/sharelatex/providers/app.rb index 499a58cfb1..42581bb121 100644 --- a/server-ce/chef/cookbooks/sharelatex/providers/app.rb +++ b/server-ce/chef/cookbooks/sharelatex/providers/app.rb @@ -68,6 +68,11 @@ action :start do notifies :restart, "service[#{r.name}]" end + env = "" + r.environment.each do |key, value| + env += "#{key}=#{value} " + end + file "/etc/init/#{r.name}.conf" do content <<-EOS description "#{r.name}" @@ -83,9 +88,11 @@ action :start do script echo $$ > /var/run/#{r.name}.pid chdir #{deploy_to}/current - exec sudo -u #{r.user} env NODE_ENV=#{node_environment} SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee node app.js >> log/production.log + exec sudo -u #{r.user} env NODE_ENV=#{node_environment} SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee #{env} node app.js >> log/production.log 2>&1 end script EOS + + notifies :restart, "service[#{r.name}]" end directory "/etc/sharelatex" diff --git a/server-ce/chef/cookbooks/sharelatex/recipes/default.rb b/server-ce/chef/cookbooks/sharelatex/recipes/default.rb index e7bb3221b4..0448ef8037 100644 --- a/server-ce/chef/cookbooks/sharelatex/recipes/default.rb +++ b/server-ce/chef/cookbooks/sharelatex/recipes/default.rb @@ -5,9 +5,14 @@ # Copyright 2014, ShareLaTeX # -for dir in ["compiles", "clsi-cache", "user_files"] do +# For filestore conversions +package "imagemagick" +package "optipng" + +for dir in ["", "compiles", "clsi-cache", "user_files"] do directory "/var/lib/sharelatex/#{dir}" do - user "www-data" + user "www-data" + group "www-data" recursive true end end @@ -35,5 +40,8 @@ end sharelatex_app "clsi-sharelatex" do repository "https://github.com/sharelatex/clsi-sharelatex.git" revision "master" + environment({ + "PATH" => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:#{node[:texlive][:bin_dir]}" + }) end diff --git a/server-ce/chef/cookbooks/sharelatex/resources/app.rb b/server-ce/chef/cookbooks/sharelatex/resources/app.rb index 22b4cacf60..3e76eb16f6 100644 --- a/server-ce/chef/cookbooks/sharelatex/resources/app.rb +++ b/server-ce/chef/cookbooks/sharelatex/resources/app.rb @@ -3,6 +3,8 @@ actions :start attribute :revision, :kind_of => String, :default => "master" attribute :repository, :kind_of => String attribute :user, :kind_of => String, :default => "www-data" +attribute :group, :kind_of => String, :default => "www-data" +attribute :environment, :kind_of => Hash, :default => {} def initialize(*args) super diff --git a/server-ce/chef/cookbooks/texlive/CHANGELOG.md b/server-ce/chef/cookbooks/texlive/CHANGELOG.md new file mode 100644 index 0000000000..e1b59f6e0c --- /dev/null +++ b/server-ce/chef/cookbooks/texlive/CHANGELOG.md @@ -0,0 +1,12 @@ +# CHANGELOG for latex + +This file is used to list changes made in each version of latex. + +## 0.1.0: + +* Initial release of latex + +- - - +Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. + +The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. diff --git a/server-ce/chef/cookbooks/texlive/README.md b/server-ce/chef/cookbooks/texlive/README.md new file mode 100644 index 0000000000..06f25ec5e4 --- /dev/null +++ b/server-ce/chef/cookbooks/texlive/README.md @@ -0,0 +1,68 @@ +latex Cookbook +============== +TODO: Enter the cookbook description here. + +e.g. +This cookbook makes your favorite breakfast sandwhich. + +Requirements +------------ +TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. + +e.g. +#### packages +- `toaster` - latex needs toaster to brown your bagel. + +Attributes +---------- +TODO: List you cookbook attributes here. + +e.g. +#### latex::default + + + + + + + + + + + + + +
KeyTypeDescriptionDefault
['latex']['bacon']Booleanwhether to include bacontrue
+ +Usage +----- +#### latex::default +TODO: Write usage instructions for each cookbook. + +e.g. +Just include `latex` in your node's `run_list`: + +```json +{ + "name":"my_node", + "run_list": [ + "recipe[latex]" + ] +} +``` + +Contributing +------------ +TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. + +e.g. +1. Fork the repository on Github +2. Create a named feature branch (like `add_component_x`) +3. Write you change +4. Write tests for your change (if applicable) +5. Run the tests, ensuring they all pass +6. Submit a Pull Request using Github + +License and Authors +------------------- +Authors: TODO: List authors diff --git a/server-ce/chef/cookbooks/texlive/attributes/default.rb b/server-ce/chef/cookbooks/texlive/attributes/default.rb new file mode 100644 index 0000000000..a3d2166187 --- /dev/null +++ b/server-ce/chef/cookbooks/texlive/attributes/default.rb @@ -0,0 +1,2 @@ +default[:texlive][:schema] = "small" +default[:texlive][:bin_dir] = "/usr/local/texlive/2013/bin/x86_64-linux" diff --git a/server-ce/chef/cookbooks/texlive/metadata.rb b/server-ce/chef/cookbooks/texlive/metadata.rb new file mode 100644 index 0000000000..ceaaaf2e9c --- /dev/null +++ b/server-ce/chef/cookbooks/texlive/metadata.rb @@ -0,0 +1,7 @@ +name 'texlive' +maintainer 'ShareLaTeX' +maintainer_email 'team@sharelatex.com' +license 'All rights reserved' +description 'Installs/Configures texlive' +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +version '0.1.0' diff --git a/server-ce/chef/cookbooks/texlive/recipes/default.rb b/server-ce/chef/cookbooks/texlive/recipes/default.rb new file mode 100644 index 0000000000..7aab8ef32b --- /dev/null +++ b/server-ce/chef/cookbooks/texlive/recipes/default.rb @@ -0,0 +1,42 @@ +# +# Cookbook Name:: texlive +# Recipe:: default +# +# Copyright 2014, YOUR_COMPANY_NAME +# +# All rights reserved - Do Not Redistribute +# + +remote_file "#{Chef::Config[:file_cache_path]}/install-tl-unx.tar.gz" do + source "http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz" + action :create_if_missing +end + +directory "/install-tl-unx" +bash "extract install-tl" do + cwd Chef::Config[:file_cache_path] + code <<-EOH + tar -xvf install-tl-unx.tar.gz -C /install-tl-unx --strip-components=1 + EOH + creates "/install-tl-unx/install-tl" +end + +file "/install-tl-unx/texlive.profile" do + content "selected_scheme scheme-#{node[:texlive][:schema]}" +end + +bash "install texlive" do + cwd "/install-tl-unx" + code <<-EOH + /install-tl-unx/install-tl -profile /install-tl-unx/texlive.profile + EOH + creates "#{node[:texlive][:bin_dir]}/pdflatex" +end + +bash "install latexmk" do + environment({ + "PATH" => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:#{node[:texlive][:bin_dir]}" + }) + code "tlmgr install latexmk" + creates "#{node[:texlive][:bin_dir]}/latexmk" +end \ No newline at end of file