Compare commits
99 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d2ba7da012 | |||
| 6bb5bcb198 | |||
| a1ecd03f73 | |||
| f73b8e3937 | |||
| 64a673ec6d | |||
| 6af53b3697 | |||
| dcec6837b4 | |||
| 6e698b0c05 | |||
| f5f46af5a5 | |||
| 2a79a6066f | |||
| 5933dd60f5 | |||
| 55b9ac7d5a | |||
| aa5eda9f1b | |||
| be1bb918e4 | |||
| 5f0785c818 | |||
| 593f48419b | |||
| d9fdd93a2e | |||
| c4d84487cd | |||
| 6ab07443e3 | |||
| bbdc08249b | |||
| b846033c15 | |||
| c9cf01a9bb | |||
| f238f7726f | |||
| 36e31fda5d | |||
| a038b56d89 | |||
| f85178bf1d | |||
| b2057cb310 | |||
| 9f28ba29cb | |||
| ff04b104a5 | |||
| 7c8f11d102 | |||
| 7713de24dc | |||
| f204c5d440 | |||
| c403003030 | |||
| fbb33bda0f | |||
| 61bb54a2be | |||
| 94aae37025 | |||
| 0b3224c05f | |||
| 217e5f74ca | |||
| aca7b3f961 | |||
| c3ff6c7770 | |||
| 0fc386eebf | |||
| 119ed217ad | |||
| 072a45d853 | |||
| dec7347f08 | |||
| b1eaa97530 | |||
| 6280a5a002 | |||
| 20866189ab | |||
| 90fdbf5681 | |||
| 31b41e156d | |||
| bf528709d2 | |||
| 89bff17891 | |||
| 6279c63dfb | |||
| 0d531d2641 | |||
| 84dfc633bd | |||
| 5840e8f88d | |||
| b461178ff0 | |||
| 69f79386f4 | |||
| 179bc4df33 | |||
| a577a17116 | |||
| d0bfa69a23 | |||
| 5bc02b12fe | |||
| 019a4f26f3 | |||
| 3e9c3bfcce | |||
| 9b6377f4dc | |||
| 78408be110 | |||
| 1d8e019e33 | |||
| c2c092fb4d | |||
| 1b51f9a6af | |||
| 00af21cc5e | |||
| 7c86c6e243 | |||
| 9b53af0a26 | |||
| c3d6d6704c | |||
| 0a707f9b05 | |||
| bce30bcfeb | |||
| 62ffdc816a | |||
| 87376120c9 | |||
| ad6ed1cbff | |||
| 09ea2f68de | |||
| 56ecb546f4 | |||
| af2476d46c | |||
| 432f45ac59 | |||
| c71cb09fdd | |||
| 65f3d2365e | |||
| 62b187eb10 | |||
| 34796ac040 | |||
| a440b5435a | |||
| 6e150b1edc | |||
| 3492e118fd | |||
| d02c777e55 | |||
| 8ed522774c | |||
| d301e54b45 | |||
| 3576b096ea | |||
| 7082842d00 | |||
| 5911a7fb43 | |||
| 81024f869d | |||
| 7ead61dbf2 | |||
| 098be1495e | |||
| 536f7b5b85 | |||
| 6a1a965ffd |
@@ -1,25 +0,0 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
|
||||
[*.go]
|
||||
indent_style = tab
|
||||
|
||||
[*.{pug,coffee}]
|
||||
indent_style = tab
|
||||
|
||||
[*.{pug,patch}]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[Jenkinsfile]
|
||||
insert_final_newline = false
|
||||
max_line_length = off
|
||||
@@ -1,56 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Report a bug
|
||||
title: ''
|
||||
labels: type:bug
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
<!--
|
||||
|
||||
Note: If you are using www.overleaf.com and have a problem,
|
||||
or if you would like to request a new feature please contact
|
||||
the support team at support@overleaf.com
|
||||
|
||||
This form should only be used to report bugs in the
|
||||
Community Edition release of Overleaf.
|
||||
|
||||
-->
|
||||
|
||||
<!-- BUG REPORT TEMPLATE -->
|
||||
|
||||
## Steps to Reproduce
|
||||
|
||||
<!-- Describe the steps leading up to when / where you found the bug. -->
|
||||
<!-- Screenshots may be helpful here. -->
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
## Expected Behaviour
|
||||
|
||||
<!-- What should have happened when you completed the steps above? -->
|
||||
|
||||
## Observed Behaviour
|
||||
|
||||
<!-- What actually happened when you completed the steps above? -->
|
||||
<!-- Screenshots may be helpful here. -->
|
||||
|
||||
## Context
|
||||
|
||||
<!-- How has this issue affected you? What were you trying to accomplish? -->
|
||||
|
||||
## Technical Info
|
||||
|
||||
<!-- Provide any technical details that may be applicable (or N/A if not applicable). -->
|
||||
|
||||
- URL:
|
||||
- Browser Name and version:
|
||||
- Operating System and version (desktop or mobile):
|
||||
- Signed in as:
|
||||
- Project and/or file:
|
||||
|
||||
## Analysis
|
||||
|
||||
<!--- Optionally, document investigation of / suggest a fix for the bug, e.g. 'comes from this line / commit' -->
|
||||
@@ -1,11 +0,0 @@
|
||||
## Description
|
||||
|
||||
<!-- Goal of the pull request -->
|
||||
|
||||
## Related issues / Pull Requests
|
||||
|
||||
<!-- Fixes #xyz, Contributes to #xyz, Related to #xyz-->
|
||||
|
||||
## Contributor Agreement
|
||||
|
||||
- [ ] I confirm I have signed the [Contributor License Agreement](https://github.com/overleaf/overleaf/blob/main/CONTRIBUTING.md#contributor-license-agreement)
|
||||
+18
-5
@@ -1,6 +1,19 @@
|
||||
# docker image build
|
||||
.dockerignore
|
||||
config
|
||||
config-local
|
||||
node_modules
|
||||
|
||||
# user defined files
|
||||
.env
|
||||
docker-compose.override.yml
|
||||
web
|
||||
document-updater
|
||||
clsi
|
||||
filestore
|
||||
track-changes
|
||||
docstore
|
||||
|
||||
compiles
|
||||
cache
|
||||
user_files
|
||||
template_files
|
||||
|
||||
db.sqlite
|
||||
|
||||
.vagrant
|
||||
|
||||
+43
-18
@@ -1,38 +1,63 @@
|
||||
# Contributing to Overleaf
|
||||
Contributing to ShareLaTeX
|
||||
==========================
|
||||
|
||||
Thank you for reading this! If you'd like to report a bug or join in the development
|
||||
of Overleaf, then here are some notes on how to do that.
|
||||
of ShareLaTeX, then here are some notes on how to do that.
|
||||
|
||||
## Reporting bugs and opening issues
|
||||
*Note that ShareLaTeX is actually made up of many seperate repositories (a list is available
|
||||
[here](https://github.com/sharelatex/sharelatex/blob/master/README.md#other-repositories)).*
|
||||
|
||||
If you'd like to report a bug or open an issue, please **[check if there is an existing issue](https://github.com/overleaf/overleaf/issues).**
|
||||
If there is then please add any more information that you have, or give it a 👍.
|
||||
Reporting bugs and opening issues
|
||||
---------------------------------
|
||||
|
||||
If you'd like a report a bug or open an issue then please:
|
||||
|
||||
1. **Find the correct repository.** ShareLaTeX is split across multiple different repositories, each containing a different service (you can find a list of [all repositories here](https://github.com/sharelatex/sharelatex/blob/master/README.md#other-repositories)). If you know the bug only applies to one service, then please open an issue in that repository. For general bugs and issues that span more than one service, please open an issue in the [sharelatex/sharelatex](https://github.com/sharelatex/sharelatex) repository.
|
||||
2. **Check if there is an existing issue.** If there is then please add
|
||||
any more information that you have, or give it a "+1" in the comments.
|
||||
|
||||
When submitting an issue please describe the issue as clearly as possible, including how to
|
||||
reproduce the bug, which situations it appears in, what you expected to happen, and what actually happens.
|
||||
If you can include a screenshot for front end issues that is very helpful.
|
||||
|
||||
**Note**: If you are using [www.overleaf.com](www.overleaf.com) and have a problem, or if you would like to request a new feature, please contact the Support team at support@overleaf.com. Raise an issue here only to report bugs in the Community Edition release of Overleaf.
|
||||
Pull Requests
|
||||
-------------
|
||||
|
||||
## Pull Requests
|
||||
|
||||
See [our wiki](https://github.com/overleaf/overleaf/wiki)
|
||||
for how to manage the Overleaf development environment and for our developer guidelines.
|
||||
See [our wiki](https://github.com/sharelatex/sharelatex/wiki/Developer-Guidelines)
|
||||
for how to manage the ShareLaTeX development environment and for our developer guidelines.
|
||||
|
||||
We love pull requests, so be bold with them! Don't be afraid of going ahead
|
||||
and changing something, or adding a new feature. We're very happy to work with you
|
||||
to get your changes merged into Overleaf.
|
||||
to get your changes merged into ShareLaTeX.
|
||||
|
||||
If you're looking for something to work on, have a look at the [open issues](https://github.com/overleaf/overleaf/issues).
|
||||
If you've got an idea for a change then please discuss it in the open first,
|
||||
either by opening an issue, or by joining us in our
|
||||
[development chat room](http://www.hipchat.com/g1nJMcj7b).
|
||||
|
||||
## Security
|
||||
If you're looking for something to work on, then take a look at our [development roadmap](https://github.com/sharelatex/sharelatex/wiki/Development-Roadmap), or have a look at the open issues in any of the repositories listed [here](https://github.com/sharelatex/sharelatex/blob/master/README.md#other-repositories).
|
||||
|
||||
Please see [our security policy](https://github.com/overleaf/overleaf/security/policy) if you would like to report a potential security vulnerability.
|
||||
Developer Chat Room
|
||||
-------------------
|
||||
|
||||
## Contributor License Agreement
|
||||
If you want to ask any questions in real-time, or get a feel for what's going on
|
||||
then please drop into our [development chat room](http://www.hipchat.com/g1nJMcj7b).
|
||||
If no one is online then you can still leave a message that will hopefully get a reply
|
||||
when we return.
|
||||
|
||||
Before we can accept any contributions of code, we need you to agree to our
|
||||
[Contributor License Agreement](https://docs.google.com/forms/d/e/1FAIpQLSef79XH3mb7yIiMzZw-yALEegS-wyFetvjTiNBfZvf_IHD2KA/viewform?usp=sf_link).
|
||||
Security
|
||||
--------
|
||||
|
||||
Please do not publish security vulnerabilities publicly until we've had a chance
|
||||
to address them. All security related issues/patches should be sent directly to
|
||||
team@sharelatex.com where we will attempt to address them quickly. If you're
|
||||
unsure whether something is a security issue or not, then please be cautious and
|
||||
contact us at team@sharelatex.com first.
|
||||
|
||||
Contributor License Agreement
|
||||
-----------------------------
|
||||
|
||||
Before we can accept and contributions of code, we need you to agree to our
|
||||
[Contributor License Agreement](https://sharelatex.wufoo.com/forms/sharelatex-contributor-license-agreement/).
|
||||
This is to ensure that you own the copyright of your contribution, and that you
|
||||
agree to give us a license to use it in both the open source version, and the version
|
||||
of Overleaf running at www.overleaf.com, which may have additional changes.
|
||||
of ShareLaTeX running at www.sharelatex.com, which may have additional changes.
|
||||
|
||||
@@ -0,0 +1,373 @@
|
||||
fs = require "fs"
|
||||
spawn = require("child_process").spawn
|
||||
exec = require("child_process").exec
|
||||
rimraf = require "rimraf"
|
||||
Path = require "path"
|
||||
semver = require "semver"
|
||||
knox = require "knox"
|
||||
|
||||
SERVICES = [{
|
||||
name: "web"
|
||||
repo: "https://github.com/sharelatex/web-sharelatex.git"
|
||||
}, {
|
||||
name: "document-updater"
|
||||
repo: "https://github.com/sharelatex/document-updater-sharelatex.git"
|
||||
}, {
|
||||
name: "clsi"
|
||||
repo: "https://github.com/sharelatex/clsi-sharelatex.git"
|
||||
}, {
|
||||
name: "filestore"
|
||||
repo: "https://github.com/sharelatex/filestore-sharelatex.git"
|
||||
}, {
|
||||
name: "track-changes"
|
||||
repo: "https://github.com/sharelatex/track-changes-sharelatex.git"
|
||||
}, {
|
||||
name: "docstore"
|
||||
repo: "https://github.com/sharelatex/docstore-sharelatex.git"
|
||||
}]
|
||||
|
||||
module.exports = (grunt) ->
|
||||
grunt.loadNpmTasks 'grunt-bunyan'
|
||||
grunt.loadNpmTasks 'grunt-execute'
|
||||
grunt.loadNpmTasks 'grunt-available-tasks'
|
||||
grunt.loadNpmTasks 'grunt-concurrent'
|
||||
|
||||
execute = {}
|
||||
for service in SERVICES
|
||||
execute[service.name] =
|
||||
src: "#{service.name}/app.js"
|
||||
|
||||
grunt.initConfig
|
||||
execute: execute
|
||||
|
||||
concurrent:
|
||||
all:
|
||||
tasks: ("run:#{service.name}" for service in SERVICES)
|
||||
options:
|
||||
limit: SERVICES.length
|
||||
logConcurrentOutput: true
|
||||
|
||||
availabletasks:
|
||||
tasks:
|
||||
options:
|
||||
filter: 'exclude',
|
||||
tasks: [
|
||||
'concurrent'
|
||||
'execute'
|
||||
'bunyan'
|
||||
'availabletasks'
|
||||
]
|
||||
groups:
|
||||
"Run tasks": [
|
||||
"run"
|
||||
"run:all"
|
||||
"default"
|
||||
].concat ("run:#{service.name}" for service in SERVICES)
|
||||
"Misc": [
|
||||
"help"
|
||||
]
|
||||
"Install tasks": ("install:#{service.name}" for service in SERVICES).concat(["install:all", "install", "install:config"])
|
||||
"Update tasks": ("update:#{service.name}" for service in SERVICES).concat(["update:all", "update"])
|
||||
"Config tasks": ["install:config"]
|
||||
"Checks": ["check", "check:redis", "check:latexmk", "check:s3", "check:make"]
|
||||
|
||||
for service in SERVICES
|
||||
do (service) ->
|
||||
grunt.registerTask "install:#{service.name}", "Download and set up the #{service.name} service", () ->
|
||||
done = @async()
|
||||
Helpers.installService(service.repo, service.name, done)
|
||||
grunt.registerTask "update:#{service.name}", "Checkout and update the #{service.name} service", () ->
|
||||
done = @async()
|
||||
Helpers.updateService(service.name, done)
|
||||
grunt.registerTask "run:#{service.name}", "Run the ShareLaTeX #{service.name} service", ["bunyan", "execute:#{service.name}"]
|
||||
|
||||
grunt.registerTask 'install:config', "Copy the example config into the real config", () ->
|
||||
Helpers.installConfig @async()
|
||||
grunt.registerTask 'install:all', "Download and set up all ShareLaTeX services",
|
||||
["check:make"].concat(
|
||||
("install:#{service.name}" for service in SERVICES)
|
||||
).concat(["install:config"])
|
||||
grunt.registerTask 'install', 'install:all'
|
||||
grunt.registerTask 'update:all', "Checkout and update all ShareLaTeX services",
|
||||
["check:make"].concat(
|
||||
("update:#{service.name}" for service in SERVICES)
|
||||
)
|
||||
grunt.registerTask 'update', 'update:all'
|
||||
grunt.registerTask 'run', "Run all of the sharelatex processes", ['concurrent:all']
|
||||
grunt.registerTask 'run:all', 'run'
|
||||
|
||||
grunt.registerTask 'help', 'Display this help list', 'availabletasks'
|
||||
grunt.registerTask 'default', 'run'
|
||||
|
||||
grunt.registerTask "check:redis", "Check that redis is installed and running", () ->
|
||||
Helpers.checkRedis @async()
|
||||
grunt.registerTask "check:latexmk", "Check that latexmk is installed", () ->
|
||||
Helpers.checkLatexmk @async()
|
||||
grunt.registerTask "check:s3", "Check that Amazon S3 credentials are configured", () ->
|
||||
Helpers.checkS3 @async()
|
||||
grunt.registerTask "check:fs", "Check that local filesystem options are configured", () ->
|
||||
Helpers.checkFS @async()
|
||||
grunt.registerTask "check:make", "Check that make is installed", () ->
|
||||
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) ->
|
||||
return callback(error) if error?
|
||||
Helpers.installNpmModules dir, (error) ->
|
||||
return callback(error) if error?
|
||||
Helpers.runGruntInstall dir, (error) ->
|
||||
return callback(error) if error?
|
||||
callback()
|
||||
|
||||
updateService: (dir, callback = (error) ->) ->
|
||||
Helpers.updateGitRepo dir, (error) ->
|
||||
return callback(error) if error?
|
||||
Helpers.installNpmModules dir, (error) ->
|
||||
return callback(error) if error?
|
||||
Helpers.runGruntInstall dir, (error) ->
|
||||
return callback(error) if error?
|
||||
callback()
|
||||
|
||||
cloneGitRepo: (repo_src, dir, callback = (error) ->) ->
|
||||
if !fs.existsSync(dir)
|
||||
proc = spawn "git", ["clone", repo_src, dir], stdio: "inherit"
|
||||
proc.on "close", () ->
|
||||
callback()
|
||||
else
|
||||
console.log "#{dir} already installed, skipping."
|
||||
callback()
|
||||
|
||||
updateGitRepo: (dir, callback = (error) ->) ->
|
||||
proc = spawn "git", ["checkout", "master"], cwd: dir, stdio: "inherit"
|
||||
proc.on "close", () ->
|
||||
proc = spawn "git", ["pull"], cwd: dir, stdio: "inherit"
|
||||
proc.on "close", () ->
|
||||
callback()
|
||||
|
||||
installNpmModules: (dir, callback = (error) ->) ->
|
||||
proc = spawn "npm", ["install"], stdio: "inherit", cwd: dir
|
||||
proc.on "close", () ->
|
||||
callback()
|
||||
|
||||
installConfig: (callback = (error) ->) ->
|
||||
if !fs.existsSync("config/settings.development.coffee")
|
||||
grunt.log.writeln "Copying example config into config/settings.development.coffee"
|
||||
exec "cp config/settings.development.coffee.example config/settings.development.coffee", (error, stdout, stderr) ->
|
||||
callback(error)
|
||||
else
|
||||
grunt.log.writeln "Config file already exists. Skipping."
|
||||
callback()
|
||||
|
||||
runGruntInstall: (dir, callback = (error) ->) ->
|
||||
proc = spawn "grunt", ["install"], stdio: "inherit", cwd: dir
|
||||
proc.on "close", () ->
|
||||
callback()
|
||||
|
||||
checkRedis: (callback = (error) ->) ->
|
||||
grunt.log.write "Checking Redis is running... "
|
||||
exec "redis-cli info", (error, stdout, stderr) ->
|
||||
if error? and error.message.match("Could not connect")
|
||||
grunt.log.error "FAIL. Redis is not running"
|
||||
return callback(error)
|
||||
else if error?
|
||||
return callback(error)
|
||||
else
|
||||
m = stdout.match(/redis_version:(.*)/)
|
||||
if !m?
|
||||
grunt.log.error "FAIL."
|
||||
grunt.log.error "Unknown redis version"
|
||||
error = new Error("Unknown redis version")
|
||||
else
|
||||
version = m[1]
|
||||
if semver.gte(version, "2.6.12")
|
||||
grunt.log.writeln "OK."
|
||||
grunt.log.writeln "Running Redis version #{version}"
|
||||
else
|
||||
grunt.log.error "FAIL."
|
||||
grunt.log.error "Redis version is too old (#{version}). Must be 2.6.12 or greater."
|
||||
error = new Error("Redis version is too old (#{version}). Must be 2.6.12 or greater.")
|
||||
callback(error)
|
||||
|
||||
checkLatexmk: (callback = (error) ->) ->
|
||||
grunt.log.write "Checking latexmk is installed... "
|
||||
exec "latexmk --version", (error, stdout, stderr) ->
|
||||
if error? and error.message.match("command not found")
|
||||
grunt.log.error "FAIL."
|
||||
grunt.log.errorlns """
|
||||
Either latexmk is not installed or is not in your PATH.
|
||||
|
||||
latexmk comes with TexLive 2013, and must be a version from 2013 or later.
|
||||
This is a not a fatal error, but compiling will not work without latexmk
|
||||
"""
|
||||
return callback(error)
|
||||
else if error?
|
||||
return callback(error)
|
||||
else
|
||||
m = stdout.match(/Version (.*)/)
|
||||
if !m?
|
||||
grunt.log.error "FAIL."
|
||||
grunt.log.error "Unknown latexmk version"
|
||||
error = new Error("Unknown latexmk version")
|
||||
else
|
||||
version = m[1]
|
||||
if semver.gte(version + ".0", "4.39.0")
|
||||
grunt.log.writeln "OK."
|
||||
grunt.log.writeln "Running latexmk version #{version}"
|
||||
else
|
||||
grunt.log.error "FAIL."
|
||||
grunt.log.errorlns """
|
||||
latexmk version is too old (#{version}). Must be 4.39 or greater.
|
||||
This is a not a fatal error, but compiling will not work without latexmk
|
||||
"""
|
||||
error = new Error("latexmk is too old")
|
||||
callback(error)
|
||||
|
||||
checkS3: (callback = (error) ->) ->
|
||||
Settings = require "settings-sharelatex"
|
||||
if Settings.filestore.backend==""
|
||||
grunt.log.writeln "No backend specified. Assuming Amazon S3"
|
||||
Settings.filestore.backend = "s3"
|
||||
if Settings.filestore.backend=="s3"
|
||||
grunt.log.write "Checking S3 credentials... "
|
||||
try
|
||||
client = knox.createClient({
|
||||
key: Settings.filestore.s3.key
|
||||
secret: Settings.filestore.s3.secret
|
||||
bucket: Settings.filestore.stores.user_files
|
||||
})
|
||||
catch e
|
||||
grunt.log.error "FAIL."
|
||||
grunt.log.errorlns """
|
||||
Please configure your Amazon S3 credentials in config/settings.development.coffee
|
||||
|
||||
Amazon S3 (Simple Storage Service) is a cloud storage service provided by
|
||||
Amazon. ShareLaTeX uses S3 for storing binary files like images. You can
|
||||
sign up for an account and find out more at:
|
||||
|
||||
http://aws.amazon.com/s3/
|
||||
|
||||
"""
|
||||
return callback()
|
||||
client.getFile "does-not-exist", (error, response) ->
|
||||
unless response? and response.statusCode == 404
|
||||
grunt.log.error "FAIL."
|
||||
grunt.log.errorlns """
|
||||
Could not connect to Amazon S3. Please check your credentials.
|
||||
"""
|
||||
else
|
||||
grunt.log.write "OK."
|
||||
callback()
|
||||
else
|
||||
grunt.log.writeln "Filestore other than S3 configured. Not checking S3."
|
||||
callback()
|
||||
|
||||
checkFS: (callback = (error) ->) ->
|
||||
Settings = require "settings-sharelatex"
|
||||
if Settings.filestore.backend=="fs"
|
||||
grunt.log.write "Checking FS configuration..."
|
||||
fs = require("fs")
|
||||
fs.exists Settings.filestore.stores.user_files, (exists) ->
|
||||
if exists
|
||||
grunt.log.write "OK."
|
||||
else
|
||||
grunt.log.error "FAIL."
|
||||
grunt.log.errorlns """
|
||||
Could not find directory "#{Settings.filestore.stores.user_files}".
|
||||
Please check your configuration.
|
||||
"""
|
||||
else
|
||||
grunt.log.writeln "Filestore other than FS configured. Not checking FS."
|
||||
callback()
|
||||
|
||||
|
||||
checkMake: (callback = (error) ->) ->
|
||||
grunt.log.write "Checking make is installed... "
|
||||
exec "make --version", (error, stdout, stderr) ->
|
||||
if error? and error.message.match("command not found")
|
||||
grunt.log.error "FAIL."
|
||||
grunt.log.errorlns """
|
||||
Either make is not installed or is not in your path.
|
||||
|
||||
On Ubuntu you can install make with:
|
||||
|
||||
sudo apt-get install build-essential
|
||||
|
||||
"""
|
||||
return callback(error)
|
||||
else if error?
|
||||
return callback(error)
|
||||
else
|
||||
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 <team@sharelatex.com>'"
|
||||
"--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()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,80 +1,126 @@
|
||||
<h1 align="center">
|
||||
<br>
|
||||
<a href="https://www.overleaf.com"><img src="doc/logo.png" alt="Overleaf" width="300"></a>
|
||||
</h1>
|
||||
ShareLaTeX
|
||||
==========
|
||||
|
||||
<h4 align="center">An open-source online real-time collaborative LaTeX editor.</h4>
|
||||
[ShareLaTeX](https://www.sharelatex.com) is now open source! ShareLaTeX is an online real-time collaborative LaTeX editor, and you can now run your own local version where you can host, edit, collaborate in real-time, and compile your LaTeX documents. We’re still 100% focused on running the hosted version at http://www.sharelatex.com, but we want to be more flexible in how you can use ShareLaTeX, and give something back to our wonderful community.
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/overleaf/overleaf/wiki">Wiki</a> •
|
||||
<a href="https://www.overleaf.com/for/enterprises">Server Pro</a> •
|
||||
<a href="#contributing">Contributing</a> •
|
||||
<a href="https://mailchi.mp/overleaf.com/community-edition-and-server-pro">Mailing List</a> •
|
||||
<a href="#authors">Authors</a> •
|
||||
<a href="#license">License</a>
|
||||
</p>
|
||||
**[Read more on our blog](https://www.sharelatex.com/blog/2014/02/21/sharelatex-is-now-open-source.html#.UwcnsEJ_ugc)**
|
||||
|
||||
<img src="doc/screenshot.png" alt="A screenshot of a project being edited in Overleaf Community Edition">
|
||||
<p align="center">
|
||||
Figure 1: A screenshot of a project being edited in Overleaf Community Edition.
|
||||
</p>
|
||||
Installation
|
||||
------------
|
||||
|
||||
## Community Edition
|
||||
**[Please help us make ShareLaTeX as easy to install as possible by answering our quick survey about your system and needs](https://sharelatex.typeform.com/to/PLNits)**
|
||||
|
||||
[Overleaf](https://www.overleaf.com) is an open-source online real-time collaborative LaTeX editor. We run a hosted version at [www.overleaf.com](https://www.overleaf.com), but you can also run your own local version, and contribute to the development of Overleaf.
|
||||
We're still figuring out the easiest way to let you install ShareLaTeX and get up and running quickly. If you fill in the above survey in we will be eternally grateful and it will help us make this install process as smooth as possible. For now, here is the best ways:
|
||||
|
||||
> [!CAUTION]
|
||||
> Overleaf Community Edition is intended for use in environments where **all** users are trusted. Community Edition is **not** appropriate for scenarios where isolation of users is required due to Sandbox Compiles not being available. When not using Sandboxed Compiles, users have full read and write access to the `sharelatex` container resources (filesystem, network, environment variables) when running LaTeX compiles.
|
||||
### Manually
|
||||
|
||||
For more information on Sandbox Compiles check out our [documentation](https://docs.overleaf.com/on-premises/configuration/overleaf-toolkit/server-pro-only-configuration/sandboxed-compiles).
|
||||
First, check out a local copy of this repository:
|
||||
|
||||
## Enterprise
|
||||
```bash
|
||||
git clone https://github.com/sharelatex/sharelatex.git
|
||||
cd sharelatex
|
||||
```
|
||||
|
||||
If you want help installing and maintaining Overleaf in your lab or workplace, we offer an officially supported version called [Overleaf Server Pro](https://www.overleaf.com/for/enterprises). It also includes more features for security (SSO with LDAP or SAML), administration and collaboration (e.g. tracked changes). [Find out more!](https://www.overleaf.com/for/enterprises)
|
||||
Next install all the node modules and ShareLaTeX services:
|
||||
|
||||
## Keeping up to date
|
||||
```bash
|
||||
npm install
|
||||
grunt install
|
||||
```
|
||||
|
||||
Sign up to the [mailing list](https://mailchi.mp/overleaf.com/community-edition-and-server-pro) to get updates on Overleaf releases and development.
|
||||
This will create a config file in `config/settings.development.coffee`. You should open
|
||||
this now and configure your AWS S3 credentials, and other custom settings.
|
||||
|
||||
## Installation
|
||||
Now check that your system is set up correctly to run ShareLaTeX (checks that you have
|
||||
the required dependencies installed.) Watch out for any failures.
|
||||
|
||||
We have detailed installation instructions in the [Overleaf Toolkit](https://github.com/overleaf/toolkit/).
|
||||
```bash
|
||||
grunt check --force
|
||||
```
|
||||
|
||||
## Upgrading
|
||||
When that has finished, run ShareLaTeX with
|
||||
|
||||
If you are upgrading from a previous version of Overleaf, please see the [Release Notes section on the Wiki](https://github.com/overleaf/overleaf/wiki#release-notes) for all of the versions between your current version and the version you are upgrading to.
|
||||
```bash
|
||||
grunt run
|
||||
```
|
||||
|
||||
## Overleaf Docker Image
|
||||
ShareLaTeX should now be running at http://localhost:3000.
|
||||
|
||||
This repo contains two dockerfiles, [`Dockerfile-base`](server-ce/Dockerfile-base), which builds the
|
||||
`sharelatex/sharelatex-base` image, and [`Dockerfile`](server-ce/Dockerfile) which builds the
|
||||
`sharelatex/sharelatex` (or "community") image.
|
||||
### With Vagrant
|
||||
|
||||
The Base image generally contains the basic dependencies like `wget`, plus `texlive`.
|
||||
We split this out because it's a pretty heavy set of
|
||||
dependencies, and it's nice to not have to rebuild all of that every time.
|
||||
There is a Vagrant and Ansible backed VM installation script for ShareLaTeX, maintained by [@palkan](https://github/palkan), available here: https://github.com/palkan/sharelatex-vagrant-ansible
|
||||
|
||||
The `sharelatex/sharelatex` image extends the base image and adds the actual Overleaf code
|
||||
and services.
|
||||
### With Docker
|
||||
|
||||
Use `make build-base` and `make build-community` from `server-ce/` to build these images.
|
||||
An [automatic docker-based installer](https://github.com/tiagoboldt/sharelatex-docker) is available. It depends on docker and will build a production environment for running ShareLaTeX on any supported platform.
|
||||
|
||||
We use the [Phusion base-image](https://github.com/phusion/baseimage-docker)
|
||||
(which is extended by our `base` image) to provide us with a VM-like container
|
||||
in which to run the Overleaf services. Baseimage uses the `runit` service
|
||||
manager to manage services, and we add our init-scripts from the `server-ce/runit`
|
||||
folder.
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
## Contributing
|
||||
ShareLaTeX should run on OS X and Linux. You need:
|
||||
|
||||
Please see the [CONTRIBUTING](CONTRIBUTING.md) file for information on contributing to the development of Overleaf.
|
||||
* [Node.js](http://nodejs.org/) 0.10 or greater. We recommend that you use [nvm](https://github.com/creationix/nvm) to install it.
|
||||
* The [grunt](http://gruntjs.com/) command line tools (Run `npm install -g grunt-cli` to install them)
|
||||
* A local instance of [Redis](http://redis.io/topics/quickstart) (version 2.6.12 or later) and [MongoDB](http://docs.mongodb.org/manual/installation/) running on their standard ports.
|
||||
* [TeXLive](https://www.tug.org/texlive/) 2013 or later with the `latexmk` program installed.
|
||||
|
||||
## Authors
|
||||
Config
|
||||
------
|
||||
|
||||
[The Overleaf Team](https://www.overleaf.com/about)
|
||||
ShareLaTeX should run out of the box, but if you want to adjust any settings you can do so by
|
||||
editing the `config/settings.development.coffee` file. Available options are explained inline.
|
||||
|
||||
## License
|
||||
Other repositories
|
||||
------------------
|
||||
|
||||
The code in this repository is released under the GNU AFFERO GENERAL PUBLIC LICENSE, version 3. A copy can be found in the [`LICENSE`](LICENSE) file.
|
||||
ShareLaTeX consists of many separate services, each with their own Node.js process
|
||||
and source code repository. These are all downloaded and set upwhen you run
|
||||
`grunt install`
|
||||
|
||||
Copyright (c) Overleaf, 2014-2025.
|
||||
The different services are:
|
||||
|
||||
### [web](https://github.com/sharelatex/web-sharelatex) [](https://travis-ci.org/sharelatex/web-sharelatex)
|
||||
|
||||
The front facing web server that serves all the HTML pages, CSS and JavaScript
|
||||
to the client. Also contains a lot of logic around creating and editing
|
||||
projects, and account management.
|
||||
|
||||
### [document-updater](https://github.com/sharelatex/document-updater-sharelatex) [](https://travis-ci.org/sharelatex/document-updater-sharelatex)
|
||||
|
||||
Processes updates that come in from the editor when users modify documents. Ensures that
|
||||
the updates are applied in the right order, and that only one operation is modifying
|
||||
the document at a time. Also caches the documents in redis for very fast but persistent
|
||||
modifications.
|
||||
|
||||
### [CLSI](https://github.com/sharelatex/clsi-sharelatex) [](https://travis-ci.org/sharelatex/clsi-sharelatex)
|
||||
|
||||
The Common LaTeX Service Interface (CLSI) which provides an API for compiling LaTeX
|
||||
documents.
|
||||
|
||||
### [filestore](https://github.com/sharelatex/filestore-sharelatex) [](https://travis-ci.org/sharelatex/filestore-sharelatex)
|
||||
|
||||
An API for performing CRUD (Create, Read, Update and Delete) operations on binary files
|
||||
(like images) stored in ShareLaTeX.
|
||||
|
||||
### [track-changes](https://github.com/sharelatex/track-changes-sharelatex) [](https://travis-ci.org/sharelatex/track-changes-sharelatex)
|
||||
|
||||
An API for compressing and storing the updates applied to a document, and then rendering a diff of the changes
|
||||
between any two time points. *Still in development and not hooked into the UI yet*.
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Please see the [CONTRIBUTING](https://github.com/sharelatex/sharelatex/blob/master/CONTRIBUTING.md) file for information on contributing to the development of ShareLaTeX. See [our wiki](https://github.com/sharelatex/sharelatex/wiki/Developer-Guidelines) for information on setting up a development environment and how to recompile and run ShareLaTeX after modifications.
|
||||
|
||||
Authors
|
||||
---
|
||||
|
||||
- [Henry Oswald](http://twitter.com/henryoswald)
|
||||
- [James Allen](http://twitter.com/thejpallen)
|
||||
|
||||
License
|
||||
----
|
||||
|
||||
The code in this repository is released under the GNU AFFERO GENERAL PUBLIC LICENSE, version 3. A copy can be found in the `LICENSE` file.
|
||||
|
||||
Copyright (c) ShareLaTeX, 2014.
|
||||
|
||||
Vendored
+54
@@ -0,0 +1,54 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
||||
VAGRANTFILE_API_VERSION = "2"
|
||||
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.box = "ubuntu-12.04"
|
||||
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
|
||||
|
||||
config.vm.network :forwarded_port, guest: 3000, host: 3000
|
||||
|
||||
config.ssh.forward_agent = true
|
||||
|
||||
config.vm.provider "virtualbox" do |v|
|
||||
v.memory = 1024
|
||||
end
|
||||
|
||||
config.vm.provision :chef_solo do |chef|
|
||||
chef.cookbooks_path = "chef/cookbooks"
|
||||
chef.add_recipe 'apt'
|
||||
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:
|
||||
chef.json = {}
|
||||
end
|
||||
|
||||
# Enable provisioning with chef server, specifying the chef server URL,
|
||||
# and the path to the validation key (relative to this Vagrantfile).
|
||||
#
|
||||
# The Opscode Platform uses HTTPS. Substitute your organization for
|
||||
# ORGNAME in the URL and validation key.
|
||||
#
|
||||
# If you have your own Chef Server, use the appropriate URL, which may be
|
||||
# HTTP instead of HTTPS depending on your configuration. Also change the
|
||||
# validation key to validation.pem.
|
||||
#
|
||||
# config.vm.provision :chef_client do |chef|
|
||||
# chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
|
||||
# chef.validation_key_path = "ORGNAME-validator.pem"
|
||||
# end
|
||||
#
|
||||
# If you're using the Opscode platform, your validator client is
|
||||
# ORGNAME-validator, replacing ORGNAME with your organization name.
|
||||
#
|
||||
# If you have your own Chef Server, the default validation client name is
|
||||
# chef-validator, unless you changed the configuration.
|
||||
#
|
||||
# chef.validation_client_name = "ORGNAME-validator"
|
||||
end
|
||||
@@ -1,3 +0,0 @@
|
||||
/* eslint-disable no-undef */
|
||||
|
||||
rs.initiate({ _id: 'overleaf', members: [{ _id: 0, host: 'mongo:27017' }] })
|
||||
@@ -0,0 +1,3 @@
|
||||
current_dir = File.dirname(__FILE__)
|
||||
cookbook_path ["#{current_dir}/../cookbooks"]
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
apt Cookbook CHANGELOG
|
||||
======================
|
||||
This file is used to list changes made in each version of the apt cookbook.
|
||||
|
||||
v2.3.8 (2014-02-14)
|
||||
-------------------
|
||||
### Bug
|
||||
- **[COOK-4287](https://tickets.opscode.com/browse/COOK-4287)** - Cleanup the Kitchen
|
||||
|
||||
|
||||
v2.3.6
|
||||
------
|
||||
* [COOK-4154] - Add chefspec matchers.rb file to apt cookbook
|
||||
* [COOK-4102] - Only index created repository
|
||||
|
||||
|
||||
v2.3.6
|
||||
------
|
||||
* [COOK-4154] - Add chefspec matchers.rb file to apt cookbook
|
||||
* [COOK-4102] - Only index created repository
|
||||
|
||||
|
||||
v2.3.4
|
||||
------
|
||||
No change. Version bump for toolchain sanity
|
||||
|
||||
|
||||
v2.3.2
|
||||
------
|
||||
- [COOK-3905] apt-get-update-periodic: configuration for the update period
|
||||
- Updating style for rubocops
|
||||
- Updating test-kitchen harness
|
||||
|
||||
|
||||
v2.3.0
|
||||
------
|
||||
### Bug
|
||||
- **[COOK-3812](https://tickets.opscode.com/browse/COOK-3812)** - Add a way to bypass the apt existence check
|
||||
|
||||
### Improvement
|
||||
- **[COOK-3567](https://tickets.opscode.com/browse/COOK-3567)** - Allow users to bypass apt-cache via attributes
|
||||
|
||||
|
||||
v2.2.1
|
||||
------
|
||||
### Improvement
|
||||
- **[COOK-664](https://tickets.opscode.com/browse/COOK-664)** - Check platform before running apt-specific commands
|
||||
|
||||
|
||||
v2.2.0
|
||||
------
|
||||
### Bug
|
||||
- **[COOK-3707](https://tickets.opscode.com/browse/COOK-3707)** - multiple nics confuse apt::cacher-client
|
||||
|
||||
v2.1.2
|
||||
------
|
||||
### Improvement
|
||||
- **[COOK-3551](https://tickets.opscode.com/browse/COOK-3551)** - Allow user to set up a trusted APT repository
|
||||
|
||||
v2.1.1
|
||||
------
|
||||
### Bug
|
||||
- **[COOK-1856](https://tickets.opscode.com/browse/COOK-1856)** - Match GPG keys without case sensitivity
|
||||
|
||||
v2.1.0
|
||||
------
|
||||
- [COOK-3426]: cacher-ng fails with restrict_environment set to true
|
||||
- [COOK-2859]: cacher-client executes out of order
|
||||
- [COOK-3052]: Long GPG keys are downloaded on every run
|
||||
- [COOK-1856]: apt cookbook should match keys without case sensitivity
|
||||
- [COOK-3255]: Attribute name incorrect in README
|
||||
- [COOK-3225]: Call use_inline_resources only if defined
|
||||
- [COOK-3386]: Cache dir for apt-cacher-ng
|
||||
- [COOK-3291]: apt_repository: enable usage of a keyserver on port 80
|
||||
- Greatly expanded test coverage with ChefSpec and Test-Kitchen
|
||||
|
||||
v2.0.0
|
||||
------
|
||||
### Bug
|
||||
|
||||
- [COOK-2258]: apt: LWRP results in error under why-run mode in apt 1.9.0 cookbook
|
||||
|
||||
v1.10.0
|
||||
-------
|
||||
### Improvement
|
||||
|
||||
- [COOK-2885]: Improvements for apt cache server search
|
||||
|
||||
### Bug
|
||||
|
||||
- [COOK-2441]: Apt recipe broken in new chef version
|
||||
- [COOK-2660]: Create Debian 6.0 "squeeze" specific template for
|
||||
apt-cacher-ng
|
||||
|
||||
v1.9.2
|
||||
------
|
||||
- [COOK-2631] - Create Ubuntu 10.04 specific template for apt-cacher-ng
|
||||
|
||||
v1.9.0
|
||||
------
|
||||
- [COOK-2185] - Proxy for apt-key
|
||||
- [COOK-2338] - Support pinning by glob() or regexp
|
||||
|
||||
v1.8.4
|
||||
------
|
||||
- [COOK-2171] - Update README to clarify required Chef version: 10.18.0
|
||||
or higher.
|
||||
|
||||
v1.8.2
|
||||
------
|
||||
- [COOK-2112] - need [] around "arch" in sources.list entries
|
||||
- [COOK-2171] - fixes a regression in the notification
|
||||
|
||||
v1.8.0
|
||||
------
|
||||
- [COOK-2143] - Allow for a custom cacher-ng port
|
||||
- [COOK-2171] - On `apt_repository.run_action(:add)` the source file
|
||||
is not created.
|
||||
- [COOK-2184] - apt::cacher-ng, use `cacher_port` attribute in
|
||||
acng.conf
|
||||
|
||||
v1.7.0
|
||||
------
|
||||
- [COOK-2082] - add "arch" parameter to apt_repository LWRP
|
||||
|
||||
v1.6.0
|
||||
------
|
||||
- [COOK-1893] - `apt_preference` use "`package_name`" resource instead of "name"
|
||||
- [COOK-1894] - change filename for sources.list.d files
|
||||
- [COOK-1914] - Wrong dir permissions for /etc/apt/preferences.d/
|
||||
- [COOK-1942] - README.md has wrong name for the keyserver attribute
|
||||
- [COOK-2019] - create 01proxy before any other apt-get updates get executed
|
||||
|
||||
v1.5.2
|
||||
------
|
||||
- [COOK-1682] - use template instead of file resource in apt::cacher-client
|
||||
- [COOK-1875] - cacher-client should be Environment-aware
|
||||
|
||||
V1.5.0
|
||||
------
|
||||
- [COOK-1500] - Avoid triggering apt-get update
|
||||
- [COOK-1548] - Add execute commands for autoclean and autoremove
|
||||
- [COOK-1591] - Setting up the apt proxy should leave https
|
||||
connections direct
|
||||
- [COOK-1596] - execute[apt-get-update-periodic] never runs
|
||||
- [COOK-1762] - create /etc/apt/preferences.d directory
|
||||
- [COOK-1776] - apt key check isn't idempotent
|
||||
|
||||
v1.4.8
|
||||
------
|
||||
* Adds test-kitchen support
|
||||
- [COOK-1435] - repository lwrp is not idempotent with http key
|
||||
|
||||
v1.4.6
|
||||
------
|
||||
- [COOK-1530] - apt_repository isn't aware of update-success-stamp
|
||||
file (also reverts COOK-1382 patch).
|
||||
|
||||
v1.4.4
|
||||
------
|
||||
- [COOK-1229] - Allow cacher IP to be set manually in non-Chef Solo
|
||||
environments
|
||||
- [COOK-1530] - Immediately update apt-cache when sources.list file is dropped off
|
||||
|
||||
v1.4.2
|
||||
------
|
||||
- [COOK-1155] - LWRP for apt pinning
|
||||
|
||||
v1.4.0
|
||||
------
|
||||
- [COOK-889] - overwrite existing repo source files
|
||||
- [COOK-921] - optionally use cookbook\_file or remote\_file for key
|
||||
- [COOK-1032] - fixes problem with apt repository key installation
|
||||
@@ -0,0 +1,248 @@
|
||||
apt Cookbook
|
||||
============
|
||||
This cookbook includes recipes to execute apt-get update to ensure the local APT package cache is up to date. There are recipes for managing the apt-cacher-ng caching proxy and proxy clients. It also includes a LWRP for managing APT repositories in /etc/apt/sources.list.d as well as an LWRP for pinning packages via /etc/apt/preferences.d.
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
**Version 2.0.0+ of this cookbook requires Chef 11.0.0 or later**. If your Chef version is earlier than 11.0.0, use version 1.10.0 of this cookbook.
|
||||
|
||||
Version 1.8.2 to 1.10.0 of this cookbook requires **Chef 10.16.4** or later.
|
||||
|
||||
If your Chef version is earlier than 10.16.4, use version 1.7.0 of this cookbook.
|
||||
|
||||
### Platform
|
||||
Please refer to the [TESTING file](TESTING.md) to see the currently (and passing) tested platforms. The release was tested on:
|
||||
|
||||
* Ubuntu 10.04
|
||||
* Ubuntu 12.04
|
||||
* Ubuntu 13.04
|
||||
* Debian 7.1
|
||||
* Debian 6.0 (have with manual testing)
|
||||
|
||||
May work with or without modification on other Debian derivatives.
|
||||
|
||||
|
||||
-------
|
||||
### default
|
||||
This recipe installs the `update-notifier-common` package to provide the timestamp file used to only run `apt-get update` if the cache is more than one day old.
|
||||
|
||||
This recipe should appear first in the run list of Debian or Ubuntu nodes to ensure that the package cache is up to date before managing any `package` resources with Chef.
|
||||
|
||||
This recipe also sets up a local cache directory for preseeding packages.
|
||||
|
||||
**Including the default recipe on a node that does not support apt (such as Windows) results in a noop.**
|
||||
|
||||
### cacher-client
|
||||
Configures the node to use the `apt-cacher-ng` server as a client.
|
||||
|
||||
#### Bypassing the cache
|
||||
Occasionally you may come across repositories that do not play nicely when the node is using an `apt-cacher-ng` server. You can configure `cacher-client` to bypass the server and connect directly to the repository with the `cache_bypass` attribute.
|
||||
|
||||
To do this, you need to override the `cache_bypass` attribute with an array of repositories, with each array key as the repository URL and value as the protocol to use:
|
||||
|
||||
```json
|
||||
{
|
||||
...,
|
||||
'apt': {
|
||||
...,
|
||||
'cache_bypass': {
|
||||
URL: PROTOCOL
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
For example, to prevent caching and directly connect to the repository at `download.oracle.com` via http:
|
||||
|
||||
```json
|
||||
{
|
||||
'apt': {
|
||||
'cache_bypass': {
|
||||
'download.oracle.com': 'http'
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### cacher-ng
|
||||
Installs the `apt-cacher-ng` package and service so the system can provide APT caching. You can check the usage report at http://{hostname}:3142/acng-report.html.
|
||||
|
||||
If you wish to help the `cacher-ng` recipe seed itself, you must now explicitly include the `cacher-client` recipe in your run list **after** `cacher-ng` or you will block your ability to install any packages (ie. `apt-cacher-ng`).
|
||||
|
||||
|
||||
Attributes
|
||||
----------
|
||||
* `['apt']['cacher_ipaddress']` - use a cacher server (or standard proxy server) not available via search
|
||||
* `['apt']['cacher_interface]` - interface to connect to the cacher-ng service, no default.
|
||||
* `['apt']['cacher_port']` - port for the cacher-ng service (either client or server), default is '3142'
|
||||
* `['apt']['cacher_dir']` - directory used by cacher-ng service, default is '/var/cache/apt-cacher-ng'
|
||||
* `['apt']['cacher-client']['restrict_environment']` - restrict your node to using the `apt-cacher-ng` server in your Environment, default is 'false'
|
||||
* `['apt']['compiletime']` - force the `cacher-client` recipe to run before other recipes. It forces apt to use the proxy before other recipes run. Useful if your nodes have limited access to public apt repositories. This is overridden if the `cacher-ng` recipe is in your run list. Default is 'false'
|
||||
* `['apt']['cache_bypass']` - array of URLs to bypass the cache. Accepts the URL and protocol to fetch directly from the remote repository and not attempt to cache
|
||||
* `['apt']['periodic_update_min_delay']` - minimum delay (in seconds) beetween two actual executions of `apt-get update` by the `execute[apt-get-update-periodic]` resource, default is '86400' (24 hours)
|
||||
|
||||
Libraries
|
||||
---------
|
||||
There is an `interface_ipaddress` method that returns the IP address for a particular host and interface, used by the `cacher-client` recipe. To enable it on the server use the `['apt']['cacher_interface']` attribute.
|
||||
|
||||
Resources/Providers
|
||||
-------------------
|
||||
### `apt_repository`
|
||||
This LWRP provides an easy way to manage additional APT repositories. Adding a new repository will notify running the `execute[apt-get-update]` resource immediately.
|
||||
|
||||
#### Actions
|
||||
- :add: creates a repository file and builds the repository listing
|
||||
- :remove: removes the repository file
|
||||
|
||||
#### Attribute Parameters
|
||||
- repo_name: name attribute. The name of the channel to discover
|
||||
- uri: the base of the Debian distribution
|
||||
- distribution: this is usually your release's codename...ie something like `karmic`, `lucid` or `maverick`
|
||||
- components: package groupings..when it doubt use `main`
|
||||
- arch: constrain package to a particular arch like `i386`, `amd64` or even `armhf` or `powerpc`. Defaults to nil.
|
||||
- trusted: treat all packages from this repository as authenticated regardless of signature
|
||||
- deb_src: whether or not to add the repository as a source repo as well - value can be `true` or `false`, default `false`.
|
||||
- keyserver: the GPG keyserver where the key for the repo should be retrieved
|
||||
- key: if a `keyserver` is provided, this is assumed to be the fingerprint, otherwise it can be either the URI to the GPG key for the repo, or a cookbook_file.
|
||||
- key_proxy: if set, pass the specified proxy via `http-proxy=` to GPG.
|
||||
- cookbook: if key should be a cookbook_file, specify a cookbook where the key is located for files/default. Defaults to nil, so it will use the cookbook where the resource is used.
|
||||
|
||||
#### Examples
|
||||
|
||||
Add the Zenoss repo:
|
||||
|
||||
```ruby
|
||||
apt_repository 'zenoss' do
|
||||
uri 'http://dev.zenoss.org/deb'
|
||||
components ['main', 'stable']
|
||||
end
|
||||
```
|
||||
|
||||
Add the Nginx PPA, grabbing the key from keyserver:
|
||||
|
||||
```ruby
|
||||
apt_repository 'nginx-php' do
|
||||
uri 'http://ppa.launchpad.net/nginx/php5/ubuntu'
|
||||
distribution node['lsb']['codename']
|
||||
components ['main']
|
||||
keyserver 'keyserver.ubuntu.com'
|
||||
key 'C300EE8C'
|
||||
end
|
||||
```
|
||||
|
||||
Add the Nginx PPA, grab the key from the keyserver, and add source repo:
|
||||
|
||||
```ruby
|
||||
apt_repository 'nginx-php' do
|
||||
uri 'http://ppa.launchpad.net/nginx/php5/ubuntu'
|
||||
distribution node['lsb']['codename']
|
||||
components ['main']
|
||||
keyserver 'keyserver.ubuntu.com'
|
||||
key 'C300EE8C'
|
||||
deb_src true
|
||||
end
|
||||
```
|
||||
|
||||
Add the Cloudera Repo of CDH4 packages for Ubuntu 12.04 on AMD64:
|
||||
|
||||
```ruby
|
||||
apt_repository 'cloudera' do
|
||||
uri 'http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh'
|
||||
arch 'amd64'
|
||||
distribution 'precise-cdh4'
|
||||
components ['contrib']
|
||||
key 'http://archive.cloudera.com/debian/archive.key'
|
||||
end
|
||||
```
|
||||
|
||||
Remove Zenoss repo:
|
||||
|
||||
```ruby
|
||||
apt_repository 'zenoss' do
|
||||
action :remove
|
||||
end
|
||||
```
|
||||
|
||||
### `apt_preference`
|
||||
This LWRP provides an easy way to pin packages in /etc/apt/preferences.d. Although apt-pinning is quite helpful from time to time please note that Debian does not encourage its use without thorough consideration.
|
||||
|
||||
Further information regarding apt-pinning is available via http://wiki.debian.org/AptPreferences.
|
||||
|
||||
#### Actions
|
||||
- :add: creates a preferences file under /etc/apt/preferences.d
|
||||
- :remove: Removes the file, therefore unpin the package
|
||||
|
||||
#### Attribute Parameters
|
||||
- package_name: name attribute. The name of the package
|
||||
- glob: Pin by glob() expression or regexp surrounded by /.
|
||||
- pin: The package version/repository to pin
|
||||
- pin_priority: The pinning priority aka "the highest package version wins"
|
||||
|
||||
#### Examples
|
||||
Pin libmysqlclient16 to version 5.1.49-3:
|
||||
|
||||
```ruby
|
||||
apt_preference 'libmysqlclient16' do
|
||||
pin 'version 5.1.49-3'
|
||||
pin_priority '700'
|
||||
end
|
||||
```
|
||||
|
||||
Unpin libmysqlclient16:
|
||||
|
||||
```ruby
|
||||
apt_preference 'libmysqlclient16' do
|
||||
action :remove
|
||||
end
|
||||
```
|
||||
|
||||
Pin all packages from dotdeb.org:
|
||||
|
||||
```ruby
|
||||
apt_preference 'dotdeb' do
|
||||
glob '*'
|
||||
pin 'origin packages.dotdeb.org'
|
||||
pin_priority '700'
|
||||
end
|
||||
```
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
Put `recipe[apt]` first in the run list. If you have other recipes that you want to use to configure how apt behaves, like new sources, notify the execute resource to run, e.g.:
|
||||
|
||||
```ruby
|
||||
template '/etc/apt/sources.list.d/my_apt_sources.list' do
|
||||
notifies :run, 'execute[apt-get update]', :immediately
|
||||
end
|
||||
```
|
||||
|
||||
The above will run during execution phase since it is a normal template resource, and should appear before other package resources that need the sources in the template.
|
||||
|
||||
Put `recipe[apt::cacher-ng]` in the run_list for a server to provide APT caching and add `recipe[apt::cacher-client]` on the rest of the Debian-based nodes to take advantage of the caching server.
|
||||
|
||||
If you want to cleanup unused packages, there is also the `apt-get autoclean` and `apt-get autoremove` resources provided for automated cleanup.
|
||||
|
||||
|
||||
License & Authors
|
||||
-----------------
|
||||
- Author:: Joshua Timberman (joshua@opscode.com)
|
||||
- Author:: Matt Ray (matt@opscode.com)
|
||||
- Author:: Seth Chisamore (schisamo@opscode.com)
|
||||
|
||||
```text
|
||||
Copyright 2009-2013, Opscode, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
```
|
||||
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# Cookbook Name:: apt
|
||||
# Attributes:: default
|
||||
#
|
||||
# Copyright 2009-2013, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
default['apt']['cacher-client']['restrict_environment'] = false
|
||||
default['apt']['cacher_dir'] = '/var/cache/apt-cacher-ng'
|
||||
default['apt']['cacher_interface'] = nil
|
||||
default['apt']['cacher_port'] = 3142
|
||||
default['apt']['caching_server'] = false
|
||||
default['apt']['compiletime'] = false
|
||||
default['apt']['key_proxy'] = ''
|
||||
default['apt']['cache_bypass'] = {}
|
||||
default['apt']['periodic_update_min_delay'] = 86_400
|
||||
@@ -0,0 +1,50 @@
|
||||
[DEFAULT]
|
||||
;; All times are in seconds, but you can add a suffix
|
||||
;; for minutes(m), hours(h) or days(d)
|
||||
|
||||
;; commented out address so apt-proxy will listen on all IPs
|
||||
;; address = 127.0.0.1
|
||||
port = 9999
|
||||
cache_dir = /var/cache/apt-proxy
|
||||
|
||||
;; Control files (Packages/Sources/Contents) refresh rate
|
||||
min_refresh_delay = 1s
|
||||
complete_clientless_downloads = 1
|
||||
|
||||
;; Debugging settings.
|
||||
debug = all:4 db:0
|
||||
|
||||
time = 30
|
||||
passive_ftp = on
|
||||
|
||||
;;--------------------------------------------------------------
|
||||
;; Cache housekeeping
|
||||
|
||||
cleanup_freq = 1d
|
||||
max_age = 120d
|
||||
max_versions = 3
|
||||
|
||||
;;---------------------------------------------------------------
|
||||
;; Backend servers
|
||||
;;
|
||||
;; Place each server in its own [section]
|
||||
|
||||
[ubuntu]
|
||||
; Ubuntu archive
|
||||
backends =
|
||||
http://us.archive.ubuntu.com/ubuntu
|
||||
|
||||
[ubuntu-security]
|
||||
; Ubuntu security updates
|
||||
backends = http://security.ubuntu.com/ubuntu
|
||||
|
||||
[debian]
|
||||
;; Backend servers, in order of preference
|
||||
backends =
|
||||
http://debian.osuosl.org/debian/
|
||||
|
||||
[security]
|
||||
;; Debian security archive
|
||||
backends =
|
||||
http://security.debian.org/debian-security
|
||||
http://ftp2.de.debian.org/debian-security
|
||||
@@ -0,0 +1,48 @@
|
||||
#
|
||||
# Cookbook Name:: apt
|
||||
# Library:: helpers
|
||||
#
|
||||
# Copyright 2013 Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
module Apt
|
||||
# Helpers for apt
|
||||
module Helpers
|
||||
# Determines if apt is installed on a system.
|
||||
#
|
||||
# @return [Boolean]
|
||||
def apt_installed?
|
||||
!which('apt-get').nil?
|
||||
end
|
||||
|
||||
# Finds a command in $PATH
|
||||
#
|
||||
# @return [String, nil]
|
||||
def which(cmd)
|
||||
paths = (ENV['PATH'].split(::File::PATH_SEPARATOR) + %w(/bin /usr/bin /sbin /usr/sbin))
|
||||
|
||||
paths.each do |path|
|
||||
possible = File.join(path, cmd)
|
||||
return possible if File.executable?(possible)
|
||||
end
|
||||
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Chef::Recipe.send(:include, ::Apt::Helpers)
|
||||
Chef::Resource.send(:include, ::Apt::Helpers)
|
||||
Chef::Provider.send(:include, ::Apt::Helpers)
|
||||
@@ -0,0 +1,17 @@
|
||||
if defined?(ChefSpec)
|
||||
def add_apt_preference(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:apt_preference, :add, resource_name)
|
||||
end
|
||||
|
||||
def remove_apt_preference(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:apt_preference, :remove, resource_name)
|
||||
end
|
||||
|
||||
def add_apt_repository(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:apt_repository, :add, resource_name)
|
||||
end
|
||||
|
||||
def remove_apt_repository(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:apt_repository, :remove, resource_name)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,31 @@
|
||||
#
|
||||
# Cookbook Name:: apt
|
||||
# library:: network
|
||||
#
|
||||
# Copyright 2013, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
module ::Apt
|
||||
def interface_ipaddress(host, interface)
|
||||
if interface
|
||||
addresses = host['network']['interfaces'][interface]['addresses']
|
||||
addresses.select do |ip, data|
|
||||
return ip if data['family'].eql?('inet')
|
||||
end
|
||||
else
|
||||
return host.ipaddress
|
||||
end
|
||||
end
|
||||
end
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,34 @@
|
||||
name 'apt'
|
||||
maintainer 'Opscode, Inc.'
|
||||
maintainer_email 'cookbooks@opscode.com'
|
||||
license 'Apache 2.0'
|
||||
description 'Configures apt and apt services and LWRPs for managing apt repositories and preferences'
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version '2.3.8'
|
||||
recipe 'apt', 'Runs apt-get update during compile phase and sets up preseed directories'
|
||||
recipe 'apt::cacher-ng', 'Set up an apt-cacher-ng caching proxy'
|
||||
recipe 'apt::cacher-client', 'Client for the apt::cacher-ng caching proxy'
|
||||
|
||||
%w{ ubuntu debian }.each do |os|
|
||||
supports os
|
||||
end
|
||||
|
||||
attribute 'apt/cacher-client/restrict_environment',
|
||||
:description => 'Whether to restrict the search for the caching server to the same environment as this node',
|
||||
:default => 'false'
|
||||
|
||||
attribute 'apt/cacher_port',
|
||||
:description => 'Default listen port for the caching server',
|
||||
:default => '3142'
|
||||
|
||||
attribute 'apt/cacher_interface',
|
||||
:description => 'Default listen interface for the caching server',
|
||||
:default => nil
|
||||
|
||||
attribute 'apt/key_proxy',
|
||||
:description => 'Passed as the proxy passed to GPG for the apt_repository resource',
|
||||
:default => ''
|
||||
|
||||
attribute 'apt/caching_server',
|
||||
:description => 'Set this to true if the node is a caching server',
|
||||
:default => 'false'
|
||||
@@ -0,0 +1,63 @@
|
||||
#
|
||||
# Cookbook Name:: apt
|
||||
# Provider:: preference
|
||||
#
|
||||
# Copyright 2010-2011, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# Build preferences.d file contents
|
||||
def build_pref(package_name, pin, pin_priority)
|
||||
"Package: #{package_name}\nPin: #{pin}\nPin-Priority: #{pin_priority}\n"
|
||||
end
|
||||
|
||||
action :add do
|
||||
new_resource.updated_by_last_action(false)
|
||||
|
||||
preference = build_pref(
|
||||
new_resource.glob || new_resource.package_name,
|
||||
new_resource.pin,
|
||||
new_resource.pin_priority
|
||||
)
|
||||
|
||||
preference_dir = directory '/etc/apt/preferences.d' do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode 00755
|
||||
recursive true
|
||||
action :nothing
|
||||
end
|
||||
|
||||
preference_file = file "/etc/apt/preferences.d/#{new_resource.name}" do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode 00644
|
||||
content preference
|
||||
action :nothing
|
||||
end
|
||||
|
||||
preference_dir.run_action(:create)
|
||||
# write out the preference file, replace it if it already exists
|
||||
preference_file.run_action(:create)
|
||||
end
|
||||
|
||||
action :remove do
|
||||
if ::File.exists?("/etc/apt/preferences.d/#{new_resource.name}")
|
||||
Chef::Log.info "Un-pinning #{new_resource.name} from /etc/apt/preferences.d/"
|
||||
file "/etc/apt/preferences.d/#{new_resource.name}" do
|
||||
action :delete
|
||||
end
|
||||
new_resource.updated_by_last_action(true)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,150 @@
|
||||
#
|
||||
# Cookbook Name:: apt
|
||||
# Provider:: repository
|
||||
#
|
||||
# Copyright 2010-2011, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
use_inline_resources if defined?(use_inline_resources)
|
||||
|
||||
def whyrun_supported?
|
||||
true
|
||||
end
|
||||
|
||||
# install apt key from keyserver
|
||||
def install_key_from_keyserver(key, keyserver)
|
||||
execute "install-key #{key}" do
|
||||
if !node['apt']['key_proxy'].empty?
|
||||
command "apt-key adv --keyserver-options http-proxy=#{node['apt']['key_proxy']} --keyserver hkp://#{keyserver}:80 --recv #{key}"
|
||||
else
|
||||
command "apt-key adv --keyserver #{keyserver} --recv #{key}"
|
||||
end
|
||||
action :run
|
||||
not_if do
|
||||
extract_fingerprints_from_cmd('apt-key finger').any? do |fingerprint|
|
||||
fingerprint.end_with?(key.upcase)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# run command and extract gpg ids
|
||||
def extract_fingerprints_from_cmd(cmd)
|
||||
so = Mixlib::ShellOut.new(cmd)
|
||||
so.run_command
|
||||
so.stdout.split(/\n/).map do |t|
|
||||
if z = t.match(/^ +Key fingerprint = ([0-9A-F ]+)/)
|
||||
z[1].split.join
|
||||
end
|
||||
end.compact
|
||||
end
|
||||
|
||||
# install apt key from URI
|
||||
def install_key_from_uri(uri)
|
||||
key_name = uri.split(/\//).last
|
||||
cached_keyfile = "#{Chef::Config[:file_cache_path]}/#{key_name}"
|
||||
if new_resource.key =~ /http/
|
||||
remote_file cached_keyfile do
|
||||
source new_resource.key
|
||||
mode 00644
|
||||
action :create
|
||||
end
|
||||
else
|
||||
cookbook_file cached_keyfile do
|
||||
source new_resource.key
|
||||
cookbook new_resource.cookbook
|
||||
mode 00644
|
||||
action :create
|
||||
end
|
||||
end
|
||||
|
||||
execute "install-key #{key_name}" do
|
||||
command "apt-key add #{cached_keyfile}"
|
||||
action :run
|
||||
not_if do
|
||||
installed_keys = extract_fingerprints_from_cmd('apt-key finger')
|
||||
proposed_keys = extract_fingerprints_from_cmd("gpg --with-fingerprint #{cached_keyfile}")
|
||||
(installed_keys & proposed_keys).sort == proposed_keys.sort
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# build repo file contents
|
||||
def build_repo(uri, distribution, components, trusted, arch, add_deb_src)
|
||||
components = components.join(' ') if components.respond_to?(:join)
|
||||
repo_options = []
|
||||
repo_options << "arch=#{arch}" if arch
|
||||
repo_options << 'trusted=yes' if trusted
|
||||
repo_options = '[' + repo_options.join(' ') + ']' unless repo_options.empty?
|
||||
repo_info = "#{uri} #{distribution} #{components}\n"
|
||||
repo_info = "#{repo_options} #{repo_info}" unless repo_options.empty?
|
||||
repo = "deb #{repo_info}"
|
||||
repo << "deb-src #{repo_info}" if add_deb_src
|
||||
repo
|
||||
end
|
||||
|
||||
action :add do
|
||||
# add key
|
||||
if new_resource.keyserver && new_resource.key
|
||||
install_key_from_keyserver(new_resource.key, new_resource.keyserver)
|
||||
elsif new_resource.key
|
||||
install_key_from_uri(new_resource.key)
|
||||
end
|
||||
|
||||
file '/var/lib/apt/periodic/update-success-stamp' do
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute 'apt-cache gencaches' do
|
||||
ignore_failure true
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute 'apt-get update' do
|
||||
command "apt-get update -o Dir::Etc::sourcelist='sources.list.d/#{new_resource.name}.list' -o Dir::Etc::sourceparts='-' -o APT::Get::List-Cleanup='0'"
|
||||
ignore_failure true
|
||||
action :nothing
|
||||
notifies :run, 'execute[apt-cache gencaches]', :immediately
|
||||
end
|
||||
|
||||
# build repo file
|
||||
repository = build_repo(
|
||||
new_resource.uri,
|
||||
new_resource.distribution,
|
||||
new_resource.components,
|
||||
new_resource.trusted,
|
||||
new_resource.arch,
|
||||
new_resource.deb_src
|
||||
)
|
||||
|
||||
file "/etc/apt/sources.list.d/#{new_resource.name}.list" do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode 00644
|
||||
content repository
|
||||
action :create
|
||||
notifies :delete, 'file[/var/lib/apt/periodic/update-success-stamp]', :immediately
|
||||
notifies :run, 'execute[apt-get update]', :immediately if new_resource.cache_rebuild
|
||||
end
|
||||
end
|
||||
|
||||
action :remove do
|
||||
if ::File.exists?("/etc/apt/sources.list.d/#{new_resource.name}.list")
|
||||
Chef::Log.info "Removing #{new_resource.name} repository from /etc/apt/sources.list.d/"
|
||||
file "/etc/apt/sources.list.d/#{new_resource.name}.list" do
|
||||
action :delete
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,81 @@
|
||||
#
|
||||
# Cookbook Name:: apt
|
||||
# Recipe:: cacher-client
|
||||
#
|
||||
# Copyright 2011-2013 Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
class ::Chef::Recipe
|
||||
include ::Apt
|
||||
end
|
||||
|
||||
# remove Acquire::http::Proxy lines from /etc/apt/apt.conf since we use 01proxy
|
||||
# these are leftover from preseed installs
|
||||
execute 'Remove proxy from /etc/apt/apt.conf' do
|
||||
command "sed --in-place '/^Acquire::http::Proxy/d' /etc/apt/apt.conf"
|
||||
only_if 'grep Acquire::http::Proxy /etc/apt/apt.conf'
|
||||
end
|
||||
|
||||
servers = []
|
||||
if node['apt']
|
||||
if node['apt']['cacher_ipaddress']
|
||||
cacher = Chef::Node.new
|
||||
cacher.default.name = node['apt']['cacher_ipaddress']
|
||||
cacher.default.ipaddress = node['apt']['cacher_ipaddress']
|
||||
cacher.default.apt.cacher_port = node['apt']['cacher_port']
|
||||
cacher.default.apt_cacher_interface = node['apt']['cacher_interface']
|
||||
servers << cacher
|
||||
elsif node['apt']['caching_server']
|
||||
node.override['apt']['compiletime'] = false
|
||||
servers << node
|
||||
end
|
||||
end
|
||||
|
||||
unless Chef::Config[:solo] || servers.length > 0
|
||||
query = 'apt_caching_server:true'
|
||||
query += " AND chef_environment:#{node.chef_environment}" if node['apt']['cacher-client']['restrict_environment']
|
||||
Chef::Log.debug("apt::cacher-client searching for '#{query}'")
|
||||
servers += search(:node, query)
|
||||
end
|
||||
|
||||
if servers.length > 0
|
||||
Chef::Log.info("apt-cacher-ng server found on #{servers[0]}.")
|
||||
if servers[0]['apt']['cacher_interface']
|
||||
cacher_ipaddress = interface_ipaddress(servers[0], servers[0]['apt']['cacher_interface'])
|
||||
else
|
||||
cacher_ipaddress = servers[0].ipaddress
|
||||
end
|
||||
t = template '/etc/apt/apt.conf.d/01proxy' do
|
||||
source '01proxy.erb'
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode 00644
|
||||
variables(
|
||||
:proxy => cacher_ipaddress,
|
||||
:port => servers[0]['apt']['cacher_port'],
|
||||
:bypass => node['apt']['cache_bypass']
|
||||
)
|
||||
action(node['apt']['compiletime'] ? :nothing : :create)
|
||||
notifies :run, 'execute[apt-get update]', :immediately
|
||||
end
|
||||
t.run_action(:create) if node['apt']['compiletime']
|
||||
else
|
||||
Chef::Log.info('No apt-cacher-ng server found.')
|
||||
file '/etc/apt/apt.conf.d/01proxy' do
|
||||
action :delete
|
||||
end
|
||||
end
|
||||
|
||||
include_recipe 'apt::default'
|
||||
@@ -0,0 +1,43 @@
|
||||
#
|
||||
# Cookbook Name:: apt
|
||||
# Recipe:: cacher-ng
|
||||
#
|
||||
# Copyright 2008-2013, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the 'License');
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an 'AS IS' BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
node.set['apt']['caching_server'] = true
|
||||
|
||||
package 'apt-cacher-ng' do
|
||||
action :install
|
||||
end
|
||||
|
||||
directory node['apt']['cacher_dir'] do
|
||||
owner 'apt-cacher-ng'
|
||||
group 'apt-cacher-ng'
|
||||
mode 0755
|
||||
end
|
||||
|
||||
template '/etc/apt-cacher-ng/acng.conf' do
|
||||
source 'acng.conf.erb'
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode 00644
|
||||
notifies :restart, 'service[apt-cacher-ng]', :immediately
|
||||
end
|
||||
|
||||
service 'apt-cacher-ng' do
|
||||
supports :restart => true, :status => false
|
||||
action [:enable, :start]
|
||||
end
|
||||
@@ -0,0 +1,82 @@
|
||||
#
|
||||
# Cookbook Name:: apt
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2008-2013, Opscode, Inc.
|
||||
# Copyright 2009, Bryan McLellan <btm@loftninjas.org>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the 'License');
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an 'AS IS' BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# On systems where apt is not installed, the resources in this recipe are not
|
||||
# executed. However, they _must_ still be present in the resource collection
|
||||
# or other cookbooks which notify these resources will fail on non-apt-enabled
|
||||
# systems.
|
||||
|
||||
Chef::Log.debug 'apt is not installed. Apt-specific resources will not be executed.' unless apt_installed?
|
||||
|
||||
# Run apt-get update to create the stamp file
|
||||
execute 'apt-get-update' do
|
||||
command 'apt-get update'
|
||||
ignore_failure true
|
||||
only_if { apt_installed? }
|
||||
not_if { ::File.exists?('/var/lib/apt/periodic/update-success-stamp') }
|
||||
end
|
||||
|
||||
# For other recipes to call to force an update
|
||||
execute 'apt-get update' do
|
||||
command 'apt-get update'
|
||||
ignore_failure true
|
||||
only_if { apt_installed? }
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# Automatically remove packages that are no longer needed for dependencies
|
||||
execute 'apt-get autoremove' do
|
||||
command 'apt-get -y autoremove'
|
||||
only_if { apt_installed? }
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# Automatically remove .deb files for packages no longer on your system
|
||||
execute 'apt-get autoclean' do
|
||||
command 'apt-get -y autoclean'
|
||||
only_if { apt_installed? }
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# provides /var/lib/apt/periodic/update-success-stamp on apt-get update
|
||||
package 'update-notifier-common' do
|
||||
notifies :run, 'execute[apt-get-update]', :immediately
|
||||
only_if { apt_installed? }
|
||||
end
|
||||
|
||||
execute 'apt-get-update-periodic' do
|
||||
command 'apt-get update'
|
||||
ignore_failure true
|
||||
only_if do
|
||||
apt_installed? &&
|
||||
::File.exists?('/var/lib/apt/periodic/update-success-stamp') &&
|
||||
::File.mtime('/var/lib/apt/periodic/update-success-stamp') < Time.now - node['apt']['periodic_update_min_delay']
|
||||
end
|
||||
end
|
||||
|
||||
%w{/var/cache/local /var/cache/local/preseeding}.each do |dirname|
|
||||
directory dirname do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode 00755
|
||||
action :create
|
||||
only_if { apt_installed? }
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# Cookbook Name:: apt
|
||||
# Resource:: preference
|
||||
#
|
||||
# Copyright 2010-2013, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
actions :add, :remove
|
||||
default_action :add if defined?(default_action) # Chef > 10.8
|
||||
|
||||
# Needed for Chef versions < 0.10.10
|
||||
def initialize(*args)
|
||||
super
|
||||
@action = :add
|
||||
end
|
||||
|
||||
attribute :package_name, :kind_of => String, :name_attribute => true
|
||||
attribute :glob, :kind_of => String
|
||||
attribute :pin, :kind_of => String
|
||||
attribute :pin_priority, :kind_of => String
|
||||
@@ -0,0 +1,43 @@
|
||||
#
|
||||
# Cookbook Name:: apt
|
||||
# Resource:: repository
|
||||
#
|
||||
# Copyright 2010-2013, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
actions :add, :remove
|
||||
default_action :add if defined?(default_action) # Chef > 10.8
|
||||
|
||||
# Needed for Chef versions < 0.10.10
|
||||
def initialize(*args)
|
||||
super
|
||||
@action = :add
|
||||
end
|
||||
|
||||
# name of the repo, used for source.list filename
|
||||
attribute :repo_name, :kind_of => String, :name_attribute => true
|
||||
attribute :uri, :kind_of => String
|
||||
attribute :distribution, :kind_of => String
|
||||
attribute :components, :kind_of => Array, :default => []
|
||||
attribute :arch, :kind_of => String, :default => nil
|
||||
attribute :trusted, :kind_of => [TrueClass, FalseClass], :default => false
|
||||
# whether or not to add the repository as a source repo as well
|
||||
attribute :deb_src, :default => false
|
||||
attribute :keyserver, :kind_of => String, :default => nil
|
||||
attribute :key, :kind_of => String, :default => nil
|
||||
attribute :cookbook, :kind_of => String, :default => nil
|
||||
# trigger cache rebuild
|
||||
# If not you can trigger in the recipe itself after checking the status of resource.updated{_by_last_action}?
|
||||
attribute :cache_rebuild, :kind_of => [TrueClass, FalseClass], :default => true
|
||||
@@ -0,0 +1,173 @@
|
||||
# Letter case in directive names does not matter. Must be separated with colons.
|
||||
# Valid boolean values are a zero number for false, non-zero numbers for true.
|
||||
|
||||
CacheDir: <%= node['apt']['cacher_dir'] %>
|
||||
|
||||
# set empty to disable logging
|
||||
LogDir: /var/log/apt-cacher-ng
|
||||
|
||||
# TCP (http) port
|
||||
# Set to 9999 to emulate apt-proxy
|
||||
Port:<%= node['apt']['cacher_port'] %>
|
||||
|
||||
# Addresses or hostnames to listen on. Multiple addresses must be separated by
|
||||
# spaces. Each entry must be associated with a local interface. DNS resolution
|
||||
# is performed using getaddrinfo(3) for all available protocols (i.e. IPv4 and
|
||||
# IPv6 if available).
|
||||
#
|
||||
# Default: not set, will listen on all interfaces.
|
||||
#
|
||||
# BindAddress: localhost 192.168.7.254 publicNameOnMainInterface
|
||||
|
||||
#Proxy: http://www-proxy.example.net:80
|
||||
#proxy: http://username:proxypassword@proxy.example.net:3128
|
||||
|
||||
# Repository remapping. See manual for details.
|
||||
# In this example, backends file is generated during package installation.
|
||||
Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian
|
||||
Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu
|
||||
Remap-debvol: file:debvol_mirror*.gz /debian-volatile ; file:backends_debvol
|
||||
Remap-cygwin: file:cygwin_mirrors /cygwin # ; file:backends_cygwin # incomplete, please create this file
|
||||
|
||||
# Virtual page accessible in a web browser to see statistics and status
|
||||
# information, i.e. under http://localhost:3142/acng-report.html
|
||||
ReportPage: acng-report.html
|
||||
|
||||
# Socket file for accessing through local UNIX socket instead of TCP/IP. Can be
|
||||
# used with inetd bridge or cron client.
|
||||
# SocketPath:/var/run/apt-cacher-ng/socket
|
||||
|
||||
# Forces log file to be written to disk after every line when set to 1. Default
|
||||
# is 0, buffer flush happens after client disconnects.
|
||||
#
|
||||
# (technically, this is an alias to the Debug option provided for convenience)
|
||||
#
|
||||
# UnbufferLogs: 0
|
||||
|
||||
# Set to 0 to store only type, time and transfer sizes.
|
||||
# 1 -> client IP and relative local path are logged too
|
||||
# VerboseLog: 1
|
||||
|
||||
# Don't detach from the console
|
||||
# ForeGround: 0
|
||||
|
||||
# Store the pid of the daemon process therein
|
||||
# PidFile: /var/run/apt-cacher-ng/pid
|
||||
|
||||
# Forbid outgoing connections, work around them or respond with 503 error
|
||||
# offlinemode:0
|
||||
|
||||
# Forbid all downloads that don't run through preconfigured backends (.where)
|
||||
#ForceManaged: 0
|
||||
|
||||
# Days before considering an unreferenced file expired (to be deleted).
|
||||
# Warning: if the value is set too low and particular index files are not
|
||||
# available for some days (mirror downtime) there is a risk of deletion of
|
||||
# still usefull package files.
|
||||
ExTreshold: 4
|
||||
|
||||
# Stop expiration when a critical problem appeared. Currently only failed
|
||||
# refresh of an index file is considered as critical.
|
||||
#
|
||||
# WARNING: don't touch this option or set to a non-zero number.
|
||||
# Anything else is DANGEROUS and may cause data loss.
|
||||
#
|
||||
# ExAbortOnProblems: 1
|
||||
|
||||
# Replace some Windows/DOS-FS incompatible chars when storing
|
||||
# StupidFs: 0
|
||||
|
||||
# Experimental feature for apt-listbugs: pass-through SOAP requests and
|
||||
# responses to/from bugs.debian.org. If not set, default is true if
|
||||
# ForceManaged is enabled and false otherwise.
|
||||
# ForwardBtsSoap: 1
|
||||
|
||||
# The daemon has a small cache for DNS data, to speed up resolution. The
|
||||
# expiration time of the DNS entries can be configured in seconds.
|
||||
# DnsCacheSeconds: 3600
|
||||
|
||||
# Don't touch the following values without good consideration!
|
||||
#
|
||||
# Max. count of connection threads kept ready (for faster response in the
|
||||
# future). Should be a sane value between 0 and average number of connections,
|
||||
# and depend on the amount of spare RAM.
|
||||
# MaxStandbyConThreads: 8
|
||||
#
|
||||
# Hard limit of active thread count for incomming connections, i.e. operation
|
||||
# is refused when this value is reached (below zero = unlimited).
|
||||
# MaxConThreads: -1
|
||||
#
|
||||
#VfilePattern = (^|.*?/)(Index|Packages\.bz2|Packages\.gz|Packages|Release|Release\.gpg|Sources\.bz2|Sources\.gz|Sources|release|index\.db-.*\.gz|Contents-[^/]*\.gz|pkglist[^/]*\.bz2|rclist[^/]*\.bz2|/meta-release[^/]*|Translation[^/]*\.bz2)$
|
||||
#PfilePattern = .*(\.deb|\.rpm|\.dsc|\.tar\.gz\.gpg|\.tar\.gz|\.diff\.gz|\.diff\.bz2|\.jigdo|\.template|changelog|copyright|\.udeb|\.diff/.*\.gz|vmlinuz|initrd\.gz|(Devel)?ReleaseAnnouncement(\\?.*)?)$
|
||||
# Whitelist for expiration, file types not to be removed even when being
|
||||
# unreferenced. Default: same as VfilePattern which is a safe bed. When and
|
||||
# only when the only used mirrors are official repositories (with working
|
||||
# Release files) then it might be set to something more restrictive, like
|
||||
# (^|.*?/)(Release|Release\.gpg|release|meta-release|Translation[^/]*\.bz2)$
|
||||
#WfilePattern = (^|.*?/)(Index|Packages\.bz2|Packages\.gz|Packages|Release|Release\.gpg|Sources\.bz2|Sources\.gz|Sources|release|index\.db-.*\.gz|Contents-[^/]*\.gz|pkglist[^/]*\.bz2|rclist[^/]*\.bz2|/meta-release[^/]*|Translation[^/]*\.bz2)$
|
||||
|
||||
# Higher modes only working with the debug version
|
||||
# Warning, writes a lot into apt-cacher.err logfile
|
||||
# Value overwrites UnbufferLogs setting (aliased)
|
||||
# Debug:3
|
||||
|
||||
# Usually, general purpose proxies like Squid expose the IP adress of the
|
||||
# client user to the remote server using the X-Forwarded-For HTTP header. This
|
||||
# behaviour can be optionally turned on with the Expose-Origin option.
|
||||
# ExposeOrigin: 0
|
||||
|
||||
# When logging the originating IP address, trust the information supplied by
|
||||
# the client in the X-Forwarded-For header.
|
||||
# LogSubmittedOrigin: 0
|
||||
|
||||
# The version string reported to the peer, to be displayed as HTTP client (and
|
||||
# version) in the logs of the mirror.
|
||||
# WARNING: some archives use this header to detect/guess capabilities of the
|
||||
# client (i.e. redirection support) and change the behaviour accordingly, while
|
||||
# ACNG might not support the expected features. Expect side effects.
|
||||
#
|
||||
# UserAgent: Yet Another HTTP Client/1.2.3p4
|
||||
|
||||
# In some cases the Import and Expiration tasks might create fresh volatile
|
||||
# data for internal use by reconstructing them using patch files. This
|
||||
# by-product might be recompressed with bzip2 and with some luck the resulting
|
||||
# file becomes identical to the *.bz2 file on the server, usable for APT
|
||||
# clients trying to fetch the full .bz2 compressed version. Injection of the
|
||||
# generated files into the cache has however a disadvantage on underpowered
|
||||
# servers: bzip2 compession can create high load on the server system and the
|
||||
# visible download of the busy .bz2 files also becomes slower.
|
||||
#
|
||||
# RecompBz2: 0
|
||||
|
||||
# Network timeout for outgoing connections.
|
||||
# NetworkTimeout: 60
|
||||
|
||||
# Sometimes it makes sense to not store the data in cache and just return the
|
||||
# package data to client as it comes in. DontCache parameters can enable this
|
||||
# behaviour for certain URL types. The tokens are extended regular expressions
|
||||
# that URLs are matched against.
|
||||
#
|
||||
# DontCacheRequested is applied to the URL as it comes in from the client.
|
||||
# Example: exclude packages built with kernel-package for x86
|
||||
# DontCacheRequested: linux-.*_10\...\.Custo._i386
|
||||
# Example usecase: exclude popular private IP ranges from caching
|
||||
# DontCacheRequested: 192.168.0 ^10\..* 172.30
|
||||
#
|
||||
# DontCacheResolved is applied to URLs after mapping to the target server. If
|
||||
# multiple backend servers are specified then it's only matched against the
|
||||
# download link for the FIRST possible source (due to implementation limits).
|
||||
# Example usecase: all Ubuntu stuff comes from a local mirror (specified as
|
||||
# backend), don't cache it again:
|
||||
# DontCacheResolved: ubuntumirror.local.net
|
||||
#
|
||||
# DontCache directive sets (overrides) both, DontCacheResolved and
|
||||
# DontCacheRequested. Provided for convenience, see those directives for
|
||||
# details.
|
||||
#
|
||||
# Default permission set of freshly created files and directories, as octal
|
||||
# numbers (see chmod(1) for details).
|
||||
# Can by limited by the umask value (see umask(2) for details) if it's set in
|
||||
# the environment of the starting shell, e.g. in apt-cacher-ng init script or
|
||||
# in its configuration file.
|
||||
# DirPerms: 00755
|
||||
# FilePerms: 00664
|
||||
@@ -0,0 +1,5 @@
|
||||
Acquire::http::Proxy "http://<%= @proxy %>:<%= @port %>";
|
||||
Acquire::https::Proxy "DIRECT";
|
||||
<% @bypass.each do |bypass, type| %>
|
||||
Acquire::<%= type %>::Proxy::<%= bypass %> "DIRECT";
|
||||
<% end %>
|
||||
@@ -0,0 +1,275 @@
|
||||
# Letter case in directive names does not matter. Must be separated with colons.
|
||||
# Valid boolean values are a zero number for false, non-zero numbers for true.
|
||||
|
||||
CacheDir: <%= node['apt']['cacher_dir'] %>
|
||||
|
||||
# set empty to disable logging
|
||||
LogDir: /var/log/apt-cacher-ng
|
||||
|
||||
# place to look for additional configuration and resource files if they are not
|
||||
# found in the configuration directory
|
||||
# SupportDir: /usr/lib/apt-cacher-ng
|
||||
|
||||
# TCP (http) port
|
||||
# Set to 9999 to emulate apt-proxy
|
||||
Port:<%= node['apt']['cacher_port'] %>
|
||||
|
||||
# Addresses or hostnames to listen on. Multiple addresses must be separated by
|
||||
# spaces. Each entry must be an exact local address which is associated with a
|
||||
# local interface. DNS resolution is performed using getaddrinfo(3) for all
|
||||
# available protocols (IPv4, IPv6, ...). Using a protocol specific format will
|
||||
# create binding(s) only on protocol specific socket(s) (e.g. 0.0.0.0 will listen
|
||||
# only to IPv4).
|
||||
#
|
||||
# Default: not set, will listen on all interfaces and protocols
|
||||
#
|
||||
# BindAddress: localhost 192.168.7.254 publicNameOnMainInterface
|
||||
|
||||
# The specification of another proxy which shall be used for downloads.
|
||||
# Username and password are, and see manual for limitations.
|
||||
#
|
||||
#Proxy: http://www-proxy.example.net:80
|
||||
#proxy: username:proxypassword@proxy.example.net:3128
|
||||
|
||||
# Repository remapping. See manual for details.
|
||||
# In this example, some backends files might be generated during package
|
||||
# installation using information collected on the system.
|
||||
Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian # Debian Archives
|
||||
Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu # Ubuntu Archives
|
||||
Remap-debvol: file:debvol_mirror*.gz /debian-volatile ; file:backends_debvol # Debian Volatile Archives
|
||||
Remap-cygwin: file:cygwin_mirrors /cygwin # ; file:backends_cygwin # incomplete, please create this file or specify preferred mirrors here
|
||||
Remap-sfnet: file:sfnet_mirrors # ; file:backends_sfnet # incomplete, please create this file or specify preferred mirrors here
|
||||
Remap-alxrep: file:archlx_mirrors /archlinux # ; file:backend_archlx # Arch Linux
|
||||
Remap-fedora: file:fedora_mirrors # Fedora Linux
|
||||
Remap-epel: file:epel_mirrors # Fedora EPEL
|
||||
Remap-slrep: file:sl_mirrors # Scientific Linux
|
||||
|
||||
# This is usually not needed for security.debian.org because it's always the
|
||||
# same DNS hostname. However, it might be enabled in order to use hooks,
|
||||
# ForceManaged mode or special flags in this context.
|
||||
# Remap-secdeb: security.debian.org
|
||||
|
||||
# Virtual page accessible in a web browser to see statistics and status
|
||||
# information, i.e. under http://localhost:3142/acng-report.html
|
||||
ReportPage: acng-report.html
|
||||
|
||||
# Socket file for accessing through local UNIX socket instead of TCP/IP. Can be
|
||||
# used with inetd bridge or cron client.
|
||||
# SocketPath:/var/run/apt-cacher-ng/socket
|
||||
|
||||
# Forces log file to be written to disk after every line when set to 1. Default
|
||||
# is 0, buffers are flushed when the client disconnects.
|
||||
#
|
||||
# (technically, alias to the Debug option, see its documentation for details)
|
||||
#
|
||||
# UnbufferLogs: 0
|
||||
|
||||
# Set to 0 to store only type, time and transfer sizes.
|
||||
# 1 -> client IP and relative local path are logged too
|
||||
# VerboseLog: 1
|
||||
|
||||
# Don't detach from the console
|
||||
# ForeGround: 0
|
||||
|
||||
# Store the pid of the daemon process therein
|
||||
# PidFile: /var/run/apt-cacher-ng/pid
|
||||
|
||||
# Forbid outgoing connections, work around them or respond with 503 error
|
||||
# offlinemode:0
|
||||
|
||||
# Forbid all downloads that don't run through preconfigured backends (.where)
|
||||
#ForceManaged: 0
|
||||
|
||||
# Days before considering an unreferenced file expired (to be deleted).
|
||||
# Warning: if the value is set too low and particular index files are not
|
||||
# available for some days (mirror downtime) there is a risk of deletion of
|
||||
# still useful package files.
|
||||
ExTreshold: 4
|
||||
|
||||
# Stop expiration when a critical problem appeared. Currently only failed
|
||||
# refresh of an index file is considered as critical.
|
||||
#
|
||||
# WARNING: don't touch this option or set to zero.
|
||||
# Anything else is DANGEROUS and may cause data loss.
|
||||
#
|
||||
# ExAbortOnProblems: 1
|
||||
|
||||
# Replace some Windows/DOS-FS incompatible chars when storing
|
||||
# StupidFs: 0
|
||||
|
||||
# Experimental feature for apt-listbugs: pass-through SOAP requests and
|
||||
# responses to/from bugs.debian.org. If not set, default is true if
|
||||
# ForceManaged is enabled and false otherwise.
|
||||
# ForwardBtsSoap: 1
|
||||
|
||||
# The daemon has a small cache for DNS data, to speed up resolution. The
|
||||
# expiration time of the DNS entries can be configured in seconds.
|
||||
# DnsCacheSeconds: 3600
|
||||
|
||||
# Don't touch the following values without good consideration!
|
||||
#
|
||||
# Max. count of connection threads kept ready (for faster response in the
|
||||
# future). Should be a sane value between 0 and average number of connections,
|
||||
# and depend on the amount of spare RAM.
|
||||
# MaxStandbyConThreads: 8
|
||||
#
|
||||
# Hard limit of active thread count for incoming connections, i.e. operation
|
||||
# is refused when this value is reached (below zero = unlimited).
|
||||
# MaxConThreads: -1
|
||||
#
|
||||
# Pigeonholing files with regular expressions (static/volatile). Can be
|
||||
# overriden here but not should not be done permanently because future update
|
||||
# of default settings would not be applied later.
|
||||
# VfilePattern = (^|.*?/)(Index|Packages(\.gz|\.bz2|\.lzma|\.xz)?|InRelease|Release|Release\.gpg|Sources(\.gz|\.bz2|\.lzma|\.xz)?|release|index\.db-.*\.gz|Contents-[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|pkglist[^/]*\.bz2|rclist[^/]*\.bz2|/meta-release[^/]*|Translation[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|MD5SUMS|SHA1SUMS|((setup|setup-legacy)(\.ini|\.bz2|\.hint)(\.sig)?)|mirrors\.lst|repo(index|md)\.xml(\.asc|\.key)?|directory\.yast|products|content(\.asc|\.key)?|media|filelists\.xml\.gz|filelists\.sqlite\.bz2|repomd\.xml|packages\.[a-zA-Z][a-zA-Z]\.gz|info\.txt|license\.tar\.gz|license\.zip|.*\.db(\.tar\.gz)?|.*\.files\.tar\.gz|.*\.abs\.tar\.gz|metalink\?repo|.*prestodelta\.xml\.gz)$|/dists/.*/installer-[^/]+/[^0-9][^/]+/images/.*
|
||||
# PfilePattern = .*(\.d?deb|\.rpm|\.dsc|\.tar(\.gz|\.bz2|\.lzma|\.xz)(\.gpg)?|\.diff(\.gz|\.bz2|\.lzma|\.xz)|\.jigdo|\.template|changelog|copyright|\.udeb|\.debdelta|\.diff/.*\.gz|(Devel)?ReleaseAnnouncement(\?.*)?|[a-f0-9]+-(susedata|updateinfo|primary|deltainfo).xml.gz|fonts/(final/)?[a-z]+32.exe(\?download.*)?|/dists/.*/installer-[^/]+/[0-9][^/]+/images/.*)$
|
||||
# Whitelist for expiration, file types not to be removed even when being
|
||||
# unreferenced. Default: many parts from VfilePattern where no parent index
|
||||
# exists or might be unknown.
|
||||
# WfilePattern = (^|.*?/)(Release|InRelease|Release\.gpg|(Packages|Sources)(\.gz|\.bz2|\.lzma|\.xz)?|Translation[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|MD5SUMS|SHA1SUMS|.*\.xml|.*\.db\.tar\.gz|.*\.files\.tar\.gz|.*\.abs\.tar\.gz|[a-z]+32.exe)$|/dists/.*/installer-.*/images/.*
|
||||
|
||||
# Higher modes only working with the debug version
|
||||
# Warning, writes a lot into apt-cacher.err logfile
|
||||
# Value overwrites UnbufferLogs setting (aliased)
|
||||
# Debug:3
|
||||
|
||||
# Usually, general purpose proxies like Squid expose the IP address of the
|
||||
# client user to the remote server using the X-Forwarded-For HTTP header. This
|
||||
# behaviour can be optionally turned on with the Expose-Origin option.
|
||||
# ExposeOrigin: 0
|
||||
|
||||
# When logging the originating IP address, trust the information supplied by
|
||||
# the client in the X-Forwarded-For header.
|
||||
# LogSubmittedOrigin: 0
|
||||
|
||||
# The version string reported to the peer, to be displayed as HTTP client (and
|
||||
# version) in the logs of the mirror.
|
||||
# WARNING: some archives use this header to detect/guess capabilities of the
|
||||
# client (i.e. redirection support) and change the behaviour accordingly, while
|
||||
# ACNG might not support the expected features. Expect side effects.
|
||||
#
|
||||
# UserAgent: Yet Another HTTP Client/1.2.3p4
|
||||
|
||||
# In some cases the Import and Expiration tasks might create fresh volatile
|
||||
# data for internal use by reconstructing them using patch files. This
|
||||
# by-product might be recompressed with bzip2 and with some luck the resulting
|
||||
# file becomes identical to the *.bz2 file on the server, usable for APT
|
||||
# clients trying to fetch the full .bz2 compressed version. Injection of the
|
||||
# generated files into the cache has however a disadvantage on underpowered
|
||||
# servers: bzip2 compression can create high load on the server system and the
|
||||
# visible download of the busy .bz2 files also becomes slower.
|
||||
#
|
||||
# RecompBz2: 0
|
||||
|
||||
# Network timeout for outgoing connections.
|
||||
# NetworkTimeout: 60
|
||||
|
||||
# Sometimes it makes sense to not store the data in cache and just return the
|
||||
# package data to client as it comes in. DontCache parameters can enable this
|
||||
# behaviour for certain URL types. The tokens are extended regular expressions
|
||||
# that URLs are matched against.
|
||||
#
|
||||
# DontCacheRequested is applied to the URL as it comes in from the client.
|
||||
# Example: exclude packages built with kernel-package for x86
|
||||
# DontCacheRequested: linux-.*_10\...\.Custo._i386
|
||||
# Example usecase: exclude popular private IP ranges from caching
|
||||
# DontCacheRequested: 192.168.0 ^10\..* 172.30
|
||||
#
|
||||
# DontCacheResolved is applied to URLs after mapping to the target server. If
|
||||
# multiple backend servers are specified then it's only matched against the
|
||||
# download link for the FIRST possible source (due to implementation limits).
|
||||
# Example usecase: all Ubuntu stuff comes from a local mirror (specified as
|
||||
# backend), don't cache it again:
|
||||
# DontCacheResolved: ubuntumirror.local.net
|
||||
#
|
||||
# DontCache directive sets (overrides) both, DontCacheResolved and
|
||||
# DontCacheRequested. Provided for convenience, see those directives for
|
||||
# details.
|
||||
#
|
||||
# Default permission set of freshly created files and directories, as octal
|
||||
# numbers (see chmod(1) for details).
|
||||
# Can by limited by the umask value (see umask(2) for details) if it's set in
|
||||
# the environment of the starting shell, e.g. in apt-cacher-ng init script or
|
||||
# in its configuration file.
|
||||
# DirPerms: 00755
|
||||
# FilePerms: 00664
|
||||
#
|
||||
#
|
||||
# It's possible to use use apt-cacher-ng as a regular web server with limited
|
||||
# feature set, i.e.
|
||||
# including directory browsing and download of any file;
|
||||
# excluding sorting, mime types/encodings, CGI execution, index page
|
||||
# redirection and other funny things.
|
||||
# To get this behavior, mappings between virtual directories and real
|
||||
# directories on the server must be defined with the LocalDirs directive.
|
||||
# Virtual and real dirs are separated by spaces, multiple pairs are separated
|
||||
# by semi-colons. Real directories must be absolute paths.
|
||||
# NOTE: Since the names of that key directories share the same namespace as
|
||||
# repository names (see Remap-...) it's administrators job to avoid such
|
||||
# collisions on them (unless created deliberately).
|
||||
#
|
||||
# LocalDirs: woo /data/debarchive/woody ; hamm /data/debarchive/hamm
|
||||
|
||||
# Precache a set of files referenced by specified index files. This can be used
|
||||
# to create a partial mirror usable for offline work. There are certain limits
|
||||
# and restrictions on the path specification, see manual for details. A list of
|
||||
# (maybe) relevant index files could be retrieved via
|
||||
# "apt-get --print-uris update" on a client machine.
|
||||
#
|
||||
# PrecacheFor: debrep/dists/unstable/*/source/Sources* debrep/dists/unstable/*/binary-amd64/Packages*
|
||||
|
||||
# Arbitrary set of data to append to request headers sent over the wire. Should
|
||||
# be a well formated HTTP headers part including newlines (DOS style) which
|
||||
# can be entered as escape sequences (\r\n).
|
||||
# RequestAppendix: X-Tracking-Choice: do-not-track\r\n
|
||||
|
||||
# Specifies the IP protocol families to use for remote connections. Order does
|
||||
# matter, first specified are considered first. Possible combinations:
|
||||
# v6 v4
|
||||
# v4 v6
|
||||
# v6
|
||||
# v4
|
||||
# (empty or not set: use system default)
|
||||
#
|
||||
# ConnectProto: v6 v4
|
||||
|
||||
# Regular expiration algorithm finds package files which are no longer listed
|
||||
# in any index file and removes them of them after a safety period.
|
||||
# This option allows to keep more versions of a package in the cache after
|
||||
# safety period is over.
|
||||
# KeepExtraVersions: 1
|
||||
|
||||
# Optionally uses TCP access control provided by libwrap, see hosts_access(5)
|
||||
# for details. Daemon name is apt-cacher-ng. Default if not set: decided on
|
||||
# startup by looking for explicit mentioning of apt-cacher-ng in
|
||||
# /etc/hosts.allow or /etc/hosts.deny files.
|
||||
# UseWrap: 0
|
||||
|
||||
# If many machines from the same local network attempt to update index files
|
||||
# (apt-get update) at nearly the same time, the known state of these index file
|
||||
# is temporarily frozen and multiple requests receive the cached response
|
||||
# without contacting the server. This parameter (in seconds) specifies the
|
||||
# length of this period before the files are considered outdated.
|
||||
# Setting it too low transfers more data and increases remote server load,
|
||||
# setting it too high (more than a couple of minutes) increases the risk of
|
||||
# delivering inconsistent responses to the clients.
|
||||
# FreshIndexMaxAge: 27
|
||||
|
||||
# Usually the users are not allowed to specify custom TCP ports of remote
|
||||
# mirrors in the requests, only the default HTTP port can be used (instead,
|
||||
# proxy administrator can create Remap- rules with custom ports). This
|
||||
# restriction can be disabled by specifying a list of allowed ports or 0 for
|
||||
# any port.
|
||||
#
|
||||
# AllowUserPorts: 80
|
||||
|
||||
# Normally the HTTP redirection responses are forwarded to the original caller
|
||||
# (i.e. APT) which starts a new download attempt from the new URL. This
|
||||
# solution is ok for client configurations with proxy mode but doesn't work
|
||||
# well with configurations using URL prefixes. To work around this the server
|
||||
# can restart its own download with another URL. However, this might be used to
|
||||
# circumvent download source policies by malicious users.
|
||||
# The RedirMax option specifies how many such redirects the server should
|
||||
# follow per request, 0 disables the internal redirection. If not set,
|
||||
# default value is 0 if ForceManaged is used and 5 otherwise.
|
||||
#
|
||||
# RedirMax: 5
|
||||
@@ -0,0 +1,269 @@
|
||||
# Letter case in directive names does not matter. Must be separated with colons.
|
||||
# Valid boolean values are a zero number for false, non-zero numbers for true.
|
||||
|
||||
CacheDir: <%= node['apt']['cacher_dir'] %>
|
||||
|
||||
# set empty to disable logging
|
||||
LogDir: /var/log/apt-cacher-ng
|
||||
|
||||
# place to look for additional configuration and resource files if they are not
|
||||
# found in the configuration directory
|
||||
# SupportDir: /usr/lib/apt-cacher-ng
|
||||
|
||||
# TCP (http) port
|
||||
# Set to 9999 to emulate apt-proxy
|
||||
Port:<%= node['apt']['cacher_port'] %>
|
||||
|
||||
# Addresses or hostnames to listen on. Multiple addresses must be separated by
|
||||
# spaces. Each entry must be an exact local address which is associated with a
|
||||
# local interface. DNS resolution is performed using getaddrinfo(3) for all
|
||||
# available protocols (IPv4, IPv6, ...). Using a protocol specific format will
|
||||
# create binding(s) only on protocol specific socket(s) (e.g. 0.0.0.0 will listen
|
||||
# only to IPv4).
|
||||
#
|
||||
# Default: not set, will listen on all interfaces and protocols
|
||||
#
|
||||
# BindAddress: localhost 192.168.7.254 publicNameOnMainInterface
|
||||
|
||||
# The specification of another proxy which shall be used for downloads.
|
||||
# Username and password are, and see manual for limitations.
|
||||
#
|
||||
#Proxy: http://www-proxy.example.net:80
|
||||
#proxy: username:proxypassword@proxy.example.net:3128
|
||||
|
||||
# Repository remapping. See manual for details.
|
||||
# In this example, some backends files might be generated during package
|
||||
# installation using information collected on the system.
|
||||
Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian # Debian Archives
|
||||
Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu # Ubuntu Archives
|
||||
Remap-debvol: file:debvol_mirror*.gz /debian-volatile ; file:backends_debvol # Debian Volatile Archives
|
||||
|
||||
# This is usually not needed for security.debian.org because it's always the
|
||||
# same DNS hostname. However, it might be enabled in order to use hooks,
|
||||
# ForceManaged mode or special flags in this context.
|
||||
# Remap-secdeb: security.debian.org
|
||||
|
||||
# Virtual page accessible in a web browser to see statistics and status
|
||||
# information, i.e. under http://localhost:3142/acng-report.html
|
||||
ReportPage: acng-report.html
|
||||
|
||||
# Socket file for accessing through local UNIX socket instead of TCP/IP. Can be
|
||||
# used with inetd bridge or cron client.
|
||||
# SocketPath:/var/run/apt-cacher-ng/socket
|
||||
|
||||
# Forces log file to be written to disk after every line when set to 1. Default
|
||||
# is 0, buffers are flushed when the client disconnects.
|
||||
#
|
||||
# (technically, alias to the Debug option, see its documentation for details)
|
||||
#
|
||||
# UnbufferLogs: 0
|
||||
|
||||
# Set to 0 to store only type, time and transfer sizes.
|
||||
# 1 -> client IP and relative local path are logged too
|
||||
# VerboseLog: 1
|
||||
|
||||
# Don't detach from the console
|
||||
# ForeGround: 0
|
||||
|
||||
# Store the pid of the daemon process therein
|
||||
# PidFile: /var/run/apt-cacher-ng/pid
|
||||
|
||||
# Forbid outgoing connections, work around them or respond with 503 error
|
||||
# offlinemode:0
|
||||
|
||||
# Forbid all downloads that don't run through preconfigured backends (.where)
|
||||
#ForceManaged: 0
|
||||
|
||||
# Days before considering an unreferenced file expired (to be deleted).
|
||||
# Warning: if the value is set too low and particular index files are not
|
||||
# available for some days (mirror downtime) there is a risk of deletion of
|
||||
# still useful package files.
|
||||
ExTreshold: 4
|
||||
|
||||
# Stop expiration when a critical problem appeared. Currently only failed
|
||||
# refresh of an index file is considered as critical.
|
||||
#
|
||||
# WARNING: don't touch this option or set to zero.
|
||||
# Anything else is DANGEROUS and may cause data loss.
|
||||
#
|
||||
# ExAbortOnProblems: 1
|
||||
|
||||
# Replace some Windows/DOS-FS incompatible chars when storing
|
||||
# StupidFs: 0
|
||||
|
||||
# Experimental feature for apt-listbugs: pass-through SOAP requests and
|
||||
# responses to/from bugs.debian.org. If not set, default is true if
|
||||
# ForceManaged is enabled and false otherwise.
|
||||
# ForwardBtsSoap: 1
|
||||
|
||||
# The daemon has a small cache for DNS data, to speed up resolution. The
|
||||
# expiration time of the DNS entries can be configured in seconds.
|
||||
# DnsCacheSeconds: 3600
|
||||
|
||||
# Don't touch the following values without good consideration!
|
||||
#
|
||||
# Max. count of connection threads kept ready (for faster response in the
|
||||
# future). Should be a sane value between 0 and average number of connections,
|
||||
# and depend on the amount of spare RAM.
|
||||
# MaxStandbyConThreads: 8
|
||||
#
|
||||
# Hard limit of active thread count for incoming connections, i.e. operation
|
||||
# is refused when this value is reached (below zero = unlimited).
|
||||
# MaxConThreads: -1
|
||||
#
|
||||
# Pigeonholing files with regular expressions (static/volatile). Can be
|
||||
# overriden here but not should not be done permanently because future update
|
||||
# of default settings would not be applied later.
|
||||
# VfilePattern = (^|.*?/)(Index|Packages(\.gz|\.bz2|\.lzma|\.xz)?|InRelease|Release|Release\.gpg|Sources(\.gz|\.bz2|\.lzma|\.xz)?|release|index\.db-.*\.gz|Contents-[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|pkglist[^/]*\.bz2|rclist[^/]*\.bz2|/meta-release[^/]*|Translation[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|MD5SUMS|SHA1SUMS|((setup|setup-legacy)(\.ini|\.bz2|\.hint)(\.sig)?)|mirrors\.lst|repo(index|md)\.xml(\.asc|\.key)?|directory\.yast|products|content(\.asc|\.key)?|media|filelists\.xml\.gz|filelists\.sqlite\.bz2|repomd\.xml|packages\.[a-zA-Z][a-zA-Z]\.gz|info\.txt|license\.tar\.gz|license\.zip|.*\.db(\.tar\.gz)?|.*\.files\.tar\.gz|.*\.abs\.tar\.gz|metalink\?repo|.*prestodelta\.xml\.gz)$|/dists/.*/installer-[^/]+/[^0-9][^/]+/images/.*
|
||||
# PfilePattern = .*(\.d?deb|\.rpm|\.dsc|\.tar(\.gz|\.bz2|\.lzma|\.xz)(\.gpg)?|\.diff(\.gz|\.bz2|\.lzma|\.xz)|\.jigdo|\.template|changelog|copyright|\.udeb|\.debdelta|\.diff/.*\.gz|(Devel)?ReleaseAnnouncement(\?.*)?|[a-f0-9]+-(susedata|updateinfo|primary|deltainfo).xml.gz|fonts/(final/)?[a-z]+32.exe(\?download.*)?|/dists/.*/installer-[^/]+/[0-9][^/]+/images/.*)$
|
||||
# Whitelist for expiration, file types not to be removed even when being
|
||||
# unreferenced. Default: many parts from VfilePattern where no parent index
|
||||
# exists or might be unknown.
|
||||
# WfilePattern = (^|.*?/)(Release|InRelease|Release\.gpg|(Packages|Sources)(\.gz|\.bz2|\.lzma|\.xz)?|Translation[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|MD5SUMS|SHA1SUMS|.*\.xml|.*\.db\.tar\.gz|.*\.files\.tar\.gz|.*\.abs\.tar\.gz|[a-z]+32.exe)$|/dists/.*/installer-.*/images/.*
|
||||
|
||||
# Higher modes only working with the debug version
|
||||
# Warning, writes a lot into apt-cacher.err logfile
|
||||
# Value overwrites UnbufferLogs setting (aliased)
|
||||
# Debug:3
|
||||
|
||||
# Usually, general purpose proxies like Squid expose the IP address of the
|
||||
# client user to the remote server using the X-Forwarded-For HTTP header. This
|
||||
# behaviour can be optionally turned on with the Expose-Origin option.
|
||||
# ExposeOrigin: 0
|
||||
|
||||
# When logging the originating IP address, trust the information supplied by
|
||||
# the client in the X-Forwarded-For header.
|
||||
# LogSubmittedOrigin: 0
|
||||
|
||||
# The version string reported to the peer, to be displayed as HTTP client (and
|
||||
# version) in the logs of the mirror.
|
||||
# WARNING: some archives use this header to detect/guess capabilities of the
|
||||
# client (i.e. redirection support) and change the behaviour accordingly, while
|
||||
# ACNG might not support the expected features. Expect side effects.
|
||||
#
|
||||
# UserAgent: Yet Another HTTP Client/1.2.3p4
|
||||
|
||||
# In some cases the Import and Expiration tasks might create fresh volatile
|
||||
# data for internal use by reconstructing them using patch files. This
|
||||
# by-product might be recompressed with bzip2 and with some luck the resulting
|
||||
# file becomes identical to the *.bz2 file on the server, usable for APT
|
||||
# clients trying to fetch the full .bz2 compressed version. Injection of the
|
||||
# generated files into the cache has however a disadvantage on underpowered
|
||||
# servers: bzip2 compression can create high load on the server system and the
|
||||
# visible download of the busy .bz2 files also becomes slower.
|
||||
#
|
||||
# RecompBz2: 0
|
||||
|
||||
# Network timeout for outgoing connections.
|
||||
# NetworkTimeout: 60
|
||||
|
||||
# Sometimes it makes sense to not store the data in cache and just return the
|
||||
# package data to client as it comes in. DontCache parameters can enable this
|
||||
# behaviour for certain URL types. The tokens are extended regular expressions
|
||||
# that URLs are matched against.
|
||||
#
|
||||
# DontCacheRequested is applied to the URL as it comes in from the client.
|
||||
# Example: exclude packages built with kernel-package for x86
|
||||
# DontCacheRequested: linux-.*_10\...\.Custo._i386
|
||||
# Example usecase: exclude popular private IP ranges from caching
|
||||
# DontCacheRequested: 192.168.0 ^10\..* 172.30
|
||||
#
|
||||
# DontCacheResolved is applied to URLs after mapping to the target server. If
|
||||
# multiple backend servers are specified then it's only matched against the
|
||||
# download link for the FIRST possible source (due to implementation limits).
|
||||
# Example usecase: all Ubuntu stuff comes from a local mirror (specified as
|
||||
# backend), don't cache it again:
|
||||
# DontCacheResolved: ubuntumirror.local.net
|
||||
#
|
||||
# DontCache directive sets (overrides) both, DontCacheResolved and
|
||||
# DontCacheRequested. Provided for convenience, see those directives for
|
||||
# details.
|
||||
#
|
||||
# Default permission set of freshly created files and directories, as octal
|
||||
# numbers (see chmod(1) for details).
|
||||
# Can by limited by the umask value (see umask(2) for details) if it's set in
|
||||
# the environment of the starting shell, e.g. in apt-cacher-ng init script or
|
||||
# in its configuration file.
|
||||
# DirPerms: 00755
|
||||
# FilePerms: 00664
|
||||
#
|
||||
#
|
||||
# It's possible to use use apt-cacher-ng as a regular web server with limited
|
||||
# feature set, i.e.
|
||||
# including directory browsing and download of any file;
|
||||
# excluding sorting, mime types/encodings, CGI execution, index page
|
||||
# redirection and other funny things.
|
||||
# To get this behavior, mappings between virtual directories and real
|
||||
# directories on the server must be defined with the LocalDirs directive.
|
||||
# Virtual and real dirs are separated by spaces, multiple pairs are separated
|
||||
# by semi-colons. Real directories must be absolute paths.
|
||||
# NOTE: Since the names of that key directories share the same namespace as
|
||||
# repository names (see Remap-...) it's administrators job to avoid such
|
||||
# collisions on them (unless created deliberately).
|
||||
#
|
||||
# LocalDirs: woo /data/debarchive/woody ; hamm /data/debarchive/hamm
|
||||
|
||||
# Precache a set of files referenced by specified index files. This can be used
|
||||
# to create a partial mirror usable for offline work. There are certain limits
|
||||
# and restrictions on the path specification, see manual for details. A list of
|
||||
# (maybe) relevant index files could be retrieved via
|
||||
# "apt-get --print-uris update" on a client machine.
|
||||
#
|
||||
# PrecacheFor: debrep/dists/unstable/*/source/Sources* debrep/dists/unstable/*/binary-amd64/Packages*
|
||||
|
||||
# Arbitrary set of data to append to request headers sent over the wire. Should
|
||||
# be a well formated HTTP headers part including newlines (DOS style) which
|
||||
# can be entered as escape sequences (\r\n).
|
||||
# RequestAppendix: X-Tracking-Choice: do-not-track\r\n
|
||||
|
||||
# Specifies the IP protocol families to use for remote connections. Order does
|
||||
# matter, first specified are considered first. Possible combinations:
|
||||
# v6 v4
|
||||
# v4 v6
|
||||
# v6
|
||||
# v4
|
||||
# (empty or not set: use system default)
|
||||
#
|
||||
# ConnectProto: v6 v4
|
||||
|
||||
# Regular expiration algorithm finds package files which are no longer listed
|
||||
# in any index file and removes them of them after a safety period.
|
||||
# This option allows to keep more versions of a package in the cache after
|
||||
# safety period is over.
|
||||
# KeepExtraVersions: 1
|
||||
|
||||
# Optionally uses TCP access control provided by libwrap, see hosts_access(5)
|
||||
# for details. Daemon name is apt-cacher-ng. Default if not set: decided on
|
||||
# startup by looking for explicit mentioning of apt-cacher-ng in
|
||||
# /etc/hosts.allow or /etc/hosts.deny files.
|
||||
# UseWrap: 0
|
||||
|
||||
# If many machines from the same local network attempt to update index files
|
||||
# (apt-get update) at nearly the same time, the known state of these index file
|
||||
# is temporarily frozen and multiple requests receive the cached response
|
||||
# without contacting the server. This parameter (in seconds) specifies the
|
||||
# length of this period before the files are considered outdated.
|
||||
# Setting it too low transfers more data and increases remote server load,
|
||||
# setting it too high (more than a couple of minutes) increases the risk of
|
||||
# delivering inconsistent responses to the clients.
|
||||
# FreshIndexMaxAge: 27
|
||||
|
||||
# Usually the users are not allowed to specify custom TCP ports of remote
|
||||
# mirrors in the requests, only the default HTTP port can be used (instead,
|
||||
# proxy administrator can create Remap- rules with custom ports). This
|
||||
# restriction can be disabled by specifying a list of allowed ports or 0 for
|
||||
# any port.
|
||||
#
|
||||
# AllowUserPorts: 80
|
||||
|
||||
# Normally the HTTP redirection responses are forwarded to the original caller
|
||||
# (i.e. APT) which starts a new download attempt from the new URL. This
|
||||
# solution is ok for client configurations with proxy mode but doesn't work
|
||||
# well with configurations using URL prefixes. To work around this the server
|
||||
# can restart its own download with another URL. However, this might be used to
|
||||
# circumvent download source policies by malicious users.
|
||||
# The RedirMax option specifies how many such redirects the server should
|
||||
# follow per request, 0 disables the internal redirection. If not set,
|
||||
# default value is 0 if ForceManaged is used and 5 otherwise.
|
||||
#
|
||||
# RedirMax: 5
|
||||
@@ -0,0 +1,12 @@
|
||||
# CHANGELOG for mongodb
|
||||
|
||||
This file is used to list changes made in each version of mongodb.
|
||||
|
||||
## 0.1.0:
|
||||
|
||||
* Initial release of mongodb
|
||||
|
||||
- - -
|
||||
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.
|
||||
@@ -0,0 +1,68 @@
|
||||
mongodb 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` - mongodb needs toaster to brown your bagel.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
TODO: List you cookbook attributes here.
|
||||
|
||||
e.g.
|
||||
#### mongodb::default
|
||||
<table>
|
||||
<tr>
|
||||
<th>Key</th>
|
||||
<th>Type</th>
|
||||
<th>Description</th>
|
||||
<th>Default</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>['mongodb']['bacon']</tt></td>
|
||||
<td>Boolean</td>
|
||||
<td>whether to include bacon</td>
|
||||
<td><tt>true</tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Usage
|
||||
-----
|
||||
#### mongodb::default
|
||||
TODO: Write usage instructions for each cookbook.
|
||||
|
||||
e.g.
|
||||
Just include `mongodb` in your node's `run_list`:
|
||||
|
||||
```json
|
||||
{
|
||||
"name":"my_node",
|
||||
"run_list": [
|
||||
"recipe[mongodb]"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
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
|
||||
@@ -0,0 +1,8 @@
|
||||
name 'mongodb'
|
||||
maintainer 'ShareLaTeX'
|
||||
maintainer_email 'team@sharelatex.com'
|
||||
license 'AGPLv3'
|
||||
description 'Installs/Configures mongodb'
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version '0.1.0'
|
||||
depends 'apt'
|
||||
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# Cookbook Name:: mongodb
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2014, ShareLaTeX
|
||||
#
|
||||
|
||||
# See http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
|
||||
apt_repository 'mongodb-10gen' do
|
||||
uri 'http://downloads-distro.mongodb.org/repo/ubuntu-upstart'
|
||||
distribution 'dist'
|
||||
components ['10gen']
|
||||
keyserver 'keyserver.ubuntu.com'
|
||||
key '7F0CEB10'
|
||||
end
|
||||
|
||||
package 'mongodb-10gen' do
|
||||
action :install
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
# CHANGELOG for nodejs
|
||||
|
||||
This file is used to list changes made in each version of nodejs.
|
||||
|
||||
## 0.1.0:
|
||||
|
||||
* Initial release of nodejs
|
||||
|
||||
- - -
|
||||
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.
|
||||
@@ -0,0 +1,68 @@
|
||||
nodejs 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` - nodejs needs toaster to brown your bagel.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
TODO: List you cookbook attributes here.
|
||||
|
||||
e.g.
|
||||
#### nodejs::default
|
||||
<table>
|
||||
<tr>
|
||||
<th>Key</th>
|
||||
<th>Type</th>
|
||||
<th>Description</th>
|
||||
<th>Default</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>['nodejs']['bacon']</tt></td>
|
||||
<td>Boolean</td>
|
||||
<td>whether to include bacon</td>
|
||||
<td><tt>true</tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Usage
|
||||
-----
|
||||
#### nodejs::default
|
||||
TODO: Write usage instructions for each cookbook.
|
||||
|
||||
e.g.
|
||||
Just include `nodejs` in your node's `run_list`:
|
||||
|
||||
```json
|
||||
{
|
||||
"name":"my_node",
|
||||
"run_list": [
|
||||
"recipe[nodejs]"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
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
|
||||
@@ -0,0 +1,8 @@
|
||||
name 'nodejs'
|
||||
maintainer 'YOUR_COMPANY_NAME'
|
||||
maintainer_email 'YOUR_EMAIL'
|
||||
license 'AGPLv3'
|
||||
description 'Installs/Configures nodejs'
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version '0.1.0'
|
||||
depends 'apt'
|
||||
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# Cookbook Name:: nodejs
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2014, ShareLaTeX
|
||||
#
|
||||
|
||||
# See https://launchpad.net/~chris-lea/+archive/nodejs
|
||||
apt_repository 'node.js' do
|
||||
uri 'http://ppa.launchpad.net/chris-lea/node.js/ubuntu'
|
||||
distribution node['lsb']['codename']
|
||||
components ['main']
|
||||
keyserver 'keyserver.ubuntu.com'
|
||||
key 'C7917B12'
|
||||
end
|
||||
|
||||
package 'nodejs' do
|
||||
action :install
|
||||
end
|
||||
|
||||
execute 'install grunt' do
|
||||
command "npm install -g grunt-cli"
|
||||
not_if "npm --no-color -g ls 'grunt-cli' 2> /dev/null | grep 'grunt-cli'"
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
# CHANGELOG for redis
|
||||
|
||||
This file is used to list changes made in each version of redis.
|
||||
|
||||
## 0.1.0:
|
||||
|
||||
* Initial release of redis
|
||||
|
||||
- - -
|
||||
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.
|
||||
@@ -0,0 +1,68 @@
|
||||
redis 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` - redis needs toaster to brown your bagel.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
TODO: List you cookbook attributes here.
|
||||
|
||||
e.g.
|
||||
#### redis::default
|
||||
<table>
|
||||
<tr>
|
||||
<th>Key</th>
|
||||
<th>Type</th>
|
||||
<th>Description</th>
|
||||
<th>Default</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>['redis']['bacon']</tt></td>
|
||||
<td>Boolean</td>
|
||||
<td>whether to include bacon</td>
|
||||
<td><tt>true</tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Usage
|
||||
-----
|
||||
#### redis::default
|
||||
TODO: Write usage instructions for each cookbook.
|
||||
|
||||
e.g.
|
||||
Just include `redis` in your node's `run_list`:
|
||||
|
||||
```json
|
||||
{
|
||||
"name":"my_node",
|
||||
"run_list": [
|
||||
"recipe[redis]"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
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
|
||||
@@ -0,0 +1,8 @@
|
||||
name 'redis-server'
|
||||
maintainer 'ShareLaTeX'
|
||||
maintainer_email 'team@sharelatex.com'
|
||||
license 'AGPLv3'
|
||||
description 'Installs/Configures redis-server'
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version '0.1.0'
|
||||
depends 'apt'
|
||||
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# Cookbook Name:: redis
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2014, ShareLaTeX
|
||||
#
|
||||
|
||||
# See https://launchpad.net/~chris-lea/+archive/redis-server
|
||||
apt_repository 'redis-server' do
|
||||
uri 'http://ppa.launchpad.net/chris-lea/redis-server/ubuntu'
|
||||
distribution node['lsb']['codename']
|
||||
components ['main']
|
||||
keyserver 'keyserver.ubuntu.com'
|
||||
key 'C7917B12'
|
||||
end
|
||||
|
||||
package 'redis-server' do
|
||||
action :upgrade
|
||||
options "--force-yes"
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
# CHANGELOG for sharelatex
|
||||
|
||||
This file is used to list changes made in each version of sharelatex.
|
||||
|
||||
## 0.1.0:
|
||||
|
||||
* Initial release of sharelatex
|
||||
|
||||
- - -
|
||||
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.
|
||||
@@ -0,0 +1,68 @@
|
||||
sharelatex 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` - sharelatex needs toaster to brown your bagel.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
TODO: List you cookbook attributes here.
|
||||
|
||||
e.g.
|
||||
#### sharelatex::default
|
||||
<table>
|
||||
<tr>
|
||||
<th>Key</th>
|
||||
<th>Type</th>
|
||||
<th>Description</th>
|
||||
<th>Default</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>['sharelatex']['bacon']</tt></td>
|
||||
<td>Boolean</td>
|
||||
<td>whether to include bacon</td>
|
||||
<td><tt>true</tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Usage
|
||||
-----
|
||||
#### sharelatex::default
|
||||
TODO: Write usage instructions for each cookbook.
|
||||
|
||||
e.g.
|
||||
Just include `sharelatex` in your node's `run_list`:
|
||||
|
||||
```json
|
||||
{
|
||||
"name":"my_node",
|
||||
"run_list": [
|
||||
"recipe[sharelatex]"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
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
|
||||
@@ -0,0 +1,8 @@
|
||||
name 'sharelatex'
|
||||
maintainer 'YOUR_COMPANY_NAME'
|
||||
maintainer_email 'YOUR_EMAIL'
|
||||
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'
|
||||
@@ -0,0 +1,121 @@
|
||||
action :start do
|
||||
package "git"
|
||||
package "build-essential"
|
||||
|
||||
r = new_resource
|
||||
|
||||
deploy_to = "/var/www/" + r.name
|
||||
|
||||
node_environment = "production"
|
||||
|
||||
directory deploy_to do
|
||||
user r.user if r.user
|
||||
recursive true
|
||||
end
|
||||
|
||||
env = {
|
||||
"HOME" => deploy_to
|
||||
}
|
||||
|
||||
directory "#{deploy_to}/releases" do
|
||||
user r.user if r.user
|
||||
recursive true
|
||||
end
|
||||
|
||||
shared_dir = "#{deploy_to}/shared"
|
||||
directory shared_dir do
|
||||
user r.user if r.user
|
||||
recursive true
|
||||
end
|
||||
directory "#{shared_dir}/config" do
|
||||
user r.user if r.user
|
||||
recursive true
|
||||
end
|
||||
directory "#{shared_dir}/log" do
|
||||
user r.user if r.user
|
||||
recursive true
|
||||
end
|
||||
|
||||
deploy_revision deploy_to do
|
||||
repository r.repository
|
||||
revision r.revision
|
||||
user r.user if r.user
|
||||
|
||||
purge_before_symlink [
|
||||
"log", "config", "node_modules"
|
||||
]
|
||||
create_dirs_before_symlink []
|
||||
symlinks({
|
||||
"log" => "log",
|
||||
"config" => "config"
|
||||
})
|
||||
symlink_before_migrate({
|
||||
"node_modules" => "node_modules"
|
||||
})
|
||||
|
||||
environment env
|
||||
|
||||
migrate true
|
||||
migration_command "npm install; grunt install"
|
||||
|
||||
before_migrate do
|
||||
directory "#{deploy_to}/shared/node_modules" do
|
||||
user r.user if r.user
|
||||
recursive true
|
||||
end
|
||||
end
|
||||
|
||||
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}"
|
||||
author "ShareLaTeX <team@sharelatex.com>"
|
||||
|
||||
start on started mountall
|
||||
stop on shutdown
|
||||
|
||||
respawn
|
||||
|
||||
limit nofile 8192 8192
|
||||
|
||||
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 #{env} node app.js >> log/production.log 2>&1
|
||||
end script
|
||||
EOS
|
||||
|
||||
notifies :restart, "service[#{r.name}]"
|
||||
end
|
||||
|
||||
directory "/etc/sharelatex"
|
||||
template "/etc/sharelatex/settings.coffee" do
|
||||
mode 0400
|
||||
user "www-data"
|
||||
notifies :restart, "service[#{r.name}]"
|
||||
end
|
||||
|
||||
service "#{r.name}" do
|
||||
provider Chef::Provider::Service::Upstart
|
||||
action :start
|
||||
end
|
||||
|
||||
file "/etc/logrotate.d/#{r.name}" do
|
||||
content <<-EOS
|
||||
#{deploy_to}/shared/log/*.log {
|
||||
rotate 7
|
||||
size 5M
|
||||
missingok
|
||||
compress
|
||||
copytruncate
|
||||
}
|
||||
EOS
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,47 @@
|
||||
#
|
||||
# Cookbook Name:: sharelatex
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2014, ShareLaTeX
|
||||
#
|
||||
|
||||
# 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"
|
||||
group "www-data"
|
||||
recursive true
|
||||
end
|
||||
end
|
||||
|
||||
sharelatex_app "web-sharelatex" do
|
||||
repository "https://github.com/sharelatex/web-sharelatex.git"
|
||||
revision "master"
|
||||
end
|
||||
|
||||
sharelatex_app "document-updater-sharelatex" do
|
||||
repository "https://github.com/sharelatex/document-updater-sharelatex.git"
|
||||
revision "master"
|
||||
end
|
||||
|
||||
sharelatex_app "filestore-sharelatex" do
|
||||
repository "https://github.com/sharelatex/filestore-sharelatex.git"
|
||||
revision "master"
|
||||
end
|
||||
|
||||
sharelatex_app "track-changes-sharelatex" do
|
||||
repository "https://github.com/sharelatex/track-changes-sharelatex.git"
|
||||
revision "master"
|
||||
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
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
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
|
||||
@action = :start
|
||||
end
|
||||
|
||||
@@ -0,0 +1,268 @@
|
||||
Path = require('path')
|
||||
http = require('http')
|
||||
http.globalAgent.maxSockets = 300
|
||||
|
||||
# Make time interval config easier.
|
||||
seconds = 1000
|
||||
minutes = 60 * seconds
|
||||
|
||||
# These credentials are used for authenticating api requests
|
||||
# between services that may need to go over public channels
|
||||
httpAuthUser = "sharelatex"
|
||||
httpAuthPass = "password"
|
||||
httpAuthUsers = {}
|
||||
httpAuthUsers[httpAuthUser] = httpAuthPass
|
||||
|
||||
sessionSecret = "secret-please-change"
|
||||
|
||||
module.exports =
|
||||
# File storage
|
||||
# ------------
|
||||
#
|
||||
# ShareLaTeX needs somewhere to store binary files like images.
|
||||
# There are currently two options:
|
||||
# Your local filesystem (the default)
|
||||
# Amazon S3
|
||||
filestore:
|
||||
# which backend persistor to use.
|
||||
# choices are
|
||||
# s3 - Amazon S3
|
||||
# fs - local filesystem
|
||||
backend: "fs"
|
||||
stores:
|
||||
# where to store user and template binary files
|
||||
#
|
||||
# For Amazon S3 this is the bucket name to store binary files
|
||||
#
|
||||
# For local filesystem this is the directory to store the files in.
|
||||
# This path must exist, not be tmpfs and be writable to by the user sharelatex is run as.
|
||||
user_files: "/var/lib/sharelatex/user_files"
|
||||
# Uncomment if you need to configure your S3 credentials
|
||||
# s3:
|
||||
# # if you are using S3, then fill in your S3 details below
|
||||
# key: ""
|
||||
# secret: ""
|
||||
|
||||
# Databases
|
||||
# ---------
|
||||
mongo:
|
||||
url : 'mongodb://127.0.0.1/sharelatex'
|
||||
|
||||
redis:
|
||||
web:
|
||||
host: "localhost"
|
||||
port: "6379"
|
||||
password: ""
|
||||
|
||||
api:
|
||||
host: "localhost"
|
||||
port: "6379"
|
||||
password: ""
|
||||
|
||||
mysql:
|
||||
clsi:
|
||||
database: "clsi"
|
||||
username: "clsi"
|
||||
password: ""
|
||||
dialect: "sqlite"
|
||||
storage: "/var/lib/sharelatex/clsi.sqlite"
|
||||
|
||||
# Service locations
|
||||
# -----------------
|
||||
|
||||
# Configure which ports to run each service on. Generally you
|
||||
# can leave these as they are unless you have some other services
|
||||
# running which conflict, or want to run the web process on port 80.
|
||||
internal:
|
||||
web:
|
||||
port: webPort = 3000
|
||||
host: "localhost"
|
||||
documentupdater:
|
||||
port: docUpdaterPort = 3003
|
||||
host: "localhost"
|
||||
clsi:
|
||||
port: clsiPort = 3013
|
||||
host: "localhost"
|
||||
filestore:
|
||||
port: filestorePort = 3009
|
||||
host: "localhost"
|
||||
trackchanges:
|
||||
port: trackchangesPort = 3015
|
||||
host: "localhost"
|
||||
|
||||
# Tell each service where to find the other services. If everything
|
||||
# is running locally then this is easy, but they exist as separate config
|
||||
# options incase you want to run some services on remote hosts.
|
||||
apis:
|
||||
web:
|
||||
url: "http://localhost:#{webPort}"
|
||||
user: httpAuthUser
|
||||
pass: httpAuthPass
|
||||
documentupdater:
|
||||
url : "http://localhost:#{docUpdaterPort}"
|
||||
clsi:
|
||||
url: "http://localhost:#{clsiPort}"
|
||||
filestore:
|
||||
url: "http://localhost:#{filestorePort}"
|
||||
trackchanges:
|
||||
url: "http://localhost:#{trackchangesPort}"
|
||||
thirdPartyDataStore:
|
||||
url : "http://localhost:3002"
|
||||
emptyProjectFlushDelayMiliseconds: 5 * seconds
|
||||
tags:
|
||||
url :"http://localhost:3012"
|
||||
spelling:
|
||||
url : "http://localhost:3005"
|
||||
versioning:
|
||||
snapshotwaitms:3000
|
||||
url: "http://localhost:4000"
|
||||
username: httpAuthUser
|
||||
password: httpAuthPass
|
||||
recurly:
|
||||
privateKey: ""
|
||||
apiKey: ""
|
||||
subdomain: ""
|
||||
chat:
|
||||
url: "http://localhost:3010"
|
||||
templates:
|
||||
port: 3007
|
||||
blog:
|
||||
port: 3008
|
||||
templates_api:
|
||||
url: "http://localhost:3007"
|
||||
|
||||
# Where your instance of ShareLaTeX can be found publically. Used in emails
|
||||
# that are sent out, generated links, etc.
|
||||
siteUrl : 'http://localhost:3000'
|
||||
|
||||
# Same, but with http auth credentials.
|
||||
httpAuthSiteUrl: 'http://#{httpAuthUser}:#{httpAuthPass}@localhost:3000'
|
||||
|
||||
# Security
|
||||
# --------
|
||||
security:
|
||||
sessionSecret: sessionSecret
|
||||
|
||||
httpAuthUsers: httpAuthUsers
|
||||
|
||||
# Default features
|
||||
# ----------------
|
||||
#
|
||||
# You can select the features that are enabled by default for new
|
||||
# new users.
|
||||
defaultFeatures: defaultFeatures =
|
||||
collaborators: -1
|
||||
dropbox: true
|
||||
versioning: true
|
||||
|
||||
plans: plans = [{
|
||||
planCode: "personal"
|
||||
name: "Personal"
|
||||
price: 0
|
||||
features: defaultFeatures
|
||||
}]
|
||||
|
||||
# Spelling languages
|
||||
# ------------------
|
||||
#
|
||||
# You must have the corresponding aspell package installed to
|
||||
# be able to use a language.
|
||||
languages: [
|
||||
{name: "English", code: "en"}
|
||||
]
|
||||
|
||||
# Email support
|
||||
# -------------
|
||||
#
|
||||
# ShareLaTeX uses nodemailer (http://www.nodemailer.com/) to send transactional emails.
|
||||
# To see the range of transport and options they support, see http://www.nodemailer.com/docs/transports
|
||||
#email:
|
||||
# Who should emails be from by default?
|
||||
# fromAddress: ""
|
||||
# The default replyTo field, if it should be set
|
||||
# replyTo: ""
|
||||
# lifecycle: false
|
||||
## Example transport and parameter settings for Amazon SES
|
||||
# transport: "SES"
|
||||
# parameters:
|
||||
# AWSAccessKeyID: ""
|
||||
# AWSSecretKey: ""
|
||||
|
||||
|
||||
# Third party services
|
||||
# --------------------
|
||||
#
|
||||
# ShareLaTeX's regular newsletter is managed by Markdown mail. Add your
|
||||
# credentials here to integrate with this.
|
||||
# markdownmail:
|
||||
# secret: ""
|
||||
# list_id: ""
|
||||
#
|
||||
# Fill in your unique token from various analytics services to enable
|
||||
# them.
|
||||
# analytics:
|
||||
# mixpanel:
|
||||
# token: ""
|
||||
# ga:
|
||||
# token: ""
|
||||
# heap:
|
||||
# token: ""
|
||||
#
|
||||
# ShareLaTeX's help desk is provided by tenderapp.com
|
||||
# tenderUrl: ""
|
||||
#
|
||||
|
||||
# Production Settings
|
||||
# -------------------
|
||||
|
||||
# Should javascript assets be served minified or not. Note that you will
|
||||
# need to run `grunt compile:minify` within the web-sharelatex directory
|
||||
# to generate these.
|
||||
useMinifiedJs: false
|
||||
|
||||
# Should static assets be sent with a header to tell the browser to cache
|
||||
# them.
|
||||
cacheStaticAssets: false
|
||||
|
||||
# If you are running ShareLaTeX over https, set this to true to send the
|
||||
# cookie with a secure flag (recommended).
|
||||
secureCookie: false
|
||||
|
||||
# Internal configs
|
||||
# ----------------
|
||||
path:
|
||||
# If we ever need to write something to disk (e.g. incoming requests
|
||||
# that need processing but may be too big for memory, then write
|
||||
# them to disk here).
|
||||
dumpFolder: Path.resolve "data/dumpFolder"
|
||||
# Where to write the project to disk before running LaTeX on it
|
||||
compilesDir: "/var/lib/sharelatex/compiles"
|
||||
# Where to cache downloaded URLs for the CLSI
|
||||
clsiCacheDir: "/var/lib/sharelatex/clsi-cache"
|
||||
|
||||
# Automatic Snapshots
|
||||
# -------------------
|
||||
automaticSnapshots:
|
||||
# How long should we wait after the user last edited to
|
||||
# take a snapshot?
|
||||
waitTimeAfterLastEdit: 5 * minutes
|
||||
# Even if edits are still taking place, this is maximum
|
||||
# time to wait before taking another snapshot.
|
||||
maxTimeBetweenSnapshots: 30 * minutes
|
||||
|
||||
# Smoke test
|
||||
# ----------
|
||||
# Provide log in credentials and a project to be able to run
|
||||
# some basic smoke tests to check the core functionality.
|
||||
#
|
||||
# smokeTest:
|
||||
# user: ""
|
||||
# password: ""
|
||||
# projectId: ""
|
||||
|
||||
# Filestore health check
|
||||
# ----------------------
|
||||
# Project and file details to check in filestore when calling /health_check
|
||||
# health_check:
|
||||
# project_id: ""
|
||||
# file_id: ""
|
||||
@@ -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.
|
||||
@@ -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
|
||||
@@ -0,0 +1,2 @@
|
||||
default[:texlive][:schema] = "small"
|
||||
default[:texlive][:bin_dir] = "/usr/local/texlive/2013/bin/x86_64-linux"
|
||||
@@ -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'
|
||||
@@ -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
|
||||
@@ -0,0 +1,275 @@
|
||||
Path = require('path')
|
||||
http = require('http')
|
||||
http.globalAgent.maxSockets = 300
|
||||
|
||||
# Make time interval config easier.
|
||||
seconds = 1000
|
||||
minutes = 60 * seconds
|
||||
|
||||
# These credentials are used for authenticating api requests
|
||||
# between services that may need to go over public channels
|
||||
httpAuthUser = "sharelatex"
|
||||
httpAuthPass = "password"
|
||||
httpAuthUsers = {}
|
||||
httpAuthUsers[httpAuthUser] = httpAuthPass
|
||||
|
||||
sessionSecret = "secret-please-change"
|
||||
|
||||
module.exports =
|
||||
# File storage
|
||||
# ------------
|
||||
#
|
||||
# ShareLaTeX needs somewhere to store binary files like images.
|
||||
# There are currently two options:
|
||||
# Your local filesystem (the default)
|
||||
# Amazon S3
|
||||
filestore:
|
||||
# which backend persistor to use.
|
||||
# choices are
|
||||
# s3 - Amazon S3
|
||||
# fs - local filesystem
|
||||
backend: "fs"
|
||||
stores:
|
||||
# where to store user and template binary files
|
||||
#
|
||||
# For Amazon S3 this is the bucket name to store binary files
|
||||
#
|
||||
# For local filesystem this is the directory to store the files in.
|
||||
# This path must exist, not be tmpfs and be writable to by the user sharelatex is run as.
|
||||
user_files: Path.resolve(__dirname + "/../user_files")
|
||||
# Uncomment if you need to configure your S3 credentials
|
||||
# s3:
|
||||
# # if you are using S3, then fill in your S3 details below
|
||||
# key: ""
|
||||
# secret: ""
|
||||
|
||||
# Databases
|
||||
# ---------
|
||||
mongo:
|
||||
url : 'mongodb://127.0.0.1/sharelatex'
|
||||
|
||||
redis:
|
||||
web:
|
||||
host: "localhost"
|
||||
port: "6379"
|
||||
password: ""
|
||||
|
||||
api:
|
||||
host: "localhost"
|
||||
port: "6379"
|
||||
password: ""
|
||||
|
||||
fairy:
|
||||
host: "localhost"
|
||||
port: "6379"
|
||||
password: ""
|
||||
|
||||
mysql:
|
||||
clsi:
|
||||
database: "clsi"
|
||||
username: "clsi"
|
||||
password: ""
|
||||
dialect: "sqlite"
|
||||
storage: Path.resolve(__dirname + "/../db.sqlite")
|
||||
|
||||
# Service locations
|
||||
# -----------------
|
||||
|
||||
# Configure which ports to run each service on. Generally you
|
||||
# can leave these as they are unless you have some other services
|
||||
# running which conflict, or want to run the web process on port 80.
|
||||
internal:
|
||||
web:
|
||||
port: webPort = 3000
|
||||
host: "localhost"
|
||||
documentupdater:
|
||||
port: docUpdaterPort = 3003
|
||||
host: "localhost"
|
||||
clsi:
|
||||
port: clsiPort = 3013
|
||||
host: "localhost"
|
||||
filestore:
|
||||
port: filestorePort = 3009
|
||||
host: "localhost"
|
||||
trackchanges:
|
||||
port: trackchangesPort = 3015
|
||||
host: "localhost"
|
||||
docstore:
|
||||
port: docstorePort = 3016
|
||||
host: "localhost"
|
||||
|
||||
# Tell each service where to find the other services. If everything
|
||||
# is running locally then this is easy, but they exist as separate config
|
||||
# options incase you want to run some services on remote hosts.
|
||||
apis:
|
||||
web:
|
||||
url: "http://localhost:#{webPort}"
|
||||
user: httpAuthUser
|
||||
pass: httpAuthPass
|
||||
documentupdater:
|
||||
url : "http://localhost:#{docUpdaterPort}"
|
||||
clsi:
|
||||
url: "http://localhost:#{clsiPort}"
|
||||
filestore:
|
||||
url: "http://localhost:#{filestorePort}"
|
||||
trackchanges:
|
||||
url: "http://localhost:#{trackchangesPort}"
|
||||
docstore:
|
||||
url: "http://localhost:#{docstorePort}"
|
||||
thirdPartyDataStore:
|
||||
url : "http://localhost:3002"
|
||||
emptyProjectFlushDelayMiliseconds: 5 * seconds
|
||||
tags:
|
||||
url :"http://localhost:3012"
|
||||
spelling:
|
||||
url : "http://localhost:3005"
|
||||
versioning:
|
||||
snapshotwaitms:3000
|
||||
url: "http://localhost:4000"
|
||||
username: httpAuthUser
|
||||
password: httpAuthPass
|
||||
recurly:
|
||||
privateKey: ""
|
||||
apiKey: ""
|
||||
subdomain: ""
|
||||
chat:
|
||||
url: "http://localhost:3010"
|
||||
templates:
|
||||
port: 3007
|
||||
blog:
|
||||
port: 3008
|
||||
templates_api:
|
||||
url: "http://localhost:3007"
|
||||
|
||||
# Where your instance of ShareLaTeX can be found publically. Used in emails
|
||||
# that are sent out, generated links, etc.
|
||||
siteUrl : 'http://localhost:3000'
|
||||
|
||||
# Same, but with http auth credentials.
|
||||
httpAuthSiteUrl: 'http://#{httpAuthUser}:#{httpAuthPass}@localhost:3000'
|
||||
|
||||
# Security
|
||||
# --------
|
||||
security:
|
||||
sessionSecret: sessionSecret
|
||||
|
||||
httpAuthUsers: httpAuthUsers
|
||||
|
||||
# Default features
|
||||
# ----------------
|
||||
#
|
||||
# You can select the features that are enabled by default for new
|
||||
# new users.
|
||||
defaultFeatures: defaultFeatures =
|
||||
collaborators: -1
|
||||
dropbox: true
|
||||
versioning: true
|
||||
|
||||
plans: plans = [{
|
||||
planCode: "personal"
|
||||
name: "Personal"
|
||||
price: 0
|
||||
features: defaultFeatures
|
||||
}]
|
||||
|
||||
# Spelling languages
|
||||
# ------------------
|
||||
#
|
||||
# You must have the corresponding aspell package installed to
|
||||
# be able to use a language.
|
||||
languages: [
|
||||
{name: "English", code: "en"}
|
||||
]
|
||||
|
||||
# Email support
|
||||
# -------------
|
||||
#
|
||||
# ShareLaTeX uses nodemailer (http://www.nodemailer.com/) to send transactional emails.
|
||||
# To see the range of transport and options they support, see http://www.nodemailer.com/docs/transports
|
||||
# email:
|
||||
# fromAddress: ""
|
||||
# replyTo: ""
|
||||
# lifecycle: false
|
||||
# transport: "SES"
|
||||
# parameters:
|
||||
# AWSAccessKeyID: ""
|
||||
# AWSSecretKey: ""
|
||||
|
||||
|
||||
# Third party services
|
||||
# --------------------
|
||||
#
|
||||
# ShareLaTeX's regular newsletter is managed by Markdown mail. Add your
|
||||
# credentials here to integrate with this.
|
||||
# markdownmail:
|
||||
# secret: ""
|
||||
# list_id: ""
|
||||
#
|
||||
# Fill in your unique token from various analytics services to enable
|
||||
# them.
|
||||
# analytics:
|
||||
# mixpanel:
|
||||
# token: ""
|
||||
# ga:
|
||||
# token: ""
|
||||
# heap:
|
||||
# token: ""
|
||||
#
|
||||
# ShareLaTeX's help desk is provided by tenderapp.com
|
||||
# tenderUrl: ""
|
||||
#
|
||||
|
||||
# Production Settings
|
||||
# -------------------
|
||||
|
||||
# Should javascript assets be served minified or not. Note that you will
|
||||
# need to run `grunt compile:minify` within the web-sharelatex directory
|
||||
# to generate these.
|
||||
useMinifiedJs: false
|
||||
|
||||
# Should static assets be sent with a header to tell the browser to cache
|
||||
# them.
|
||||
cacheStaticAssets: false
|
||||
|
||||
# If you are running ShareLaTeX over https, set this to true to send the
|
||||
# cookie with a secure flag (recommended).
|
||||
secureCookie: false
|
||||
|
||||
# Internal configs
|
||||
# ----------------
|
||||
path:
|
||||
# If we ever need to write something to disk (e.g. incoming requests
|
||||
# that need processing but may be too big for memory, then write
|
||||
# them to disk here).
|
||||
dumpFolder: Path.resolve "data/dumpFolder"
|
||||
# Where to write the project to disk before running LaTeX on it
|
||||
compilesDir: Path.resolve(__dirname + "/../compiles")
|
||||
# Where to cache downloaded URLs for the CLSI
|
||||
clsiCacheDir: Path.resolve(__dirname + "/../cache")
|
||||
|
||||
# Automatic Snapshots
|
||||
# -------------------
|
||||
automaticSnapshots:
|
||||
# How long should we wait after the user last edited to
|
||||
# take a snapshot?
|
||||
waitTimeAfterLastEdit: 5 * minutes
|
||||
# Even if edits are still taking place, this is maximum
|
||||
# time to wait before taking another snapshot.
|
||||
maxTimeBetweenSnapshots: 30 * minutes
|
||||
|
||||
# Smoke test
|
||||
# ----------
|
||||
# Provide log in credentials and a project to be able to run
|
||||
# some basic smoke tests to check the core functionality.
|
||||
#
|
||||
# smokeTest:
|
||||
# user: ""
|
||||
# password: ""
|
||||
# projectId: ""
|
||||
|
||||
# Filestore health check
|
||||
# ----------------------
|
||||
# Project and file details to check in filestore when calling /health_check
|
||||
# health_check:
|
||||
# project_id: ""
|
||||
# file_id: ""
|
||||
@@ -1,3 +0,0 @@
|
||||
/compiles/*
|
||||
!.gitkeep
|
||||
.env
|
||||
@@ -1,77 +0,0 @@
|
||||
# Overleaf Community Edition, development environment
|
||||
|
||||
## Building and running
|
||||
|
||||
In this `develop` directory, build the services:
|
||||
|
||||
```shell
|
||||
bin/build
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> If Docker is running out of RAM while building the services in parallel, create a `.env` file in this directory containing `COMPOSE_PARALLEL_LIMIT=1`.
|
||||
|
||||
Then start the services:
|
||||
|
||||
```shell
|
||||
bin/up
|
||||
```
|
||||
|
||||
Once the services are running, open <http://localhost/launchpad> to create the first admin account.
|
||||
|
||||
## Development
|
||||
|
||||
To avoid running `bin/build && bin/up` after every code change, you can run Overleaf
|
||||
Community Edition in _development mode_, where services will automatically update on code changes.
|
||||
|
||||
To do this, use the included `bin/dev` script:
|
||||
|
||||
```shell
|
||||
bin/dev
|
||||
```
|
||||
|
||||
This will start all services using `node --watch`, which will automatically monitor the code and restart the services as necessary.
|
||||
|
||||
To improve performance, you can start only a subset of the services in development mode by providing a space-separated list to the `bin/dev` script:
|
||||
|
||||
```shell
|
||||
bin/dev [service1] [service2] ... [serviceN]
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> Starting the `web` service in _development mode_ will only update the `web`
|
||||
> service when backend code changes. In order to automatically update frontend
|
||||
> code as well, make sure to start the `webpack` service in _development mode_
|
||||
> as well.
|
||||
|
||||
If no services are named, all services will start in development mode.
|
||||
|
||||
## Debugging
|
||||
|
||||
When run in _development mode_ most services expose a debugging port to which
|
||||
you can attach a debugger such as
|
||||
[the inspector in Chrome's Dev Tools](chrome://inspect/) or one integrated into
|
||||
an IDE. The following table shows the port exposed on the **host machine** for
|
||||
each service:
|
||||
|
||||
| Service | Port |
|
||||
| ------------------ | ---- |
|
||||
| `web` | 9229 |
|
||||
| `clsi` | 9230 |
|
||||
| `chat` | 9231 |
|
||||
| `contacts` | 9232 |
|
||||
| `docstore` | 9233 |
|
||||
| `document-updater` | 9234 |
|
||||
| `filestore` | 9235 |
|
||||
| `notifications` | 9236 |
|
||||
| `real-time` | 9237 |
|
||||
| `history-v1` | 9239 |
|
||||
| `project-history` | 9240 |
|
||||
|
||||
To attach to a service using Chrome's _remote debugging_, go to
|
||||
<chrome://inspect/> and make sure _Discover network targets_ is checked. Next
|
||||
click _Configure..._ and add an entry `localhost:[service port]` for each of the
|
||||
services you want to attach a debugger to.
|
||||
|
||||
After adding an entry, the service will show up as a _Remote Target_ that you
|
||||
can inspect and debug.
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
docker compose build --pull "$@"
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --no-deps --detach "$@"
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
docker compose down "$@"
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
docker compose logs --follow --tail 10 --no-color "$@" \
|
||||
| ggrep --line-buffered --invert-match "global.gc" \
|
||||
| ggrep --line-buffered --invert-match "health.check" \
|
||||
| ggrep --line-buffered --invert-match "slow event loop" \
|
||||
| ggrep --line-buffered --invert-match "process.memoryUsage" \
|
||||
| ggrep --line-buffered --only-matching "[{].*" \
|
||||
| bunyan --output short
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
docker compose exec -it "$@" /bin/bash
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
docker compose up --detach "$@"
|
||||
@@ -1,25 +0,0 @@
|
||||
CHAT_HOST=chat
|
||||
CLSI_HOST=clsi
|
||||
DOWNLOAD_HOST=clsi-nginx
|
||||
CONTACTS_HOST=contacts
|
||||
DOCSTORE_HOST=docstore
|
||||
DOCUMENT_UPDATER_HOST=document-updater
|
||||
FILESTORE_HOST=filestore
|
||||
GRACEFUL_SHUTDOWN_DELAY_SECONDS=0
|
||||
HISTORY_V1_HOST=history-v1
|
||||
HISTORY_REDIS_HOST=redis
|
||||
LISTEN_ADDRESS=0.0.0.0
|
||||
MONGO_HOST=mongo
|
||||
MONGO_URL=mongodb://mongo/sharelatex?directConnection=true
|
||||
NOTIFICATIONS_HOST=notifications
|
||||
PROJECT_HISTORY_HOST=project-history
|
||||
QUEUES_REDIS_HOST=redis
|
||||
DSMP_REDIS_HOST=redis
|
||||
REALTIME_HOST=real-time
|
||||
REDIS_HOST=redis
|
||||
SESSION_SECRET=foo
|
||||
V1_HISTORY_HOST=history-v1
|
||||
WEBPACK_HOST=webpack
|
||||
WEB_API_PASSWORD=overleaf
|
||||
WEB_API_USER=overleaf
|
||||
WEB_HOST=web
|
||||
@@ -1,139 +0,0 @@
|
||||
services:
|
||||
clsi:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9230:9229"
|
||||
volumes:
|
||||
- ../services/clsi/app:/overleaf/services/clsi/app
|
||||
- ../services/clsi/app.js:/overleaf/services/clsi/app.js
|
||||
- ../services/clsi/config:/overleaf/services/clsi/config
|
||||
|
||||
chat:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9231:9229"
|
||||
volumes:
|
||||
- ../services/chat/app:/overleaf/services/chat/app
|
||||
- ../services/chat/app.js:/overleaf/services/chat/app.js
|
||||
- ../services/chat/config:/overleaf/services/chat/config
|
||||
|
||||
contacts:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9232:9229"
|
||||
volumes:
|
||||
- ../services/contacts/app:/overleaf/services/contacts/app
|
||||
- ../services/contacts/app.js:/overleaf/services/contacts/app.js
|
||||
- ../services/contacts/config:/overleaf/services/contacts/config
|
||||
|
||||
docstore:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9233:9229"
|
||||
volumes:
|
||||
- ../services/docstore/app:/overleaf/services/docstore/app
|
||||
- ../services/docstore/app.js:/overleaf/services/docstore/app.js
|
||||
- ../services/docstore/config:/overleaf/services/docstore/config
|
||||
|
||||
document-updater:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9234:9229"
|
||||
volumes:
|
||||
- ../services/document-updater/app:/overleaf/services/document-updater/app
|
||||
- ../services/document-updater/app.js:/overleaf/services/document-updater/app.js
|
||||
- ../services/document-updater/config:/overleaf/services/document-updater/config
|
||||
|
||||
filestore:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9235:9229"
|
||||
volumes:
|
||||
- ../services/filestore/app:/overleaf/services/filestore/app
|
||||
- ../services/filestore/app.js:/overleaf/services/filestore/app.js
|
||||
- ../services/filestore/config:/overleaf/services/filestore/config
|
||||
|
||||
history-v1:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9239:9229"
|
||||
volumes:
|
||||
- ../services/history-v1/api:/overleaf/services/history-v1/api
|
||||
- ../services/history-v1/app.js:/overleaf/services/history-v1/app.js
|
||||
- ../services/history-v1/config:/overleaf/services/history-v1/config
|
||||
- ../services/history-v1/storage:/overleaf/services/history-v1/storage
|
||||
- ../services/history-v1/knexfile.js:/overleaf/services/history-v1/knexfile.js
|
||||
- ../services/history-v1/migrations:/overleaf/services/history-v1/migrations
|
||||
|
||||
notifications:
|
||||
command: ["node", "--watch", "app.ts"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9236:9229"
|
||||
volumes:
|
||||
- ../services/notifications/app:/overleaf/services/notifications/app
|
||||
- ../services/notifications/app.ts:/overleaf/services/notifications/app.ts
|
||||
- ../services/notifications/config:/overleaf/services/notifications/config
|
||||
|
||||
project-history:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9240:9229"
|
||||
volumes:
|
||||
- ../services/project-history/app:/overleaf/services/project-history/app
|
||||
- ../services/project-history/app.js:/overleaf/services/project-history/app.js
|
||||
- ../services/project-history/config:/overleaf/services/project-history/config
|
||||
|
||||
real-time:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9237:9229"
|
||||
volumes:
|
||||
- ../services/real-time/app:/overleaf/services/real-time/app
|
||||
- ../services/real-time/app.js:/overleaf/services/real-time/app.js
|
||||
- ../services/real-time/config:/overleaf/services/real-time/config
|
||||
|
||||
web:
|
||||
command: ["node", "--watch", "app.mjs", "--watch-locales"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9229:9229"
|
||||
volumes:
|
||||
- ../services/web/app:/overleaf/services/web/app
|
||||
- ../services/web/app.mjs:/overleaf/services/web/app.mjs
|
||||
- ../services/web/config:/overleaf/services/web/config
|
||||
- ../services/web/locales:/overleaf/services/web/locales
|
||||
- ../services/web/modules:/overleaf/services/web/modules
|
||||
- ../services/web/public:/overleaf/services/web/public
|
||||
|
||||
webpack:
|
||||
volumes:
|
||||
- ../services/web/app:/overleaf/services/web/app
|
||||
- ../services/web/config:/overleaf/services/web/config
|
||||
- ../services/web/frontend:/overleaf/services/web/frontend
|
||||
- ../services/web/locales:/overleaf/services/web/locales
|
||||
- ../services/web/modules:/overleaf/services/web/modules
|
||||
- ../services/web/public:/overleaf/services/web/public
|
||||
- ../services/web/transform:/overleaf/services/web/transform
|
||||
- ../services/web/types:/overleaf/services/web/types
|
||||
- ../services/web/webpack-plugins:/overleaf/services/web/webpack-plugins
|
||||
@@ -1,183 +0,0 @@
|
||||
volumes:
|
||||
clsi-cache:
|
||||
filestore-public-files:
|
||||
filestore-template-files:
|
||||
filestore-uploads:
|
||||
filestore-user-files:
|
||||
mongo-data:
|
||||
redis-data:
|
||||
sharelatex-data:
|
||||
web-data:
|
||||
history-v1-buckets:
|
||||
|
||||
services:
|
||||
chat:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/chat/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
|
||||
clsi:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/clsi/Dockerfile
|
||||
target: with-texlive
|
||||
env_file:
|
||||
- dev.env
|
||||
environment:
|
||||
- SANDBOXED_COMPILES=false
|
||||
user: root
|
||||
volumes:
|
||||
- ${PWD}/compiles:/overleaf/services/clsi/compiles
|
||||
- ${PWD}/output:/overleaf/services/clsi/output
|
||||
- ${DOCKER_SOCKET_PATH:-/var/run/docker.sock}:/var/run/docker.sock
|
||||
- clsi-cache:/overleaf/services/clsi/cache
|
||||
|
||||
clsi-nginx:
|
||||
image: nginx:1.28
|
||||
read_only: true
|
||||
tmpfs:
|
||||
- /tmp
|
||||
- /var/cache/nginx
|
||||
- /run
|
||||
volumes:
|
||||
- ${PWD}/output:/output:ro
|
||||
- ../services/clsi/nginx.conf:/etc/nginx/conf.d/nginx.conf:ro
|
||||
|
||||
contacts:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/contacts/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
|
||||
docstore:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/docstore/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
|
||||
document-updater:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/document-updater/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
|
||||
filestore:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/filestore/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
# environment:
|
||||
# - ENABLE_CONVERSIONS=true
|
||||
volumes:
|
||||
- filestore-public-files:/overleaf/services/filestore/public_files
|
||||
- filestore-template-files:/overleaf/services/filestore/template_files
|
||||
- filestore-uploads:/overleaf/services/filestore/uploads
|
||||
|
||||
history-v1:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/history-v1/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
environment:
|
||||
OVERLEAF_EDITOR_ANALYTICS_BUCKET: "/buckets/analytics"
|
||||
OVERLEAF_EDITOR_BLOBS_BUCKET: "/buckets/blobs"
|
||||
OVERLEAF_EDITOR_CHUNKS_BUCKET: "/buckets/chunks"
|
||||
OVERLEAF_EDITOR_PROJECT_BLOBS_BUCKET: "/buckets/project_blobs"
|
||||
OVERLEAF_EDITOR_ZIPS_BUCKET: "/buckets/zips"
|
||||
PERSISTOR_BACKEND: fs
|
||||
volumes:
|
||||
- history-v1-buckets:/buckets
|
||||
|
||||
mongo:
|
||||
image: mongo:8
|
||||
command: --replSet overleaf
|
||||
ports:
|
||||
- "127.0.0.1:27017:27017" # for debugging
|
||||
volumes:
|
||||
- mongo-data:/data/db
|
||||
- ../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js
|
||||
environment:
|
||||
MONGO_INITDB_DATABASE: sharelatex
|
||||
extra_hosts:
|
||||
# Required when using the automatic database setup for initializing the
|
||||
# replica set. This override is not needed when running the setup after
|
||||
# starting up mongo.
|
||||
- mongo:127.0.0.1
|
||||
|
||||
notifications:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/notifications/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
|
||||
project-history:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/project-history/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
|
||||
real-time:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/real-time/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
|
||||
redis:
|
||||
image: redis:7
|
||||
ports:
|
||||
- "127.0.0.1:6379:6379" # for debugging
|
||||
volumes:
|
||||
- redis-data:/data
|
||||
|
||||
web:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/web/Dockerfile
|
||||
target: dev
|
||||
env_file:
|
||||
- dev.env
|
||||
environment:
|
||||
- APP_NAME=Overleaf Community Edition
|
||||
- ENABLED_LINKED_FILE_TYPES=project_file,project_output_file
|
||||
- EMAIL_CONFIRMATION_DISABLED=true
|
||||
- NODE_ENV=development
|
||||
- OVERLEAF_ALLOW_PUBLIC_ACCESS=true
|
||||
command: ["node", "app.mjs"]
|
||||
volumes:
|
||||
- sharelatex-data:/var/lib/overleaf
|
||||
- web-data:/overleaf/services/web/data
|
||||
depends_on:
|
||||
- mongo
|
||||
- redis
|
||||
- chat
|
||||
- clsi
|
||||
- contacts
|
||||
- docstore
|
||||
- document-updater
|
||||
- filestore
|
||||
- history-v1
|
||||
- notifications
|
||||
- project-history
|
||||
- real-time
|
||||
|
||||
webpack:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/web/Dockerfile
|
||||
target: webpack
|
||||
command:
|
||||
["npx", "webpack", "serve", "--config", "webpack.config.dev-env.js"]
|
||||
ports:
|
||||
- "127.0.0.1:80:3808"
|
||||
volumes:
|
||||
- ./webpack.config.dev-env.js:/overleaf/services/web/webpack.config.dev-env.js
|
||||
@@ -1,23 +0,0 @@
|
||||
const { merge } = require('webpack-merge')
|
||||
|
||||
const base = require('./webpack.config.dev')
|
||||
|
||||
module.exports = merge(base, {
|
||||
devServer: {
|
||||
allowedHosts: 'auto',
|
||||
devMiddleware: {
|
||||
index: false,
|
||||
},
|
||||
proxy: [
|
||||
{
|
||||
context: '/socket.io/**',
|
||||
target: 'http://real-time:3026',
|
||||
ws: true,
|
||||
},
|
||||
{
|
||||
context: ['!**/*.js', '!**/*.css', '!**/*.json'],
|
||||
target: 'http://web:3000',
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 13 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 271 KiB |
@@ -1,23 +0,0 @@
|
||||
version: "2.2"
|
||||
services:
|
||||
sharelatex:
|
||||
ports:
|
||||
- 30000:30000
|
||||
- 30150:30150
|
||||
- 30120:30120
|
||||
- 30050:30050
|
||||
- 30420:30420
|
||||
- 30030:30030
|
||||
- 30160:30160
|
||||
- 30360:30360
|
||||
- 30130:30130
|
||||
- 30100:30100
|
||||
- 30540:30540
|
||||
- 30640:30640
|
||||
- 40000:40000
|
||||
|
||||
# Server Pro
|
||||
- 30070:30070
|
||||
- 30400:30400
|
||||
environment:
|
||||
DEBUG_NODE: "true"
|
||||
@@ -1,149 +0,0 @@
|
||||
services:
|
||||
sharelatex:
|
||||
restart: always
|
||||
# Server Pro users:
|
||||
# image: quay.io/sharelatex/sharelatex-pro
|
||||
image: sharelatex/sharelatex
|
||||
container_name: sharelatex
|
||||
depends_on:
|
||||
mongo:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_started
|
||||
ports:
|
||||
- 80:80
|
||||
stop_grace_period: 60s
|
||||
volumes:
|
||||
- ~/sharelatex_data:/var/lib/overleaf
|
||||
########################################################################
|
||||
#### Server Pro: Uncomment the following line to mount the docker ####
|
||||
#### socket, required for Sibling Containers to work ####
|
||||
########################################################################
|
||||
# - /var/run/docker.sock:/var/run/docker.sock
|
||||
environment:
|
||||
OVERLEAF_APP_NAME: Overleaf Community Edition
|
||||
|
||||
OVERLEAF_MONGO_URL: mongodb://mongo/sharelatex
|
||||
|
||||
# Same property, unfortunately with different names in
|
||||
# different locations
|
||||
OVERLEAF_REDIS_HOST: redis
|
||||
REDIS_HOST: redis
|
||||
|
||||
ENABLED_LINKED_FILE_TYPES: "project_file,project_output_file"
|
||||
|
||||
# Enables Thumbnail generation using ImageMagick
|
||||
ENABLE_CONVERSIONS: "true"
|
||||
|
||||
# Disables email confirmation requirement
|
||||
EMAIL_CONFIRMATION_DISABLED: "true"
|
||||
|
||||
## Set for SSL via nginx-proxy
|
||||
#VIRTUAL_HOST: 103.112.212.22
|
||||
|
||||
# OVERLEAF_SITE_URL: http://overleaf.example.com
|
||||
# OVERLEAF_NAV_TITLE: Overleaf Community Edition
|
||||
# OVERLEAF_HEADER_IMAGE_URL: http://example.com/mylogo.png
|
||||
# OVERLEAF_ADMIN_EMAIL: support@it.com
|
||||
|
||||
# OVERLEAF_LEFT_FOOTER: '[{"text": "Another page I want to link to can be found <a href=\"here\">here</a>"} ]'
|
||||
# OVERLEAF_RIGHT_FOOTER: '[{"text": "Hello I am on the Right"} ]'
|
||||
|
||||
# OVERLEAF_EMAIL_FROM_ADDRESS: "hello@example.com"
|
||||
|
||||
# OVERLEAF_EMAIL_AWS_SES_ACCESS_KEY_ID:
|
||||
# OVERLEAF_EMAIL_AWS_SES_SECRET_KEY:
|
||||
|
||||
# OVERLEAF_EMAIL_SMTP_HOST: smtp.example.com
|
||||
# OVERLEAF_EMAIL_SMTP_PORT: 587
|
||||
# OVERLEAF_EMAIL_SMTP_SECURE: false
|
||||
# OVERLEAF_EMAIL_SMTP_USER:
|
||||
# OVERLEAF_EMAIL_SMTP_PASS:
|
||||
# OVERLEAF_EMAIL_SMTP_TLS_REJECT_UNAUTH: true
|
||||
# OVERLEAF_EMAIL_SMTP_IGNORE_TLS: false
|
||||
# OVERLEAF_EMAIL_SMTP_NAME: '127.0.0.1'
|
||||
# OVERLEAF_EMAIL_SMTP_LOGGER: true
|
||||
# OVERLEAF_CUSTOM_EMAIL_FOOTER: "This system is run by department x"
|
||||
|
||||
# ENABLE_CRON_RESOURCE_DELETION: true
|
||||
|
||||
################
|
||||
## Server Pro ##
|
||||
################
|
||||
|
||||
## The Community Edition is intended for use in environments where all users are trusted and is not appropriate for
|
||||
## scenarios where isolation of users is required. Sandboxed Compiles are not available in the Community Edition,
|
||||
## so the following environment variables must be commented out to avoid compile issues.
|
||||
##
|
||||
## Sandboxed Compiles: https://docs.overleaf.com/on-premises/configuration/overleaf-toolkit/server-pro-only-configuration/sandboxed-compiles
|
||||
SANDBOXED_COMPILES: "true"
|
||||
### Bind-mount source for /var/lib/overleaf/data/compiles inside the container.
|
||||
SANDBOXED_COMPILES_HOST_DIR_COMPILES: "/home/user/sharelatex_data/data/compiles"
|
||||
### Bind-mount source for /var/lib/overleaf/data/output inside the container.
|
||||
SANDBOXED_COMPILES_HOST_DIR_OUTPUT: "/home/user/sharelatex_data/data/output"
|
||||
### Backwards compatibility (before Server Pro 5.5)
|
||||
DOCKER_RUNNER: "true"
|
||||
SANDBOXED_COMPILES_SIBLING_CONTAINERS: "true"
|
||||
|
||||
## Works with test LDAP server shown at bottom of docker compose
|
||||
# OVERLEAF_LDAP_URL: 'ldap://ldap:389'
|
||||
# OVERLEAF_LDAP_SEARCH_BASE: 'ou=people,dc=planetexpress,dc=com'
|
||||
# OVERLEAF_LDAP_SEARCH_FILTER: '(uid={{username}})'
|
||||
# OVERLEAF_LDAP_BIND_DN: 'cn=admin,dc=planetexpress,dc=com'
|
||||
# OVERLEAF_LDAP_BIND_CREDENTIALS: 'GoodNewsEveryone'
|
||||
# OVERLEAF_LDAP_EMAIL_ATT: 'mail'
|
||||
# OVERLEAF_LDAP_NAME_ATT: 'cn'
|
||||
# OVERLEAF_LDAP_LAST_NAME_ATT: 'sn'
|
||||
# OVERLEAF_LDAP_UPDATE_USER_DETAILS_ON_LOGIN: 'true'
|
||||
|
||||
# OVERLEAF_TEMPLATES_USER_ID: "578773160210479700917ee5"
|
||||
# OVERLEAF_NEW_PROJECT_TEMPLATE_LINKS: '[ {"name":"All Templates","url":"/templates/all"}]'
|
||||
|
||||
# OVERLEAF_PROXY_LEARN: "true"
|
||||
|
||||
mongo:
|
||||
restart: always
|
||||
image: mongo:6.0
|
||||
container_name: mongo
|
||||
command: "--replSet overleaf"
|
||||
volumes:
|
||||
- ~/mongo_data:/data/db
|
||||
- ./bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js
|
||||
environment:
|
||||
MONGO_INITDB_DATABASE: sharelatex
|
||||
extra_hosts:
|
||||
# Required when using the automatic database setup for initializing the replica set.
|
||||
# This override is not needed when running the setup after starting up mongo.
|
||||
- mongo:127.0.0.1
|
||||
healthcheck:
|
||||
test: echo 'db.stats().ok' | mongosh localhost:27017/test --quiet
|
||||
interval: 10s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
|
||||
redis:
|
||||
restart: always
|
||||
image: redis:6.2
|
||||
container_name: redis
|
||||
volumes:
|
||||
- ~/redis_data:/data
|
||||
|
||||
# ldap:
|
||||
# restart: always
|
||||
# image: rroemhild/test-openldap
|
||||
# container_name: ldap
|
||||
|
||||
# See https://github.com/jwilder/nginx-proxy for documentation on how to configure the nginx-proxy container,
|
||||
# and https://github.com/overleaf/overleaf/wiki/HTTPS-reverse-proxy-using-Nginx for an example of some recommended
|
||||
# settings. We recommend using a properly managed nginx instance outside of the Overleaf Server Pro setup,
|
||||
# but the example here can be used if you'd prefer to run everything with docker-compose
|
||||
|
||||
# nginx-proxy:
|
||||
# image: jwilder/nginx-proxy
|
||||
# container_name: nginx-proxy
|
||||
# ports:
|
||||
# - "80:80"
|
||||
# - "443:443"
|
||||
# volumes:
|
||||
# - /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
# - /home/overleaf/tmp:/etc/nginx/certs
|
||||
@@ -1,12 +0,0 @@
|
||||
FROM cypress/included:13.13.2
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=1000
|
||||
|
||||
WORKDIR /overleaf
|
||||
|
||||
RUN sed -i s/node:x:1000:/node:x:${USER_GID}:/ /etc/group \
|
||||
&& sed -i s_node:x:1000:1000::/home/node:/bin/bash_node:x:${USER_UID}:${USER_GID}::/home/node:/bin/bash_ /etc/passwd \
|
||||
&& chown -R node:node /home/node \
|
||||
&& chown node:node /overleaf
|
||||
|
||||
USER node
|
||||
@@ -1,13 +0,0 @@
|
||||
let reporterOptions = {}
|
||||
if (process.env.CI) {
|
||||
reporterOptions = {
|
||||
reporter: '/overleaf/node_modules/mocha-multi-reporters',
|
||||
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
|
||||
}
|
||||
}
|
||||
const all = {
|
||||
require: 'test/setup.js',
|
||||
...reporterOptions,
|
||||
}
|
||||
|
||||
module.exports = all
|
||||
@@ -1 +0,0 @@
|
||||
24.14.1
|
||||
@@ -1,661 +0,0 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
@@ -1,3 +0,0 @@
|
||||
# Access Token Encryptor
|
||||
|
||||
Used in third-party-references, to encrypt access tokens
|
||||
@@ -1,9 +0,0 @@
|
||||
access-token-encryptor
|
||||
--dependencies=None
|
||||
--env-add=
|
||||
--env-pass-through=
|
||||
--esmock-loader=False
|
||||
--is-library=True
|
||||
--node-version=24.14.1
|
||||
--pipeline-owner=32
|
||||
--public-repo=False
|
||||
@@ -1 +0,0 @@
|
||||
module.exports = require('./lib/js/AccessTokenEncryptor')
|
||||
@@ -1,164 +0,0 @@
|
||||
const { promisify } = require('node:util')
|
||||
const crypto = require('node:crypto')
|
||||
|
||||
const ALGORITHM = 'aes-256-ctr'
|
||||
|
||||
const cryptoHkdf = promisify(crypto.hkdf)
|
||||
const cryptoRandomBytes = promisify(crypto.randomBytes)
|
||||
|
||||
class AbstractAccessTokenScheme {
|
||||
constructor(cipherLabel, cipherPassword) {
|
||||
this.cipherLabel = cipherLabel
|
||||
this.cipherPassword = cipherPassword
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} json
|
||||
* @return {Promise<string>}
|
||||
*/
|
||||
async encryptJson(json) {
|
||||
throw new Error('encryptJson is not implemented')
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} encryptedJson
|
||||
* @return {Promise<Object>}
|
||||
*/
|
||||
async decryptToJson(encryptedJson) {
|
||||
throw new Error('decryptToJson is not implemented')
|
||||
}
|
||||
}
|
||||
|
||||
class AccessTokenSchemeWithGenericKeyFn extends AbstractAccessTokenScheme {
|
||||
/**
|
||||
* @param {Buffer} salt
|
||||
* @return {Promise<Buffer>}
|
||||
*/
|
||||
async keyFn(salt) {
|
||||
throw new Error('keyFn is not implemented')
|
||||
}
|
||||
|
||||
async encryptJson(json) {
|
||||
const plainText = JSON.stringify(json)
|
||||
|
||||
const bytes = await cryptoRandomBytes(32)
|
||||
const salt = bytes.slice(0, 16)
|
||||
const iv = bytes.slice(16, 32)
|
||||
const key = await this.keyFn(salt)
|
||||
|
||||
const cipher = crypto.createCipheriv(ALGORITHM, key, iv)
|
||||
const cipherText =
|
||||
cipher.update(plainText, 'utf8', 'base64') + cipher.final('base64')
|
||||
|
||||
return [
|
||||
this.cipherLabel,
|
||||
salt.toString('hex'),
|
||||
cipherText,
|
||||
iv.toString('hex'),
|
||||
].join(':')
|
||||
}
|
||||
|
||||
async decryptToJson(encryptedJson) {
|
||||
const [, salt, cipherText, iv] = encryptedJson.split(':', 4)
|
||||
const key = await this.keyFn(Buffer.from(salt, 'hex'))
|
||||
|
||||
const decipher = crypto.createDecipheriv(
|
||||
ALGORITHM,
|
||||
key,
|
||||
Buffer.from(iv, 'hex')
|
||||
)
|
||||
const plainText =
|
||||
decipher.update(cipherText, 'base64', 'utf8') + decipher.final('utf8')
|
||||
try {
|
||||
return JSON.parse(plainText)
|
||||
} catch (e) {
|
||||
throw new Error('error decrypting token')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AccessTokenSchemeV3 extends AccessTokenSchemeWithGenericKeyFn {
|
||||
async keyFn(salt) {
|
||||
const optionalInfo = ''
|
||||
return await cryptoHkdf(
|
||||
'sha512',
|
||||
this.cipherPassword,
|
||||
salt,
|
||||
optionalInfo,
|
||||
32
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class AccessTokenEncryptor {
|
||||
constructor(settings) {
|
||||
/**
|
||||
* @type {Map<string, AbstractAccessTokenScheme>}
|
||||
*/
|
||||
this.schemeByCipherLabel = new Map()
|
||||
for (const cipherLabel of Object.keys(settings.cipherPasswords)) {
|
||||
if (!cipherLabel) {
|
||||
throw new Error('cipherLabel cannot be empty')
|
||||
}
|
||||
if (cipherLabel.match(/:/)) {
|
||||
throw new Error(
|
||||
`cipherLabel must not contain a colon (:), got ${cipherLabel}`
|
||||
)
|
||||
}
|
||||
const [, version] = cipherLabel.split('-')
|
||||
if (!version) {
|
||||
throw new Error(
|
||||
`cipherLabel must contain version suffix (e.g. 2042.1-v42), got ${cipherLabel}`
|
||||
)
|
||||
}
|
||||
|
||||
const cipherPassword = settings.cipherPasswords[cipherLabel]
|
||||
if (!cipherPassword) {
|
||||
throw new Error(`cipherPasswords['${cipherLabel}'] is missing`)
|
||||
}
|
||||
if (cipherPassword.length < 16) {
|
||||
throw new Error(`cipherPasswords['${cipherLabel}'] is too short`)
|
||||
}
|
||||
|
||||
let scheme
|
||||
switch (version) {
|
||||
case 'v3':
|
||||
scheme = new AccessTokenSchemeV3(cipherLabel, cipherPassword)
|
||||
break
|
||||
default:
|
||||
throw new Error(`unknown version '${version}' for ${cipherLabel}`)
|
||||
}
|
||||
this.schemeByCipherLabel.set(cipherLabel, scheme)
|
||||
}
|
||||
|
||||
/** @type {AbstractAccessTokenScheme} */
|
||||
this.defaultScheme = this.schemeByCipherLabel.get(settings.cipherLabel)
|
||||
if (!this.defaultScheme) {
|
||||
throw new Error(`unknown default cipherLabel ${settings.cipherLabel}`)
|
||||
}
|
||||
}
|
||||
|
||||
promises = {
|
||||
encryptJson: async json => await this.defaultScheme.encryptJson(json),
|
||||
decryptToJson: async encryptedJson => {
|
||||
const [label] = encryptedJson.split(':', 1)
|
||||
const scheme = this.schemeByCipherLabel.get(label)
|
||||
if (!scheme) {
|
||||
throw new Error('unknown access-token-encryptor label ' + label)
|
||||
}
|
||||
return await scheme.decryptToJson(encryptedJson)
|
||||
},
|
||||
}
|
||||
|
||||
encryptJson(json, callback) {
|
||||
this.promises.encryptJson(json).then(s => callback(null, s), callback)
|
||||
}
|
||||
|
||||
decryptToJson(encryptedJson, callback) {
|
||||
this.promises
|
||||
.decryptToJson(encryptedJson)
|
||||
.then(o => callback(null, o), callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AccessTokenEncryptor
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"name": "@overleaf/access-token-encryptor",
|
||||
"version": "3.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "npm run lint && npm run types:check && npm run test:unit",
|
||||
"lint": "eslint --cache --cache-location ../../node_modules/.cache/eslint/ --ext .cjs,.js,.jsx,.mjs,.ts --max-warnings 0 --format unix .",
|
||||
"lint:fix": "eslint --cache --cache-location ../../node_modules/.cache/eslint/ --fix --ext .cjs,.js,.jsx,.mjs,.ts .",
|
||||
"test:ci": "npm run test:unit",
|
||||
"test:unit": "mocha --exit test/**/*.{js,cjs}",
|
||||
"types:check": "tsc --noEmit"
|
||||
},
|
||||
"author": "",
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.21"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.3.6",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"mocha": "^11.1.0",
|
||||
"mocha-junit-reporter": "^2.2.1",
|
||||
"mocha-multi-reporters": "^1.5.1",
|
||||
"sandboxed-module": "^2.0.4",
|
||||
"typescript": "^5.0.4"
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
function formatTokenUsageStats(STATS) {
|
||||
const prettyStats = []
|
||||
const sortedStats = Object.entries(STATS).sort((a, b) =>
|
||||
a[0] > b[0] ? 1 : -1
|
||||
)
|
||||
const totalByName = {}
|
||||
for (const [key, n] of sortedStats) {
|
||||
const [name, version, collectionName, path, label] = key.split(':')
|
||||
totalByName[name] = (totalByName[name] || 0) + n
|
||||
prettyStats.push({ name, version, collectionName, path, label, n })
|
||||
}
|
||||
for (const row of prettyStats) {
|
||||
row.percentage = ((100 * row.n) / totalByName[row.name])
|
||||
.toFixed(2)
|
||||
.padStart(6)
|
||||
}
|
||||
|
||||
if (prettyStats.length === 0) {
|
||||
console.warn('---')
|
||||
console.warn('Found 0 access tokens.')
|
||||
console.warn('---')
|
||||
} else {
|
||||
console.table(prettyStats)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { formatTokenUsageStats }
|
||||
@@ -1,108 +0,0 @@
|
||||
const _ = require('lodash')
|
||||
const { formatTokenUsageStats } = require('./format-usage-stats')
|
||||
|
||||
const LOG_EVERY_IN_S = parseInt(process.env.LOG_EVERY_IN_S || '5', 10)
|
||||
const DRY_RUN = !process.argv.includes('--dry-run=false')
|
||||
|
||||
/**
|
||||
* @param {AccessTokenEncryptor} accessTokenEncryptor
|
||||
* @param {string} encryptedJson
|
||||
* @return {Promise<string>}
|
||||
*/
|
||||
async function reEncryptTokens(accessTokenEncryptor, encryptedJson) {
|
||||
return await new Promise((resolve, reject) => {
|
||||
accessTokenEncryptor.decryptToJson(encryptedJson, (err, json) => {
|
||||
if (err) return reject(err)
|
||||
accessTokenEncryptor.encryptJson(json, (err, reEncryptedJson) => {
|
||||
if (err) return reject(err)
|
||||
resolve(reEncryptedJson)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {AccessTokenEncryptor} accessTokenEncryptor
|
||||
* @param {Collection} collection
|
||||
* @param {Object} paths
|
||||
* @param {Object} queryOptions
|
||||
* @return {Promise<{}>}
|
||||
*/
|
||||
async function reEncryptTokensInCollection({
|
||||
accessTokenEncryptor,
|
||||
collection,
|
||||
paths,
|
||||
queryOptions,
|
||||
}) {
|
||||
const { collectionName } = collection
|
||||
const stats = {}
|
||||
|
||||
let processed = 0
|
||||
let updatedNUsers = 0
|
||||
let lastLog = 0
|
||||
const logProgress = () => {
|
||||
if (DRY_RUN) {
|
||||
console.warn(
|
||||
`processed ${processed} | Would have updated ${updatedNUsers} users`
|
||||
)
|
||||
} else {
|
||||
console.warn(`processed ${processed} | Updated ${updatedNUsers} users`)
|
||||
}
|
||||
}
|
||||
|
||||
const projection = { _id: 1 }
|
||||
for (const path of Object.values(paths)) {
|
||||
projection[path] = 1
|
||||
}
|
||||
const cursor = collection.find(
|
||||
{},
|
||||
{
|
||||
...queryOptions,
|
||||
projection,
|
||||
}
|
||||
)
|
||||
|
||||
for await (const doc of cursor) {
|
||||
processed++
|
||||
|
||||
let update = null
|
||||
for (const [name, path] of Object.entries(paths)) {
|
||||
const blob = _.get(doc, path)
|
||||
if (!blob) continue
|
||||
// Schema: LABEL-VERSION:SALT:CIPHERTEXT:IV
|
||||
const [label] = blob.split(':')
|
||||
let [, version] = label.split('-')
|
||||
version = version || 'v2'
|
||||
|
||||
const key = [name, version, collectionName, path, label].join(':')
|
||||
stats[key] = (stats[key] || 0) + 1
|
||||
|
||||
if (version === 'v2') {
|
||||
update = update || {}
|
||||
update[path] = await reEncryptTokens(accessTokenEncryptor, blob)
|
||||
}
|
||||
}
|
||||
|
||||
if (Date.now() - lastLog >= LOG_EVERY_IN_S * 1000) {
|
||||
logProgress()
|
||||
lastLog = Date.now()
|
||||
}
|
||||
if (update) {
|
||||
updatedNUsers++
|
||||
|
||||
const { _id } = doc
|
||||
if (DRY_RUN) {
|
||||
console.log('Would upgrade tokens for user', _id, Object.keys(update))
|
||||
} else {
|
||||
console.log('Upgrading tokens for user', _id, Object.keys(update))
|
||||
await collection.updateOne({ _id }, { $set: update })
|
||||
}
|
||||
}
|
||||
}
|
||||
logProgress()
|
||||
formatTokenUsageStats(stats)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
reEncryptTokensInCollection,
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
module.exports = {
|
||||
reporterEnabled: 'spec, mocha-junit-reporter',
|
||||
mochaJunitReporterReporterOptions: {
|
||||
mochaFile: `reports/junit-mocha-${process.env.MOCHA_GREP}.xml`,
|
||||
includePending: true,
|
||||
jenkinsMode: true,
|
||||
output: true,
|
||||
},
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
const chai = require('chai')
|
||||
const chaiAsPromised = require('chai-as-promised')
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
|
||||
chai.use(chaiAsPromised)
|
||||
|
||||
SandboxedModule.configure({
|
||||
sourceTransformers: {
|
||||
removeNodePrefix: function (source) {
|
||||
return source.replace(/require\(['"]node:/g, "require('")
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -1,305 +0,0 @@
|
||||
const chai = require('chai')
|
||||
chai.should()
|
||||
const { expect } = chai
|
||||
const modulePath = '../../../index.js'
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
|
||||
describe('AccessTokenEncryptor', function () {
|
||||
beforeEach(function () {
|
||||
this.testObject = { hello: 'world' }
|
||||
this.encrypted2015 =
|
||||
'2015.1:473a66fb5d816bc716f278ab819d88a5:+mTg7O9sgUND8pNQFG6h2GE='
|
||||
this.encrypted2016 =
|
||||
'2016.1:76a7d64a444ccee1a515b49c44844a69:m5YSkexUsLjcF4gLncm72+k='
|
||||
this.encrypted2019 =
|
||||
'2019.1:627143b2ab185a020c8720253a4c984e:7gnY6Ez3/Y3UWgLHLfBtJsE=:bf75cecb6aeea55b3c060e1122d2a82d'
|
||||
this.encrypted2023 =
|
||||
'2023.1-v3:a6dd3781dd6ce93a4134874b505a209c:9TdIDAc8V9SeR0ffSn63Jj4=:d8b2de0b733c81b949993dce229abb4c'
|
||||
this.badLabel = 'xxxxxx:c7a39310056b694c:jQf+Uh5Den3JREtvc82GW5Q='
|
||||
this.badKey = '2015.1:d7a39310056b694c:jQf+Uh5Den3JREtvc82GW5Q='
|
||||
this.badCipherText = '2015.1:c7a39310056b694c:xQf+Uh5Den3JREtvc82GW5Q='
|
||||
this.settings = {
|
||||
cipherLabel: '2023.1-v3',
|
||||
cipherPasswords: {
|
||||
'2023.1-v3': '44444444444444444444444444444444444444',
|
||||
},
|
||||
}
|
||||
this.AccessTokenEncryptor = SandboxedModule.require(modulePath, {
|
||||
globals: {
|
||||
Buffer,
|
||||
},
|
||||
})
|
||||
this.encryptor = new this.AccessTokenEncryptor(this.settings)
|
||||
})
|
||||
|
||||
describe('invalid settings', function () {
|
||||
it('should flag missing label', function () {
|
||||
expect(
|
||||
() =>
|
||||
new this.AccessTokenEncryptor({
|
||||
cipherLabel: '',
|
||||
cipherPasswords: { '': '' },
|
||||
})
|
||||
).to.throw(/cipherLabel cannot be empty/)
|
||||
})
|
||||
|
||||
it('should flag invalid label with colon', function () {
|
||||
expect(
|
||||
() =>
|
||||
new this.AccessTokenEncryptor({
|
||||
cipherLabel: '2023:1-v2',
|
||||
cipherPasswords: { '2023:1-v2': '' },
|
||||
})
|
||||
).to.throw(/colon/)
|
||||
})
|
||||
|
||||
it('should flag missing password', function () {
|
||||
expect(
|
||||
() =>
|
||||
new this.AccessTokenEncryptor({
|
||||
cipherPasswords: { '2023.1-v3': '' },
|
||||
cipherVersions: { '2023.1-v3': 'v3' },
|
||||
})
|
||||
).to.throw(/cipherPasswords.+ missing/)
|
||||
expect(
|
||||
() =>
|
||||
new this.AccessTokenEncryptor({
|
||||
cipherLabel: '2023.1-v3',
|
||||
cipherPasswords: { '2023.1-v3': undefined },
|
||||
})
|
||||
).to.throw(/cipherPasswords.+ missing/)
|
||||
})
|
||||
|
||||
it('should flag short password', function () {
|
||||
expect(
|
||||
() =>
|
||||
new this.AccessTokenEncryptor({
|
||||
cipherLabel: '2023.1-v3',
|
||||
cipherPasswords: { '2023.1-v3': 'foo' },
|
||||
})
|
||||
).to.throw(/cipherPasswords.+ too short/)
|
||||
})
|
||||
|
||||
it('should flag missing version', function () {
|
||||
expect(
|
||||
() =>
|
||||
new this.AccessTokenEncryptor({
|
||||
cipherLabel: '2023.1',
|
||||
cipherPasswords: { 2023.1: '11111111111111111111111111111111' },
|
||||
})
|
||||
).to.throw(/must contain version suffix/)
|
||||
expect(
|
||||
() =>
|
||||
new this.AccessTokenEncryptor({
|
||||
cipherLabel: '2023.1-',
|
||||
cipherPasswords: { '2023.1-': '11111111111111111111111111111111' },
|
||||
})
|
||||
).to.throw(/must contain version suffix/)
|
||||
})
|
||||
|
||||
it('should flag invalid version', function () {
|
||||
expect(
|
||||
() =>
|
||||
new this.AccessTokenEncryptor({
|
||||
cipherLabel: '2023.1-v0',
|
||||
cipherPasswords: {
|
||||
'2023.1-v0': '11111111111111111111111111111111',
|
||||
},
|
||||
})
|
||||
).to.throw(/unknown version/)
|
||||
})
|
||||
|
||||
it('should flag unknown default scheme', function () {
|
||||
expect(
|
||||
() =>
|
||||
new this.AccessTokenEncryptor({
|
||||
cipherLabel: '2000.1-v3',
|
||||
cipherPasswords: {
|
||||
'2023.1-v3': '11111111111111111111111111111111',
|
||||
},
|
||||
})
|
||||
).to.throw(/unknown default cipherLabel/)
|
||||
})
|
||||
})
|
||||
|
||||
describe('sync', function () {
|
||||
describe('encrypt', function () {
|
||||
it('should encrypt the object', function (done) {
|
||||
this.encryptor.encryptJson(this.testObject, (err, encrypted) => {
|
||||
expect(err).to.be.null
|
||||
encrypted.should.match(
|
||||
/^2023.1-v3:[0-9a-f]{32}:[a-zA-Z0-9=+/]+:[0-9a-f]{32}$/
|
||||
)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should encrypt the object differently the next time', function (done) {
|
||||
this.encryptor.encryptJson(this.testObject, (err, encrypted1) => {
|
||||
expect(err).to.be.null
|
||||
this.encryptor.encryptJson(this.testObject, (err, encrypted2) => {
|
||||
expect(err).to.be.null
|
||||
encrypted1.should.not.equal(encrypted2)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('decrypt', function () {
|
||||
it('should decrypt the string to get the same object', function (done) {
|
||||
this.encryptor.encryptJson(this.testObject, (err, encrypted) => {
|
||||
expect(err).to.be.null
|
||||
this.encryptor.decryptToJson(encrypted, (err, decrypted) => {
|
||||
expect(err).to.be.null
|
||||
expect(decrypted).to.deep.equal(this.testObject)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('should not be able to decrypt 2015 string', function (done) {
|
||||
this.encryptor.decryptToJson(this.encrypted2015, (err, decrypted) => {
|
||||
expect(err).to.exist
|
||||
expect(err.message).to.equal(
|
||||
'unknown access-token-encryptor label 2015.1'
|
||||
)
|
||||
expect(decrypted).to.not.exist
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not be able to decrypt a 2016 string', function (done) {
|
||||
this.encryptor.decryptToJson(this.encrypted2016, (err, decrypted) => {
|
||||
expect(err).to.exist
|
||||
expect(err.message).to.equal(
|
||||
'unknown access-token-encryptor label 2016.1'
|
||||
)
|
||||
expect(decrypted).to.not.exist
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not be able to decrypt a 2019 string', function (done) {
|
||||
this.encryptor.decryptToJson(this.encrypted2019, (err, decrypted) => {
|
||||
expect(err).to.exist
|
||||
expect(err.message).to.equal(
|
||||
'unknown access-token-encryptor label 2019.1'
|
||||
)
|
||||
expect(decrypted).to.not.exist
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should decrypt an 2023 string to get the same object', function (done) {
|
||||
this.encryptor.decryptToJson(this.encrypted2023, (err, decrypted) => {
|
||||
expect(err).to.be.null
|
||||
expect(decrypted).to.deep.equal(this.testObject)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should return an error when decrypting an invalid label', function (done) {
|
||||
this.encryptor.decryptToJson(this.badLabel, (err, decrypted) => {
|
||||
expect(err).to.be.instanceof(Error)
|
||||
expect(decrypted).to.be.undefined
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should return an error when decrypting an invalid key', function (done) {
|
||||
this.encryptor.decryptToJson(this.badKey, (err, decrypted) => {
|
||||
expect(err).to.be.instanceof(Error)
|
||||
expect(decrypted).to.be.undefined
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should return an error when decrypting an invalid ciphertext', function (done) {
|
||||
this.encryptor.decryptToJson(this.badCipherText, (err, decrypted) => {
|
||||
expect(err).to.be.instanceof(Error)
|
||||
expect(decrypted).to.be.undefined
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('async', function () {
|
||||
describe('encrypt', function () {
|
||||
it('should encrypt the object', async function () {
|
||||
const encrypted = await this.encryptor.promises.encryptJson(
|
||||
this.testObject
|
||||
)
|
||||
encrypted.should.match(
|
||||
/^2023.1-v3:[0-9a-f]{32}:[a-zA-Z0-9=+/]+:[0-9a-f]{32}$/
|
||||
)
|
||||
})
|
||||
|
||||
it('should encrypt the object differently the next time', async function () {
|
||||
const encrypted1 = await this.encryptor.promises.encryptJson(
|
||||
this.testObject
|
||||
)
|
||||
const encrypted2 = await this.encryptor.promises.encryptJson(
|
||||
this.testObject
|
||||
)
|
||||
encrypted1.should.not.equal(encrypted2)
|
||||
})
|
||||
})
|
||||
|
||||
describe('decrypt', function () {
|
||||
it('should decrypt the string to get the same object', async function () {
|
||||
const encrypted = await this.encryptor.promises.encryptJson(
|
||||
this.testObject
|
||||
)
|
||||
const decrypted = await this.encryptor.promises.decryptToJson(encrypted)
|
||||
expect(decrypted).to.deep.equal(this.testObject)
|
||||
})
|
||||
|
||||
it('should not be able to decrypt 2015 string', async function () {
|
||||
await expect(
|
||||
this.encryptor.promises.decryptToJson(this.encrypted2015)
|
||||
).to.eventually.be.rejectedWith(
|
||||
'unknown access-token-encryptor label 2015.1'
|
||||
)
|
||||
})
|
||||
|
||||
it('should not be able to decrypt a 2016 string', async function () {
|
||||
await expect(
|
||||
this.encryptor.promises.decryptToJson(this.encrypted2016)
|
||||
).to.be.rejectedWith('unknown access-token-encryptor label 2016.1')
|
||||
})
|
||||
|
||||
it('should not be able to decrypt a 2019 string', async function () {
|
||||
await expect(
|
||||
this.encryptor.promises.decryptToJson(this.encrypted2019)
|
||||
).to.be.rejectedWith('unknown access-token-encryptor label 2019.1')
|
||||
})
|
||||
|
||||
it('should decrypt an 2023 string to get the same object', async function () {
|
||||
const decrypted = await this.encryptor.promises.decryptToJson(
|
||||
this.encrypted2023
|
||||
)
|
||||
expect(decrypted).to.deep.equal(this.testObject)
|
||||
})
|
||||
|
||||
it('should return an error when decrypting an invalid label', async function () {
|
||||
await expect(
|
||||
this.encryptor.promises.decryptToJson(this.badLabel)
|
||||
).to.be.rejectedWith('unknown access-token-encryptor label xxxxxx')
|
||||
})
|
||||
|
||||
it('should return an error when decrypting an invalid key', async function () {
|
||||
await expect(
|
||||
this.encryptor.promises.decryptToJson(this.badKey)
|
||||
).to.be.rejectedWith('unknown access-token-encryptor label 2015.1')
|
||||
})
|
||||
|
||||
it('should return an error when decrypting an invalid ciphertext', async function () {
|
||||
await expect(
|
||||
this.encryptor.promises.decryptToJson(this.badCipherText)
|
||||
).to.be.rejectedWith('unknown access-token-encryptor label 2015.1')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.backend.json",
|
||||
"include": ["**/*.js", "**/*.cjs", "**/*.ts"]
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
module.exports = {
|
||||
rules: {
|
||||
'no-unnecessary-trans': require('./no-unnecessary-trans'),
|
||||
'prefer-kebab-url': require('./prefer-kebab-url'),
|
||||
'should-unescape-trans': require('./should-unescape-trans'),
|
||||
'no-generated-editor-themes': require('./no-generated-editor-themes'),
|
||||
'require-script-runner': require('./require-script-runner'),
|
||||
'require-vi-doMock-valid-path': require('./require-vi-doMock-valid-path'),
|
||||
'require-loading-label': require('./require-loading-label'),
|
||||
'require-cio-snake-case-properties': require('./require-cio-snake-case-properties'),
|
||||
},
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: 'error',
|
||||
docs: {
|
||||
description:
|
||||
'Prohibit CodeMirror themes that are generated in a function',
|
||||
},
|
||||
},
|
||||
create(context) {
|
||||
return {
|
||||
':matches(ArrowFunctionExpression, FunctionDeclaration, FunctionExpression) CallExpression > MemberExpression[object.name="EditorView"]:matches([property.name="theme"],[property.name="baseTheme"])'(
|
||||
node
|
||||
) {
|
||||
context.report({
|
||||
node,
|
||||
message: `EditorView.theme and EditorView.baseTheme each add CSS to the page for every instance of the theme. Store the theme in a variable and reuse it instead.`,
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: 'problem',
|
||||
fixable: 'code',
|
||||
docs: {
|
||||
description: 'Prohibit Trans with no components or values',
|
||||
},
|
||||
},
|
||||
create(context) {
|
||||
return {
|
||||
'JSXOpeningElement[name.name="Trans"]'(node) {
|
||||
const attributes = new Map(
|
||||
node.attributes.map(attr => [attr.name.name, attr])
|
||||
)
|
||||
|
||||
if (!attributes.has('components')) {
|
||||
if (node.parent.children.length > 0) {
|
||||
context.report({
|
||||
node,
|
||||
message: `Trans components must not have child elements`,
|
||||
})
|
||||
} else if (attributes.has('values')) {
|
||||
context.report({
|
||||
node,
|
||||
message: `Use t('…') when there are no components`,
|
||||
})
|
||||
} else {
|
||||
context.report({
|
||||
node,
|
||||
message: `Use t('…') when there are no components`,
|
||||
fix(fixer) {
|
||||
const i18nKey = attributes.get('i18nKey').value.value
|
||||
|
||||
// Note: Prettier can fix indentation
|
||||
return fixer.replaceText(node.parent, `{t('${i18nKey}')}`)
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"name": "@overleaf/eslint-plugin",
|
||||
"version": "0.1.0",
|
||||
"author": "Overleaf (https://www.overleaf.com)",
|
||||
"license": "AGPL-3.0-only",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"eslint": "^8.51.0",
|
||||
"lodash": "^4.17.21"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/parser": "^8.50.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node rules.test.js"
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
// URL parts should be kebab-case, but we didn't have this rule in the past.
|
||||
// The ESLint rule `prefer-kebab-url` will ignore these "legacy" URL parts.
|
||||
|
||||
const ignoreWords = {
|
||||
snake: new Set([
|
||||
'clear_saml_data',
|
||||
'confirm_link',
|
||||
'confirm_university_domain',
|
||||
'create_recurly_account',
|
||||
'current_history_content',
|
||||
'current_user',
|
||||
'default_email',
|
||||
'disable_managed_users',
|
||||
'doc_snapshot',
|
||||
'enable_history_ranges_support',
|
||||
'features_override',
|
||||
'generate_password_reset_url',
|
||||
'get_assignment',
|
||||
'get_clone',
|
||||
'health_check',
|
||||
'institutional_emails',
|
||||
'latest_template',
|
||||
'link_after_saml_response',
|
||||
'linked_file',
|
||||
'metrics_segmentation',
|
||||
'new_users',
|
||||
'no_autostart_post_gateway',
|
||||
'personal_info',
|
||||
'planned_maintenance',
|
||||
'refresh_features',
|
||||
'register_admin',
|
||||
'register_ldap_admin',
|
||||
'register_saml_admin',
|
||||
'restore_file',
|
||||
'revert_file',
|
||||
'saved_vers',
|
||||
'send_test_email',
|
||||
'session_maintenance',
|
||||
'set_in_session',
|
||||
'sign_in_to_link',
|
||||
'split_test',
|
||||
'sso_configuration_test',
|
||||
'sso_email',
|
||||
'sso_enrollment',
|
||||
'track_changes',
|
||||
'update_admin',
|
||||
'user_details',
|
||||
]),
|
||||
camel: new Set([
|
||||
'addWorkflowScope',
|
||||
'aiErrorAssistant',
|
||||
'aiFeatureUsage',
|
||||
'beginAuth',
|
||||
'brandVariationId',
|
||||
'closeEditor',
|
||||
'completeRegistration',
|
||||
'deactivateOldProjects',
|
||||
'deletedSubscription',
|
||||
'disconnectAllUsers',
|
||||
'editingSession',
|
||||
'emailSubscription',
|
||||
'enableManagedUsers',
|
||||
'externalCollaboration',
|
||||
'flushProjectToTpds',
|
||||
'indexAll',
|
||||
'offboardManagedUser',
|
||||
'openEditor',
|
||||
'perfTest',
|
||||
'pollDropboxForUser',
|
||||
'resendInvite',
|
||||
'resendManagedUserInvite',
|
||||
'salesContactForm',
|
||||
'showSupport',
|
||||
]),
|
||||
other: new Set([
|
||||
'Project',
|
||||
'disableSSO',
|
||||
'enableSSO',
|
||||
'resendSSOLinkInvite',
|
||||
'usersCSV',
|
||||
]),
|
||||
}
|
||||
|
||||
module.exports = { ignoreWords }
|
||||
@@ -1,91 +0,0 @@
|
||||
const _ = require('lodash')
|
||||
const { ignoreWords } = require('./prefer-kebab-url-ignore')
|
||||
|
||||
const removeTextBetweenBrackets = text => {
|
||||
while (text.includes('[') || text.includes('(')) {
|
||||
text = text.replaceAll(/\[[^[\]]*]/g, '')
|
||||
text = text.replaceAll(/\([^()]*\)/g, '')
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
const shouldIgnoreWord = str =>
|
||||
str.includes(':') ||
|
||||
str.includes('(') ||
|
||||
str === '*' ||
|
||||
str.match(/^[a-z0-9.]+$/) ||
|
||||
ignoreWords.snake.has(str) ||
|
||||
ignoreWords.camel.has(str) ||
|
||||
ignoreWords.other.has(str)
|
||||
|
||||
const getSuggestion = routePath => {
|
||||
if (typeof routePath === 'string') {
|
||||
const kebabed = routePath
|
||||
.split('/')
|
||||
.map(word => (shouldIgnoreWord(word) ? word : _.kebabCase(word)))
|
||||
.join('/')
|
||||
return kebabed === routePath ? null : `'${kebabed}'`
|
||||
}
|
||||
|
||||
if (routePath instanceof RegExp) {
|
||||
const words = removeTextBetweenBrackets(routePath.source).match(/[\w-]+/g)
|
||||
if (!words) return routePath
|
||||
|
||||
let newSource = routePath.source
|
||||
for (const word of words) {
|
||||
if (!shouldIgnoreWord(word)) {
|
||||
newSource = newSource.replaceAll(
|
||||
new RegExp(`\\b${word}\\b`, 'g'),
|
||||
_.kebabCase(word)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const kebabed = new RegExp(newSource, routePath.flags)
|
||||
return kebabed.source.toString() === routePath.source.toString()
|
||||
? null
|
||||
: kebabed
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: 'problem',
|
||||
fixable: 'code',
|
||||
hasSuggestions: true,
|
||||
docs: {
|
||||
description: 'Enforce using kebab-case for URL paths',
|
||||
},
|
||||
},
|
||||
create: context => ({
|
||||
CallExpression(node) {
|
||||
if (
|
||||
node.callee.type === 'MemberExpression' &&
|
||||
node.arguments[0]?.type === 'Literal' &&
|
||||
[/app/i, /router/i].some(callee =>
|
||||
typeof callee === 'string'
|
||||
? node.callee.object.name === callee
|
||||
: callee.test(node.callee.object.name)
|
||||
) &&
|
||||
['get', 'post', 'put', 'delete'].includes(node.callee.property.name)
|
||||
) {
|
||||
const routePath = node.arguments[0].value
|
||||
|
||||
const suggestion = getSuggestion(routePath)
|
||||
|
||||
if (suggestion) {
|
||||
context.report({
|
||||
node: node.arguments[0],
|
||||
message: 'Route path should be in kebab-case.',
|
||||
suggest: [
|
||||
{
|
||||
desc: `Change to kebab-case: ${suggestion}`,
|
||||
fix: fixer => fixer.replaceText(node.arguments[0], suggestion),
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
}),
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const SNAKE_CASE_RE = /^[a-z][a-z0-9]*(_[a-z0-9]+)*$/
|
||||
|
||||
function isSnakeCase(name) {
|
||||
return SNAKE_CASE_RE.test(name)
|
||||
}
|
||||
|
||||
function getStaticKeyName(property) {
|
||||
if (property.computed) return null
|
||||
if (property.key.type === 'Identifier') return property.key.name
|
||||
if (property.key.type === 'Literal' && typeof property.key.value === 'string')
|
||||
return property.key.value
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a node is a call to CustomerIoHandler.updateUserAttributes()
|
||||
* and return the attributes argument (2nd argument)
|
||||
*/
|
||||
function getUpdateUserAttributesArg(node) {
|
||||
if (
|
||||
node.callee.type === 'MemberExpression' &&
|
||||
node.callee.object.type === 'Identifier' &&
|
||||
node.callee.object.name === 'CustomerIoHandler' &&
|
||||
node.callee.property.name === 'updateUserAttributes' &&
|
||||
node.arguments[1]?.type === 'ObjectExpression'
|
||||
) {
|
||||
return node.arguments[1]
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a node is a call to Modules[.promises].hooks.fire('setUserProperties', ...)
|
||||
* and return the attributes argument (3rd argument)
|
||||
*/
|
||||
function getSetUserPropertiesArg(node) {
|
||||
const callee = node.callee
|
||||
if (callee.type !== 'MemberExpression' || callee.property.name !== 'fire') {
|
||||
return null
|
||||
}
|
||||
|
||||
// Check first argument is 'setUserProperties'
|
||||
if (
|
||||
!node.arguments[0] ||
|
||||
node.arguments[0].type !== 'Literal' ||
|
||||
node.arguments[0].value !== 'setUserProperties'
|
||||
) {
|
||||
return null
|
||||
}
|
||||
|
||||
// Match: Modules.hooks.fire or Modules.promises.hooks.fire
|
||||
const obj = callee.object
|
||||
if (obj.type === 'MemberExpression' && obj.property.name === 'hooks') {
|
||||
const parent = obj.object
|
||||
// Modules.hooks
|
||||
if (parent.type === 'Identifier' && parent.name === 'Modules') {
|
||||
if (node.arguments[2]?.type === 'ObjectExpression') {
|
||||
return node.arguments[2]
|
||||
}
|
||||
}
|
||||
// Modules.promises.hooks
|
||||
if (
|
||||
parent.type === 'MemberExpression' &&
|
||||
parent.property.name === 'promises' &&
|
||||
parent.object.type === 'Identifier' &&
|
||||
parent.object.name === 'Modules'
|
||||
) {
|
||||
if (node.arguments[2]?.type === 'ObjectExpression') {
|
||||
return node.arguments[2]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description:
|
||||
'Enforce snake_case for Customer.io user property attribute names',
|
||||
},
|
||||
},
|
||||
create(context) {
|
||||
return {
|
||||
CallExpression(node) {
|
||||
const attrsNode =
|
||||
getUpdateUserAttributesArg(node) || getSetUserPropertiesArg(node)
|
||||
if (!attrsNode) return
|
||||
|
||||
for (const property of attrsNode.properties) {
|
||||
if (property.type === 'SpreadElement') continue
|
||||
|
||||
const keyName = getStaticKeyName(property)
|
||||
if (keyName === null) continue // skip computed/dynamic keys
|
||||
|
||||
if (!isSnakeCase(keyName)) {
|
||||
context.report({
|
||||
node: property.key,
|
||||
message: `Customer.io attribute '{{name}}' must be in snake_case.`,
|
||||
data: { name: keyName },
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: 'problem',
|
||||
fixable: null,
|
||||
docs: {
|
||||
description:
|
||||
'Require loadingLabel prop when isLoading is specified on OLButton',
|
||||
},
|
||||
schema: [],
|
||||
},
|
||||
create(context) {
|
||||
return {
|
||||
'JSXOpeningElement[name.name="OLButton"]'(node) {
|
||||
const attributes = new Map(
|
||||
node.attributes.map(attr => [attr.name?.name, attr])
|
||||
)
|
||||
|
||||
const isLoadingAttr = attributes.get('isLoading')
|
||||
const loadingLabelAttr = attributes.get('loadingLabel')
|
||||
|
||||
if (isLoadingAttr && !loadingLabelAttr) {
|
||||
const isLoadingValue = isLoadingAttr.value
|
||||
|
||||
if (
|
||||
!isLoadingValue ||
|
||||
(isLoadingValue.type === 'JSXExpressionContainer' &&
|
||||
isLoadingValue.expression.type === 'Literal' &&
|
||||
isLoadingValue.expression.value === true)
|
||||
) {
|
||||
context.report({
|
||||
node: isLoadingAttr,
|
||||
message:
|
||||
'Button with isLoading prop must also specify loadingLabel',
|
||||
})
|
||||
} else if (
|
||||
isLoadingValue.type === 'JSXExpressionContainer' &&
|
||||
isLoadingValue.expression.type !== 'Literal'
|
||||
) {
|
||||
context.report({
|
||||
node: isLoadingAttr,
|
||||
message:
|
||||
'Button with isLoading prop must also specify loadingLabel',
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Require Script Runner for scripts',
|
||||
},
|
||||
},
|
||||
create(context) {
|
||||
let hasImport = false
|
||||
|
||||
return {
|
||||
ImportDeclaration(node) {
|
||||
if (node.source.value.endsWith('lib/ScriptRunner.mjs')) {
|
||||
hasImport = true
|
||||
}
|
||||
},
|
||||
'Program:exit'() {
|
||||
if (!hasImport) {
|
||||
context.report({
|
||||
loc: { line: 1, column: 0 },
|
||||
message:
|
||||
'Please use Script Runner for scripts. Refer to the developer manual (https://manual.dev-overleaf.com/development/code/web_scripts/#monitor-script-execution-and-usage-with-script-runner) for more information.',
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
const path = require('node:path')
|
||||
const fs = require('node:fs')
|
||||
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: 'Ensure vi.doMock first argument is a resolvable path.',
|
||||
category: 'Best Practices',
|
||||
recommended: false,
|
||||
url: '',
|
||||
},
|
||||
fixable: 'code',
|
||||
hasSuggestions: true,
|
||||
schema: [],
|
||||
messages: {
|
||||
unresolvablePath:
|
||||
'The path "{{pathValue}}" in vi.doMock() cannot be resolved relative to the current file.',
|
||||
notAStringLiteral:
|
||||
'The first argument of vi.doMock() must be (or resolve to) a string literal representing a path.',
|
||||
noArguments: 'vi.doMock() called with no arguments.',
|
||||
},
|
||||
},
|
||||
create(context) {
|
||||
const currentFilePath = context.getFilename()
|
||||
// ESLint can sometimes pass <text> or <input> for snippets not in a file
|
||||
if (currentFilePath === '<text>' || currentFilePath === '<input>') {
|
||||
return {}
|
||||
}
|
||||
const currentDirectory = path.dirname(currentFilePath)
|
||||
|
||||
function canResolve(modulePath) {
|
||||
try {
|
||||
require.resolve(path.resolve(currentDirectory, modulePath))
|
||||
return true
|
||||
} catch (e) {
|
||||
const absolutePath = path.resolve(currentDirectory, modulePath)
|
||||
const extensions = [
|
||||
'',
|
||||
'.js',
|
||||
'.mjs',
|
||||
'.ts',
|
||||
'.jsx',
|
||||
'.tsx',
|
||||
'.json',
|
||||
'.node',
|
||||
'/index.js',
|
||||
'/index.ts',
|
||||
] // Add common extensions
|
||||
for (const ext of extensions) {
|
||||
if (fs.existsSync(absolutePath + ext)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
CallExpression(node) {
|
||||
if (
|
||||
node.callee.type === 'MemberExpression' &&
|
||||
node.callee.object.type === 'Identifier' &&
|
||||
node.callee.object.name === 'vi' &&
|
||||
node.callee.property.type === 'Identifier' &&
|
||||
node.callee.property.name === 'doMock'
|
||||
) {
|
||||
if (node.arguments.length === 0) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'noArguments',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const firstArg = node.arguments[0]
|
||||
let pathValue = firstArg.value
|
||||
|
||||
if (
|
||||
firstArg.type !== 'Literal' ||
|
||||
typeof firstArg.value !== 'string'
|
||||
) {
|
||||
if (firstArg.type === 'Identifier') {
|
||||
const variable = context
|
||||
.getScope()
|
||||
.variables.find(v => v.name === firstArg.name)
|
||||
if (
|
||||
variable &&
|
||||
variable.defs.length > 0 &&
|
||||
variable.defs[0].node.init &&
|
||||
variable.defs[0].node.init.type === 'Literal' &&
|
||||
typeof variable.defs[0].node.init.value === 'string'
|
||||
) {
|
||||
pathValue = variable.defs[0].node.init.value
|
||||
if (canResolve(pathValue)) {
|
||||
return
|
||||
}
|
||||
// If the first argument was a variable that didn't resolve then we can't auto-fix it
|
||||
}
|
||||
}
|
||||
context.report({
|
||||
node: firstArg,
|
||||
messageId: 'notAStringLiteral',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!pathValue.startsWith('.')) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!canResolve(pathValue)) {
|
||||
const mjsPath = pathValue.replace('.js', '.mjs')
|
||||
const additionalReportOptions = {}
|
||||
if (canResolve(mjsPath)) {
|
||||
additionalReportOptions.fix = fixer =>
|
||||
fixer.replaceText(firstArg, `'${mjsPath}'`)
|
||||
additionalReportOptions.suggest = [
|
||||
{
|
||||
desc: `Replace with "${pathValue.replace('.js', '.mjs')}"`,
|
||||
fix: fixer => fixer.replaceText(firstArg, `'${mjsPath}'`),
|
||||
},
|
||||
]
|
||||
}
|
||||
context.report({
|
||||
node: firstArg,
|
||||
messageId: 'unresolvablePath',
|
||||
data: {
|
||||
pathValue,
|
||||
},
|
||||
...additionalReportOptions,
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -1,269 +0,0 @@
|
||||
const { RuleTester } = require('eslint')
|
||||
const preferKebabUrl = require('./prefer-kebab-url')
|
||||
const noUnnecessaryTrans = require('./no-unnecessary-trans')
|
||||
const shouldUnescapeTrans = require('./should-unescape-trans')
|
||||
const noGeneratedEditorThemes = require('./no-generated-editor-themes')
|
||||
const viDoMockValidPath = require('./require-vi-doMock-valid-path')
|
||||
const requireCioSnakeCaseProperties = require('./require-cio-snake-case-properties')
|
||||
|
||||
const ruleTester = new RuleTester({
|
||||
parser: require.resolve('@typescript-eslint/parser'),
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
ecmaFeatures: { jsx: true },
|
||||
},
|
||||
})
|
||||
|
||||
ruleTester.run('prefer-kebab-url', preferKebabUrl, {
|
||||
valid: [
|
||||
{ code: `app.get('/foo-bar')` },
|
||||
{ code: `app.get('/foo-bar/:id')` },
|
||||
{ code: `router.post('/foo-bar')` },
|
||||
{ code: `router.get('/foo-bar/:id/:name/:age')` },
|
||||
{ code: `webRouter.get('/foo-bar/:user_id/(ProjectName)/get-info')` },
|
||||
{ code: `webApp.post('/foo-bar/:user_id/(ProjectName)/get-info')` },
|
||||
{
|
||||
code: `router.get(/^\\/download\\/project\\/([^/]*)\\/output\\/output\\.pdf$/)`,
|
||||
},
|
||||
{
|
||||
code: `webRouter.get(/^\\/project\\/([^/]*)\\/user\\/([0-9a-f]+)\\/build\\/([0-9a-f-]+)\\/output\\/(.*)$/)`,
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
code: `app.get('/fooBar')`,
|
||||
errors: [{ message: 'Route path should be in kebab-case.' }],
|
||||
},
|
||||
{
|
||||
code: `app.get('/fooBar/:id')`,
|
||||
errors: [{ message: 'Route path should be in kebab-case.' }],
|
||||
},
|
||||
{
|
||||
code: `webRouter.get('/foo_bar/:id/FooBar/:name/fooBar')`,
|
||||
errors: [{ message: 'Route path should be in kebab-case.' }],
|
||||
},
|
||||
{
|
||||
code: `router.get(/^\\/downLoad\\/pro-ject\\/([^/]*)\\/OutPut\\/out-put\\.pdf$/)`,
|
||||
errors: [{ message: 'Route path should be in kebab-case.' }],
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
ruleTester.run('no-unnecessary-trans', noUnnecessaryTrans, {
|
||||
valid: [
|
||||
{ code: `<Trans i18nKey="test" components={{ strong: <strong/> }}/>` },
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
code: `<Trans i18nKey="test" values={{ test: 'foo '}}/>`,
|
||||
errors: [{ message: `Use t('…') when there are no components` }],
|
||||
},
|
||||
{
|
||||
code: `<Trans i18nKey="test" />`,
|
||||
errors: [{ message: `Use t('…') when there are no components` }],
|
||||
output: `{t('test')}`,
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
ruleTester.run('should-unescape-trans', shouldUnescapeTrans, {
|
||||
valid: [
|
||||
{
|
||||
code: `<Trans i18nKey="test" components={{ strong: <strong/> }}/>`,
|
||||
},
|
||||
{
|
||||
code: `<Trans i18nKey="test" values={{ foo: 'bar' }} components={{ strong: <strong/> }} shouldUnescape tOptions={{ interpolation: { escapeValue: true } }}/>`,
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
code: `<Trans i18nKey="test" values={{ foo: 'bar' }} components={{ strong: <strong/> }} />`,
|
||||
errors: [{ message: 'Trans with values must have shouldUnescape' }],
|
||||
output: `<Trans i18nKey="test" values={{ foo: 'bar' }}\nshouldUnescape components={{ strong: <strong/> }} />`,
|
||||
},
|
||||
{
|
||||
code: `<Trans i18nKey="test" values={{ foo: 'bar' }} components={{ strong: <strong/> }} shouldUnescape />`,
|
||||
errors: [
|
||||
{
|
||||
message:
|
||||
'Trans with shouldUnescape must have tOptions.interpolation.escapeValue',
|
||||
},
|
||||
],
|
||||
output: `<Trans i18nKey="test" values={{ foo: 'bar' }} components={{ strong: <strong/> }} shouldUnescape\ntOptions={{ interpolation: { escapeValue: true } }} />`,
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
const noGeneratedEditorThemesError =
|
||||
'EditorView.theme and EditorView.baseTheme each add CSS to the page for every instance of the theme. Store the theme in a variable and reuse it instead.'
|
||||
ruleTester.run('no-generated-editor-themes', noGeneratedEditorThemes, {
|
||||
valid: [
|
||||
{
|
||||
code: `EditorView.theme({ '.cm-editor': { color: 'black' } })`,
|
||||
},
|
||||
{
|
||||
code: `const theme = EditorView.theme({ '.cm-editor': { color: 'black' } })`,
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
code: `function createTheme() { return EditorView.theme({ '.cm-editor': { color: 'black' } }) }`,
|
||||
errors: [
|
||||
{
|
||||
message: noGeneratedEditorThemesError,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
code: `() => EditorView.theme({ '.cm-editor': { color: 'black' } })`,
|
||||
errors: [
|
||||
{
|
||||
message: noGeneratedEditorThemesError,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
code: `class Foo { createTheme() { return EditorView.theme({ '.cm-editor': { color: 'black' } }) } }`,
|
||||
errors: [
|
||||
{
|
||||
message: noGeneratedEditorThemesError,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
ruleTester.run('domock-require-valid-path', viDoMockValidPath, {
|
||||
valid: [
|
||||
{
|
||||
code: 'vi.doMock("./require-vi-doMock-valid-path.js")',
|
||||
filename: __filename,
|
||||
},
|
||||
{
|
||||
code: 'const filename = "./require-vi-doMock-valid-path.js"; vi.doMock(filename);',
|
||||
filename: __filename,
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
code: "vi.doMock('./require-vi-doMock-valid-path2')",
|
||||
filename: __filename,
|
||||
errors: [
|
||||
{
|
||||
message:
|
||||
'The path "./require-vi-doMock-valid-path2" in vi.doMock() cannot be resolved relative to the current file.',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
code: 'const filename = "./require-vi-doMock-valid-path2.js"; vi.doMock(filename);',
|
||||
filename: __filename,
|
||||
errors: [
|
||||
{
|
||||
message:
|
||||
'The first argument of vi.doMock() must be (or resolve to) a string literal representing a path.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
ruleTester.run(
|
||||
'require-cio-snake-case-properties',
|
||||
requireCioSnakeCaseProperties,
|
||||
{
|
||||
valid: [
|
||||
// updateUserAttributes with snake_case keys
|
||||
{
|
||||
code: `CustomerIoHandler.updateUserAttributes(userId, { plan_type: 'free', group_size: 10 })`,
|
||||
},
|
||||
// Modules.promises.hooks.fire with snake_case keys
|
||||
{
|
||||
code: `Modules.promises.hooks.fire('setUserProperties', userId, { plan_type: 'free', last_active: 123 })`,
|
||||
},
|
||||
// Modules.hooks.fire with snake_case keys
|
||||
{
|
||||
code: `Modules.hooks.fire('setUserProperties', userId, { plan_type: 'free' })`,
|
||||
},
|
||||
// Single-word keys are valid snake_case
|
||||
{
|
||||
code: `CustomerIoHandler.updateUserAttributes(userId, { email: 'a@b.com', role: 'admin' })`,
|
||||
},
|
||||
// Computed/dynamic keys are skipped
|
||||
{
|
||||
code: `CustomerIoHandler.updateUserAttributes(userId, { [dynamicKey]: true })`,
|
||||
},
|
||||
// Spread elements are skipped
|
||||
{
|
||||
code: `CustomerIoHandler.updateUserAttributes(userId, { ...existingAttrs })`,
|
||||
},
|
||||
// Unrelated function calls are not checked
|
||||
{
|
||||
code: `SomeOtherHandler.updateUserAttributes(userId, { camelCase: true })`,
|
||||
},
|
||||
// fire() with a different event name is not checked
|
||||
{
|
||||
code: `Modules.promises.hooks.fire('someOtherEvent', userId, { camelCase: true })`,
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
// camelCase key in updateUserAttributes
|
||||
{
|
||||
code: `CustomerIoHandler.updateUserAttributes(userId, { planType: 'free' })`,
|
||||
errors: [
|
||||
{
|
||||
message: `Customer.io attribute 'planType' must be in snake_case.`,
|
||||
},
|
||||
],
|
||||
},
|
||||
// kebab-case string key
|
||||
{
|
||||
code: `CustomerIoHandler.updateUserAttributes(userId, { 'plan-type': 'free' })`,
|
||||
errors: [
|
||||
{
|
||||
message: `Customer.io attribute 'plan-type' must be in snake_case.`,
|
||||
},
|
||||
],
|
||||
},
|
||||
// PascalCase key
|
||||
{
|
||||
code: `CustomerIoHandler.updateUserAttributes(userId, { PlanType: 'free' })`,
|
||||
errors: [
|
||||
{
|
||||
message: `Customer.io attribute 'PlanType' must be in snake_case.`,
|
||||
},
|
||||
],
|
||||
},
|
||||
// camelCase in Modules.promises.hooks.fire
|
||||
{
|
||||
code: `Modules.promises.hooks.fire('setUserProperties', userId, { planType: 'free' })`,
|
||||
errors: [
|
||||
{
|
||||
message: `Customer.io attribute 'planType' must be in snake_case.`,
|
||||
},
|
||||
],
|
||||
},
|
||||
// camelCase in Modules.hooks.fire
|
||||
{
|
||||
code: `Modules.hooks.fire('setUserProperties', userId, { planType: 'free' })`,
|
||||
errors: [
|
||||
{
|
||||
message: `Customer.io attribute 'planType' must be in snake_case.`,
|
||||
},
|
||||
],
|
||||
},
|
||||
// Multiple invalid keys report multiple errors
|
||||
{
|
||||
code: `CustomerIoHandler.updateUserAttributes(userId, { planType: 'free', groupSize: 10, plan_term: 'annual' })`,
|
||||
errors: [
|
||||
{
|
||||
message: `Customer.io attribute 'planType' must be in snake_case.`,
|
||||
},
|
||||
{
|
||||
message: `Customer.io attribute 'groupSize' must be in snake_case.`,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user