فهرست منبع

Add in TeXLive and imagemagick

James Allen 12 سال پیش
والد
کامیت
f5f46af5a5

+ 1 - 0
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:

+ 1 - 0
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'

+ 8 - 1
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"

+ 10 - 2
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
 

+ 2 - 0
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

+ 12 - 0
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.

+ 68 - 0
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
+<table>
+  <tr>
+    <th>Key</th>
+    <th>Type</th>
+    <th>Description</th>
+    <th>Default</th>
+  </tr>
+  <tr>
+    <td><tt>['latex']['bacon']</tt></td>
+    <td>Boolean</td>
+    <td>whether to include bacon</td>
+    <td><tt>true</tt></td>
+  </tr>
+</table>
+
+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

+ 2 - 0
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"

+ 7 - 0
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'

+ 42 - 0
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