forked from overleaf/overleaf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start putting together .deb package builder
- Loading branch information
James Allen
committed
May 15, 2014
1 parent
6bb5bcb
commit d2ba7da
Showing
10 changed files
with
221 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ document-updater | |
clsi | ||
filestore | ||
track-changes | ||
docstore | ||
|
||
compiles | ||
cache | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,9 @@ module.exports = (grunt) -> | |
Helpers.checkMake @async() | ||
grunt.registerTask "check", "Check that you have the required dependencies installed", ["check:redis", "check:latexmk", "check:s3", "check:fs"] | ||
|
||
grunt.registerTask "build_deb", "Build an installable .deb file from the current directory", () -> | ||
Helpers.buildDeb @async() | ||
|
||
Helpers = | ||
installService: (repo_src, dir, callback = (error) ->) -> | ||
Helpers.cloneGitRepo repo_src, dir, (error) -> | ||
|
@@ -302,6 +305,69 @@ module.exports = (grunt) -> | |
grunt.log.write "OK." | ||
return callback() | ||
|
||
buildDeb: (callback = (error) ->) -> | ||
# TODO: filestore uses local 'uploads' directory, not configurable in settings | ||
command = ["fpm", "-s", "dir", "-t", "deb", "-n", "sharelatex", "-v", "0.0.1", "--verbose"] | ||
command.push( | ||
"--maintainer", "'ShareLaTeX <[email protected]>'" | ||
"--config-files", "/etc/sharelatex/settings.coffee", | ||
"--directories", "/var/data/sharelatex" | ||
"--directories", "/var/log/sharelatex" | ||
) | ||
|
||
command.push( | ||
"--depends", "'redis-server > 2.6.12'" | ||
"--depends", "'mongodb-10gen > 2.4.0'" | ||
"--depends", "'nodejs > 0.10.0'" | ||
) | ||
|
||
template = fs.readFileSync("package/upstart/sharelatex-template").toString() | ||
for service in SERVICES | ||
fs.writeFileSync "package/upstart/sharelatex-#{service.name}", template.replace(/SERVICE/g, service.name) | ||
command.push( | ||
"--deb-upstart", "package/upstart/sharelatex-#{service.name}" | ||
) | ||
|
||
after_install_script = """ | ||
#!/bin/sh | ||
sudo adduser --system --group --home /var/www/sharelatex --no-create-home sharelatex | ||
mkdir -p /var/log/sharelatex | ||
chown sharelatex:sharelatex /var/log/sharelatex | ||
""" | ||
|
||
for dir in ["user_files", "uploads", "compiles", "cache", "dump"] | ||
after_install_script += """ | ||
mkdir -p /var/data/sharelatex/#{dir} | ||
chown sharelatex:sharelatex /var/data/sharelatex/#{dir} | ||
""" | ||
|
||
for service in SERVICES | ||
after_install_script += "service sharelatex-#{service.name} restart\n" | ||
fs.writeFileSync "package/scripts/after_install.sh", after_install_script | ||
command.push("--after-install", "package/scripts/after_install.sh") | ||
|
||
command.push("--exclude", "'**/.git'") | ||
for path in ["filestore/user_files", "filestore/uploads", "clsi/cache", "clsi/compiles"] | ||
command.push "--exclude", path | ||
|
||
for service in SERVICES | ||
command.push "#{service.name}=/var/www/sharelatex/" | ||
|
||
command.push( | ||
"package/config/settings.coffee=/etc/sharelatex/settings.coffee" | ||
) | ||
console.log command.join(" ") | ||
exec command.join(" "), (error, stdout, stderr) -> | ||
return callback(error) if error? | ||
console.log stdout | ||
console.error stderr if stderr? | ||
callback() | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
sudo adduser --system --group --home /var/www/sharelatex --no-create-home sharelatex | ||
|
||
mkdir -p /var/log/sharelatex | ||
chown sharelatex:sharelatex /var/log/sharelatex | ||
mkdir -p /var/data/sharelatex/user_files | ||
chown sharelatex:sharelatex /var/data/sharelatex/user_files | ||
mkdir -p /var/data/sharelatex/uploads | ||
chown sharelatex:sharelatex /var/data/sharelatex/uploads | ||
mkdir -p /var/data/sharelatex/compiles | ||
chown sharelatex:sharelatex /var/data/sharelatex/compiles | ||
mkdir -p /var/data/sharelatex/cache | ||
chown sharelatex:sharelatex /var/data/sharelatex/cache | ||
mkdir -p /var/data/sharelatex/dump | ||
chown sharelatex:sharelatex /var/data/sharelatex/dump | ||
service sharelatex-web restart | ||
service sharelatex-document-updater restart | ||
service sharelatex-clsi restart | ||
service sharelatex-filestore restart | ||
service sharelatex-track-changes restart | ||
service sharelatex-docstore restart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
description "sharelatex-clsi" | ||
author "ShareLaTeX <[email protected]>" | ||
|
||
start on started mountall | ||
stop on shutdown | ||
|
||
respawn | ||
|
||
limit nofile 8192 8192 | ||
|
||
pre-start script | ||
mkdir -p /var/log/sharelatex | ||
end script | ||
|
||
script | ||
echo $$ > /var/run/sharelatex-clsi.pid | ||
chdir /var/www/sharelatex/clsi | ||
exec sudo -u sharelatex -g sharelatex env SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee NODE_ENV=production node app.js >> /var/log/sharelatex/clsi.log 2>&1 | ||
end script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
description "sharelatex-docstore" | ||
author "ShareLaTeX <[email protected]>" | ||
|
||
start on started mountall | ||
stop on shutdown | ||
|
||
respawn | ||
|
||
limit nofile 8192 8192 | ||
|
||
pre-start script | ||
mkdir -p /var/log/sharelatex | ||
end script | ||
|
||
script | ||
echo $$ > /var/run/sharelatex-docstore.pid | ||
chdir /var/www/sharelatex/docstore | ||
exec sudo -u sharelatex -g sharelatex env SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee NODE_ENV=production node app.js >> /var/log/sharelatex/docstore.log 2>&1 | ||
end script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
description "sharelatex-document-updater" | ||
author "ShareLaTeX <[email protected]>" | ||
|
||
start on started mountall | ||
stop on shutdown | ||
|
||
respawn | ||
|
||
limit nofile 8192 8192 | ||
|
||
pre-start script | ||
mkdir -p /var/log/sharelatex | ||
end script | ||
|
||
script | ||
echo $$ > /var/run/sharelatex-document-updater.pid | ||
chdir /var/www/sharelatex/document-updater | ||
exec sudo -u sharelatex -g sharelatex env SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee NODE_ENV=production node app.js >> /var/log/sharelatex/document-updater.log 2>&1 | ||
end script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
description "sharelatex-filestore" | ||
author "ShareLaTeX <[email protected]>" | ||
|
||
start on started mountall | ||
stop on shutdown | ||
|
||
respawn | ||
|
||
limit nofile 8192 8192 | ||
|
||
pre-start script | ||
mkdir -p /var/log/sharelatex | ||
end script | ||
|
||
script | ||
echo $$ > /var/run/sharelatex-filestore.pid | ||
chdir /var/www/sharelatex/filestore | ||
exec sudo -u sharelatex -g sharelatex env SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee NODE_ENV=production node app.js >> /var/log/sharelatex/filestore.log 2>&1 | ||
end script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
description "sharelatex-SERVICE" | ||
author "ShareLaTeX <[email protected]>" | ||
|
||
start on started mountall | ||
stop on shutdown | ||
|
||
respawn | ||
|
||
limit nofile 8192 8192 | ||
|
||
pre-start script | ||
mkdir -p /var/log/sharelatex | ||
end script | ||
|
||
script | ||
echo $$ > /var/run/sharelatex-SERVICE.pid | ||
chdir /var/www/sharelatex/SERVICE | ||
exec sudo -u sharelatex -g sharelatex env SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee NODE_ENV=production node app.js >> /var/log/sharelatex/SERVICE.log 2>&1 | ||
end script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
description "sharelatex-track-changes" | ||
author "ShareLaTeX <[email protected]>" | ||
|
||
start on started mountall | ||
stop on shutdown | ||
|
||
respawn | ||
|
||
limit nofile 8192 8192 | ||
|
||
pre-start script | ||
mkdir -p /var/log/sharelatex | ||
end script | ||
|
||
script | ||
echo $$ > /var/run/sharelatex-track-changes.pid | ||
chdir /var/www/sharelatex/track-changes | ||
exec sudo -u sharelatex -g sharelatex env SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee NODE_ENV=production node app.js >> /var/log/sharelatex/track-changes.log 2>&1 | ||
end script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
description "sharelatex-web" | ||
author "ShareLaTeX <[email protected]>" | ||
|
||
start on started mountall | ||
stop on shutdown | ||
|
||
respawn | ||
|
||
limit nofile 8192 8192 | ||
|
||
pre-start script | ||
mkdir -p /var/log/sharelatex | ||
end script | ||
|
||
script | ||
echo $$ > /var/run/sharelatex-web.pid | ||
chdir /var/www/sharelatex/web | ||
exec sudo -u sharelatex -g sharelatex env SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee NODE_ENV=production node app.js >> /var/log/sharelatex/web.log 2>&1 | ||
end script |