Update .deb package builder

This commit is contained in:
James Allen 2014-08-18 15:13:48 +01:00
parent d8804834ac
commit b031e98ff8
2 changed files with 38 additions and 13 deletions

View file

@ -131,6 +131,7 @@ module.exports = (grunt) ->
grunt.registerTask "build:upstart_scripts", "Create upstart scripts for each service", () ->
Helpers.buildUpstartScripts()
Helpers =
installService: (repo_src, dir, callback = (error) ->) ->
Helpers.cloneGitRepo repo_src, dir, (error) ->
@ -382,8 +383,13 @@ module.exports = (grunt) ->
for service in SERVICES
fs.writeFileSync "package/upstart/sharelatex-#{service.name}", template.replace(/__SERVICE__/g, service.name)
buildPackageSettingsFile: () ->
config = fs.readFileSync("config/settings.development.coffee.example").toString()
config = config.replace /DATA_DIR.*/, "DATA_DIR = '/var/lib/sharelatex/data'"
config = config.replace /TMP_DIR.*/, "TMP_DIR = '/var/lib/sharelatex/tmp'"
fs.writeFileSync "package/config/settings.coffee", config
buildDeb: (callback = (error) ->) ->
# TODO: filestore uses local 'uploads' directory, not configurable in settings
command = ["-s", "dir", "-t", "deb", "-n", "sharelatex", "-v", "0.0.1", "--verbose"]
command.push(
"--maintainer", "ShareLaTeX <team@sharelatex.com>"
@ -394,10 +400,12 @@ module.exports = (grunt) ->
command.push(
"--depends", "redis-server > 2.6.12"
"--depends", "mongodb-10gen > 2.4.0"
"--depends", "mongodb-org > 2.4.0"
"--depends", "nodejs > 0.10.0"
)
@buildPackageSettingsFile()
@buildUpstartScripts()
for service in SERVICES
command.push(
@ -406,14 +414,21 @@ module.exports = (grunt) ->
after_install_script = """
#!/bin/sh
# Create random secret keys
sed -i "s/CRYPTO_RANDOM/$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 64 | head -n 1)/" /etc/sharelatex/settings.coffee
sed -i "s/CRYPTO_RANDOM/$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 64 | head -n 1)/" /etc/sharelatex/settings.coffee
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/lib/sharelatex
chown sharelatex:sharelatex /var/lib/sharelatex
"""
for dir in ["user_files", "uploads", "compiles", "cache", "dump"]
for dir in ["data/user_files", "tmp/uploads", "data/compiles", "data/cache", "tmp/dumpFolder"]
after_install_script += """
mkdir -p /var/lib/sharelatex/#{dir}
chown sharelatex:sharelatex /var/lib/sharelatex/#{dir}

View file

@ -1,21 +1,31 @@
#!/bin/sh
# Create random secret keys
sed -i "s/CRYPTO_RANDOM/$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 64 | head -n 1)/" /etc/sharelatex/settings.coffee
sed -i "s/CRYPTO_RANDOM/$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 64 | head -n 1)/" /etc/sharelatex/settings.coffee
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
mkdir -p /var/lib/sharelatex
chown sharelatex:sharelatex /var/lib/sharelatex
mkdir -p /var/lib/sharelatex/data/user_files
chown sharelatex:sharelatex /var/lib/sharelatex/data/user_files
mkdir -p /var/lib/sharelatex/tmp/uploads
chown sharelatex:sharelatex /var/lib/sharelatex/tmp/uploads
mkdir -p /var/lib/sharelatex/data/compiles
chown sharelatex:sharelatex /var/lib/sharelatex/data/compiles
mkdir -p /var/lib/sharelatex/data/cache
chown sharelatex:sharelatex /var/lib/sharelatex/data/cache
mkdir -p /var/lib/sharelatex/tmp/dumpFolder
chown sharelatex:sharelatex /var/lib/sharelatex/tmp/dumpFolder
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
service sharelatex-chat restart
service sharelatex-tags restart
service sharelatex-spelling restart