1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/overleaf_ynh.git synced 2024-09-03 19:56:27 +02:00

Merge pull request #20 from YunoHost-Apps/testing

Testing
This commit is contained in:
Thomas 2024-03-07 18:09:09 +01:00 committed by GitHub
commit 9e09ce2295
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 950 additions and 1502 deletions

View file

@ -1,137 +0,0 @@
#!/bin/bash
#=================================================
# PACKAGE UPDATING HELPER
#=================================================
# This script is meant to be run by GitHub Actions
# The YunoHost-Apps organisation offers a template Action to run this script periodically
# Since each app is different, maintainers can adapt its contents so as to perform
# automatic actions when a new upstream release is detected.
# Remove this exit command when you are ready to run this Action
exit 1
#=================================================
# FETCHING LATEST RELEASE AND ITS ASSETS
#=================================================
# Fetching information
current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions)
version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'"))
# Later down the script, we assume the version has only digits and dots
# Sometimes the release name starts with a "v", so let's filter it out.
# You may need more tweaks here if the upstream repository has different naming conventions.
if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then
version=${version:1}
fi
# Setting up the environment variables
echo "Current version: $current_version"
echo "Latest release from upstream: $version"
echo "VERSION=$version" >> $GITHUB_ENV
echo "REPO=$repo" >> $GITHUB_ENV
# For the time being, let's assume the script will fail
echo "PROCEED=false" >> $GITHUB_ENV
# Proceed only if the retrieved version is greater than the current one
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
echo "::warning ::No new version available"
exit 0
# Proceed only if a PR for this new version does not already exist
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then
echo "::warning ::A branch already exists for this update"
exit 0
fi
# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.)
echo "${#assets[@]} available asset(s)"
#=================================================
# UPDATE SOURCE FILES
#=================================================
# Here we use the $assets variable to get the resources published in the upstream release.
# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like.
# Let's loop over the array of assets URLs
for asset_url in ${assets[@]}; do
echo "Handling asset at $asset_url"
# Assign the asset to a source file in conf/ directory
# Here we base the source file name upon a unique keyword in the assets url (admin vs. update)
# Leave $src empty to ignore the asset
case $asset_url in
*"admin"*)
src="app"
;;
*"update"*)
src="app-upgrade"
;;
*)
src=""
;;
esac
# If $src is not empty, let's process the asset
if [ ! -z "$src" ]; then
# Create the temporary directory
tempdir="$(mktemp -d)"
# Download sources and calculate checksum
filename=${asset_url##*/}
curl --silent -4 -L $asset_url -o "$tempdir/$filename"
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
# Delete temporary directory
rm -rf $tempdir
# Get extension
if [[ $filename == *.tar.gz ]]; then
extension=tar.gz
else
extension=${filename##*.}
fi
# Rewrite source file
cat <<EOT > conf/$src.src
SOURCE_URL=$asset_url
SOURCE_SUM=$checksum
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=$extension
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
EOT
echo "... conf/$src.src updated"
else
echo "... asset ignored"
fi
done
#=================================================
# SPECIFIC UPDATE STEPS
#=================================================
# Any action on the app's source code can be done.
# The GitHub Action workflow takes care of committing all changes after this script ends.
#=================================================
# GENERIC FINALIZATION
#=================================================
# Replace new version in manifest
echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json
# No need to update the README, yunohost-bot takes care of it
# The Action will proceed only if the PROCEED environment variable is set to true
echo "PROCEED=true" >> $GITHUB_ENV
exit 0

View file

@ -1,5 +1,5 @@
<!-- <!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/readme_generator
It shall NOT be edited by hand. It shall NOT be edited by hand.
--> -->
@ -19,16 +19,12 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
Overleaf is an open-source online real-time collaborative LaTeX editor. Overleaf is an open-source online real-time collaborative LaTeX editor.
**Shipped version:** 2022.04.23~ynh1 **Shipped version:** 2024.01.26~ynh1
## Screenshots ## Screenshots
![Screenshot of Overleaf](./doc/screenshots/screenshot.png) ![Screenshot of Overleaf](./doc/screenshots/screenshot.png)
## Disclaimers / important information
To create the initial administrator account: `https://yourdomain.com/launchpad`
## Documentation and resources ## Documentation and resources
* Official app website: <https://www.overleaf.com> * Official app website: <https://www.overleaf.com>

View file

@ -1,5 +1,5 @@
<!-- <!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/readme_generator
It shall NOT be edited by hand. It shall NOT be edited by hand.
--> -->
@ -19,16 +19,12 @@ Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
Overleaf est un éditeur LaTeX collaboratif en ligne et en temps réel open source. Overleaf est un éditeur LaTeX collaboratif en ligne et en temps réel open source.
**Version incluse :** 2022.04.23~ynh1 **Version incluse :** 2024.01.26~ynh1
## Captures décran ## Captures décran
![Capture décran de Overleaf](./doc/screenshots/screenshot.png) ![Capture décran de Overleaf](./doc/screenshots/screenshot.png)
## Avertissements / informations importantes
Pour créer le compte administrateur initial : `https://yourdomain.com/launchpad`
## Documentations et ressources ## Documentations et ressources
* Site officiel de lapp : <https://www.overleaf.com> * Site officiel de lapp : <https://www.overleaf.com>

View file

@ -1,22 +0,0 @@
;; Test complet
; Manifest
domain="domain.tld"
is_public=1
language="fr"
admin="john"
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
#upgrade=1 from_commit=CommitHash
backup_restore=1
multi_instance=0
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/overleaf/overleaf/archive/f561650b6217f0dc8e5040415477361a646d970f.tar.gz
SOURCE_SUM=b801aa19a0e5bf39eb89f15d373bfed20e0458aa961d427a66bac6f4259c2b70
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/smhaller/ldap-overleaf-sl/archive/489b158b5070abbfb7159f150260bebe84424535.tar.gz
SOURCE_SUM=a6589b789f19b03fb11deb8fb53b019fbd2e1a6943c55f862d461d61a7d989dd
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,6 +1,9 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ { location __PATH__/ {
# Set max upload size
client_max_body_size 50m;
proxy_pass http://localhost:__PORT__; # The port must match the value of SHARELATEX_PORT. proxy_pass http://localhost:__PORT__; # The port must match the value of SHARELATEX_PORT.
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
@ -16,7 +19,7 @@ location __PATH__/ {
} }
location __PATH__/socket.io/ { location __PATH__/socket.io/ {
proxy_pass http://127.0.0.1:3026; proxy_pass http://localhost:3026;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";
@ -29,16 +32,20 @@ location __PATH__/socket.io/ {
} }
location __PATH__/stylesheets/ { location __PATH__/stylesheets/ {
alias __FINALPATH__/live/services/web/public/stylesheets/;
# Set max upload size
client_max_body_size 50m;
alias __INSTALL_DIR__/live/services/web/public/stylesheets/;
expires 1y; expires 1y;
} }
location __PATH__/minjs/ { location __PATH__/minjs/ {
alias __FINALPATH__/live/services/web/public/minjs/; alias __INSTALL_DIR__/live/services/web/public/minjs/;
expires 1y; expires 1y;
} }
location __PATH__/img/ { location __PATH__/img/ {
alias __FINALPATH__/live/services/web/public/img/; alias __INSTALL_DIR__/live/services/web/public/img/;
expires 1y; expires 1y;
} }

View file

@ -6,9 +6,9 @@ After=network.target
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__FINALPATH__/variables.env EnvironmentFile=__INSTALL_DIR__/variables.env
ExecStart=__YNH_NODE__ __FINALPATH__/live/services/chat/app.js ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/chat/app.js
StandardOutput=append:/var/log/__APP__/chat.log StandardOutput=append:/var/log/__APP__/chat.log
StandardError=inherit StandardError=inherit
Restart=on-failure Restart=on-failure

View file

@ -6,9 +6,9 @@ After=network.target
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__FINALPATH__/variables.env EnvironmentFile=__INSTALL_DIR__/variables.env
ExecStart=__YNH_NODE__ __FINALPATH__/live/services/clsi/app.js ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/clsi/app.js
StandardOutput=append:/var/log/__APP__/clsi.log StandardOutput=append:/var/log/__APP__/clsi.log
StandardError=inherit StandardError=inherit
Restart=on-failure Restart=on-failure

View file

@ -6,9 +6,9 @@ After=network.target
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__FINALPATH__/variables.env EnvironmentFile=__INSTALL_DIR__/variables.env
ExecStart=__YNH_NODE__ __FINALPATH__/live/services/contacts/app.js ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/contacts/app.js
StandardOutput=append:/var/log/__APP__/contacts.log StandardOutput=append:/var/log/__APP__/contacts.log
StandardError=inherit StandardError=inherit
Restart=on-failure Restart=on-failure

View file

@ -6,9 +6,9 @@ After=network.target
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__FINALPATH__/variables.env EnvironmentFile=__INSTALL_DIR__/variables.env
ExecStart=__YNH_NODE__ __FINALPATH__/live/services/docstore/app.js ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/docstore/app.js
StandardOutput=append:/var/log/__APP__/docstore.log StandardOutput=append:/var/log/__APP__/docstore.log
StandardError=inherit StandardError=inherit
Restart=on-failure Restart=on-failure

View file

@ -6,9 +6,9 @@ After=network.target
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__FINALPATH__/variables.env EnvironmentFile=__INSTALL_DIR__/variables.env
ExecStart=__YNH_NODE__ __FINALPATH__/live/services/document-updater/app.js ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/document-updater/app.js
StandardOutput=append:/var/log/__APP__/document-updater.log StandardOutput=append:/var/log/__APP__/document-updater.log
StandardError=inherit StandardError=inherit
Restart=on-failure Restart=on-failure

View file

@ -6,9 +6,9 @@ After=network.target
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__FINALPATH__/variables.env EnvironmentFile=__INSTALL_DIR__/variables.env
ExecStart=__YNH_NODE__ __FINALPATH__/live/services/filestore/app.js ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/filestore/app.js
StandardOutput=append:/var/log/__APP__/filestore.log StandardOutput=append:/var/log/__APP__/filestore.log
StandardError=inherit StandardError=inherit
Restart=on-failure Restart=on-failure

View file

@ -0,0 +1,20 @@
[Unit]
Description=__APP__ history-v1
After=network.target
[Service]
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__INSTALL_DIR__/variables.env
Environment="MONGO_CONNECTION_STRING=mongodb://127.0.0.1:27017/__DB_NAME__"
Environment="NODE_CONFIG_DIR=__INSTALL_DIR__/live/services/history-v1/config"
ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/history-v1/app.js
StandardOutput=append:/var/log/__APP__/history-v1.log
StandardError=inherit
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target

View file

@ -6,9 +6,9 @@ After=network.target
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__FINALPATH__/variables.env EnvironmentFile=__INSTALL_DIR__/variables.env
ExecStart=__YNH_NODE__ __FINALPATH__/live/services/notifications/app.js ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/notifications/app.js
StandardOutput=append:/var/log/__APP__/notifications.log StandardOutput=append:/var/log/__APP__/notifications.log
StandardError=inherit StandardError=inherit
Restart=on-failure Restart=on-failure

View file

@ -0,0 +1,18 @@
[Unit]
Description=__APP__ project-history
After=network.target
[Service]
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__INSTALL_DIR__/variables.env
ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/project-history/app.js
StandardOutput=append:/var/log/__APP__/project-history.log
StandardError=inherit
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target

View file

@ -6,9 +6,9 @@ After=network.target
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__FINALPATH__/variables.env EnvironmentFile=__INSTALL_DIR__/variables.env
ExecStart=__YNH_NODE__ __FINALPATH__/live/services/real-time/app.js ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/real-time/app.js
StandardOutput=append:/var/log/__APP__/real-time.log StandardOutput=append:/var/log/__APP__/real-time.log
StandardError=inherit StandardError=inherit
Restart=on-failure Restart=on-failure

View file

@ -6,9 +6,9 @@ After=network.target
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__FINALPATH__/variables.env EnvironmentFile=__INSTALL_DIR__/variables.env
ExecStart=__YNH_NODE__ __FINALPATH__/live/services/spelling/app.js ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/spelling/app.js
StandardOutput=append:/var/log/__APP__/spelling.log StandardOutput=append:/var/log/__APP__/spelling.log
StandardError=inherit StandardError=inherit
Restart=on-failure Restart=on-failure

View file

@ -1,18 +0,0 @@
[Unit]
Description=__APP__ track-changes
After=network.target
[Service]
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/
EnvironmentFile=__FINALPATH__/variables.env
ExecStart=__YNH_NODE__ __FINALPATH__/live/services/track-changes/app.js
StandardOutput=append:/var/log/__APP__/track-changes.log
StandardError=inherit
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target

View file

@ -6,9 +6,9 @@ After=network.target
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__FINALPATH__/variables.env EnvironmentFile=__INSTALL_DIR__/variables.env
ExecStart=__YNH_NODE__ __FINALPATH__/live/services/web/app.js ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/web/app.js
StandardOutput=append:/var/log/__APP__/web.log StandardOutput=append:/var/log/__APP__/web.log
StandardError=inherit StandardError=inherit
Restart=on-failure Restart=on-failure

24
conf/production.json Normal file
View file

@ -0,0 +1,24 @@
{
"persistor": {
"backend": "fs",
"useSubdirectories": true
},
"basicHttpAuth": {
"password": "password"
},
"useDeleteObjects": "false",
"jwtAuth": {
"algorithm": "HS256"
},
"mongo": {},
"blobStore": {
"globalBucket": "__DATA_DIR__/history/overleaf-global-blobs",
"projectBucket": "__DATA_DIR__/history/overleaf-project-blobs"
},
"chunkStore": {
"bucket": "__DATA_DIR__/history/overleaf-chunks"
},
"zipStore": {
"bucket": "__DATA_DIR__/history/overleaf-zips"
}
}

View file

@ -42,8 +42,8 @@ const parseIntOrFail = function (value) {
return parsedValue return parsedValue
} }
const DATA_DIR = '__DATADIR__' const DATA_DIR = '__DATA_DIR__'
const TMP_DIR = '__FINALPATH__/tmp' const TMP_DIR = '__INSTALL_DIR__/tmp'
const settings = { const settings = {
clsi: { clsi: {
@ -120,20 +120,6 @@ const settings = {
blockingKey({ doc_id }) { blockingKey({ doc_id }) {
return `Blocking:${doc_id}` return `Blocking:${doc_id}`
}, },
// track-changes:lock
historyLock({ doc_id }) {
return `HistoryLock:${doc_id}`
},
historyIndexLock({ project_id }) {
return `HistoryIndexLock:${project_id}`
},
// track-changes:history
uncompressedHistoryOps({ doc_id }) {
return `UncompressedHistoryOps:${doc_id}`
},
docsWithHistoryOps({ project_id }) {
return `DocsWithHistoryOps:${project_id}`
},
// realtime // realtime
clientsInProject({ project_id }) { clientsInProject({ project_id }) {
return `clients_in_project:${project_id}` return `clients_in_project:${project_id}`
@ -144,7 +130,7 @@ const settings = {
}, },
}), }),
fairy: redisConfig, fairy: redisConfig,
// track-changes and document-updater // document-updater
realtime: redisConfig, realtime: redisConfig,
documentupdater: redisConfig, documentupdater: redisConfig,
lock: redisConfig, lock: redisConfig,
@ -153,35 +139,20 @@ const settings = {
api: redisConfig, api: redisConfig,
pubsub: redisConfig, pubsub: redisConfig,
project_history: redisConfig, project_history: redisConfig,
},
// File storage project_history_migration: {
// ------------ host: redisConfig.host,
port: redisConfig.port,
// ShareLaTeX can store binary files like images either locally or in Amazon password: redisConfig.password,
// S3. The default is locally: maxRetriesPerRequest: parseInt(
filestore: { process.env.REDIS_MAX_RETRIES_PER_REQUEST || '20'
backend: 'fs', ),
stores: { key_schema: {
user_files: Path.join(DATA_DIR, 'user_files'), projectHistoryOps({ projectId }) {
template_files: Path.join(DATA_DIR, 'template_files'), return `ProjectHistory:Ops:{${projectId}}` // NOTE: the extra braces are intentional
},
}, },
}, },
// To use Amazon S3 as a storage backend, comment out the above config, and
// uncomment the following, filling in your key, secret, and bucket name:
//
// filestore:
// backend: "s3"
// stores:
// user_files: "BUCKET_NAME"
// s3:
// key: "AWS_KEY"
// secret: "AWS_SECRET"
//
trackchanges: {
continueOnError: true,
}, },
// Local disk caching // Local disk caching
@ -193,6 +164,8 @@ const settings = {
dumpFolder: Path.join(TMP_DIR, 'dumpFolder'), dumpFolder: Path.join(TMP_DIR, 'dumpFolder'),
// Where to write uploads before they are processed // Where to write uploads before they are processed
uploadFolder: Path.join(TMP_DIR, 'uploads'), uploadFolder: Path.join(TMP_DIR, 'uploads'),
// Where to write intermediate file for full project history migration
projectHistories: Path.join(TMP_DIR, 'projectHistories'),
// Where to write the project to disk before running LaTeX on it // Where to write the project to disk before running LaTeX on it
compilesDir: Path.join(DATA_DIR, 'compiles'), compilesDir: Path.join(DATA_DIR, 'compiles'),
// Where to cache downloaded URLs for the CLSI // Where to cache downloaded URLs for the CLSI
@ -208,6 +181,9 @@ const settings = {
// when emails are sent out and in generated links: // when emails are sent out and in generated links:
siteUrl: (siteUrl = process.env.SHARELATEX_SITE_URL || 'http://localhost'), siteUrl: (siteUrl = process.env.SHARELATEX_SITE_URL || 'http://localhost'),
// Status page URL as displayed on the maintenance/500 pages.
statusPageUrl: process.env.SHARELATEX_STATUS_PAGE_URL,
// The name this is used to describe your ShareLaTeX Installation // The name this is used to describe your ShareLaTeX Installation
appName: process.env.SHARELATEX_APP_NAME || 'ShareLaTeX (Community Edition)', appName: process.env.SHARELATEX_APP_NAME || 'ShareLaTeX (Community Edition)',
@ -253,6 +229,18 @@ const settings = {
// address and http/https protocol information. // address and http/https protocol information.
behindProxy: process.env.SHARELATEX_BEHIND_PROXY || false, behindProxy: process.env.SHARELATEX_BEHIND_PROXY || false,
trustedProxyIps: process.env.SHARELATEX_TRUSTED_PROXY_IPS,
// The amount of time, in milliseconds, until the (rolling) cookie session expires
cookieSessionLength: parseInt(
process.env.SHARELATEX_COOKIE_SESSION_LENGTH || 5 * 24 * 60 * 60 * 1000, // default 5 days
10
),
redisLockTTLSeconds: parseInt(
process.env.SHARELATEX_REDIS_LOCK_TTL_SECONDS || '60',
10
),
i18n: { i18n: {
subdomainLang: { subdomainLang: {
@ -273,7 +261,17 @@ const settings = {
pass: httpAuthPass, pass: httpAuthPass,
}, },
project_history: { project_history: {
enabled: false, sendProjectStructureOps: true,
url: 'http://localhost:3054',
},
v1_history: {
url: process.env.V1_HISTORY_URL || 'http://localhost:3100/api',
user: 'staging',
pass: process.env.STAGING_PASSWORD,
requestTimeout: parseInt(
process.env.SHARELATEX_HISTORY_V1_HTTP_REQUEST_TIMEOUT || '300000', // default is 5min
10
),
}, },
}, },
references: {}, references: {},
@ -416,7 +414,7 @@ if (
pattern: process.env.SHARELATEX_PASSWORD_VALIDATION_PATTERN || 'aA$3', pattern: process.env.SHARELATEX_PASSWORD_VALIDATION_PATTERN || 'aA$3',
length: { length: {
min: process.env.SHARELATEX_PASSWORD_VALIDATION_MIN_LENGTH || 8, min: process.env.SHARELATEX_PASSWORD_VALIDATION_MIN_LENGTH || 8,
max: process.env.SHARELATEX_PASSWORD_VALIDATION_MAX_LENGTH || 150, max: process.env.SHARELATEX_PASSWORD_VALIDATION_MAX_LENGTH || 72,
}, },
} }
} }
@ -430,244 +428,6 @@ if (parse(process.env.SHARELATEX_IS_SERVER_PRO) === true) {
settings.apis.references = { url: 'http://localhost:3040' } settings.apis.references = { url: 'http://localhost:3040' }
} }
// LDAP - SERVER PRO ONLY
// ----------
if (process.env.SHARELATEX_LDAP_HOST) {
console.error(`\
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# WARNING: The LDAP configuration format has changed in version 0.5.1
# See https://github.com/sharelatex/sharelatex/wiki/Server-Pro:-LDAP-Config
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #\
`)
}
if (process.env.SHARELATEX_LDAP_URL) {
let _ldap_connect_timeout,
_ldap_group_search_attribs,
_ldap_search_attribs,
_ldap_timeout
settings.externalAuth = true
settings.ldap = {
emailAtt: process.env.SHARELATEX_LDAP_EMAIL_ATT,
nameAtt: process.env.SHARELATEX_LDAP_NAME_ATT,
lastNameAtt: process.env.SHARELATEX_LDAP_LAST_NAME_ATT,
updateUserDetailsOnLogin:
process.env.SHARELATEX_LDAP_UPDATE_USER_DETAILS_ON_LOGIN === 'true',
placeholder: process.env.SHARELATEX_LDAP_PLACEHOLDER,
server: {
url: process.env.SHARELATEX_LDAP_URL,
bindDn: process.env.SHARELATEX_LDAP_BIND_DN,
bindCredentials: process.env.SHARELATEX_LDAP_BIND_CREDENTIALS,
bindProperty: process.env.SHARELATEX_LDAP_BIND_PROPERTY,
searchBase: process.env.SHARELATEX_LDAP_SEARCH_BASE,
searchScope: process.env.SHARELATEX_LDAP_SEARCH_SCOPE,
searchFilter: process.env.SHARELATEX_LDAP_SEARCH_FILTER,
searchAttributes: (_ldap_search_attribs =
process.env.SHARELATEX_LDAP_SEARCH_ATTRIBUTES)
? (() => {
try {
return JSON.parse(_ldap_search_attribs)
} catch (error3) {
e = error3
return console.error(
'could not parse SHARELATEX_LDAP_SEARCH_ATTRIBUTES'
)
}
})()
: undefined,
groupDnProperty: process.env.SHARELATEX_LDAP_GROUP_DN_PROPERTY,
groupSearchBase: process.env.SHARELATEX_LDAP_GROUP_SEARCH_BASE,
groupSearchScope: process.env.SHARELATEX_LDAP_GROUP_SEARCH_SCOPE,
groupSearchFilter: process.env.SHARELATEX_LDAP_GROUP_SEARCH_FILTER,
groupSearchAttributes: (_ldap_group_search_attribs =
process.env.SHARELATEX_LDAP_GROUP_SEARCH_ATTRIBUTES)
? (() => {
try {
return JSON.parse(_ldap_group_search_attribs)
} catch (error4) {
e = error4
return console.error(
'could not parse SHARELATEX_LDAP_GROUP_SEARCH_ATTRIBUTES'
)
}
})()
: undefined,
cache: process.env.SHARELATEX_LDAP_CACHE === 'true',
timeout: (_ldap_timeout = process.env.SHARELATEX_LDAP_TIMEOUT)
? (() => {
try {
return parseIntOrFail(_ldap_timeout)
} catch (error5) {
e = error5
return console.error('Cannot parse SHARELATEX_LDAP_TIMEOUT')
}
})()
: undefined,
connectTimeout: (_ldap_connect_timeout =
process.env.SHARELATEX_LDAP_CONNECT_TIMEOUT)
? (() => {
try {
return parseIntOrFail(_ldap_connect_timeout)
} catch (error6) {
e = error6
return console.error(
'Cannot parse SHARELATEX_LDAP_CONNECT_TIMEOUT'
)
}
})()
: undefined,
},
}
if (process.env.SHARELATEX_LDAP_TLS_OPTS_CA_PATH) {
let ca, ca_paths
try {
ca = JSON.parse(process.env.SHARELATEX_LDAP_TLS_OPTS_CA_PATH)
} catch (error7) {
e = error7
console.error(
'could not parse SHARELATEX_LDAP_TLS_OPTS_CA_PATH, invalid JSON'
)
}
if (typeof ca === 'string') {
ca_paths = [ca]
} else if (
typeof ca === 'object' &&
(ca != null ? ca.length : undefined) != null
) {
ca_paths = ca
} else {
console.error('problem parsing SHARELATEX_LDAP_TLS_OPTS_CA_PATH')
}
settings.ldap.server.tlsOptions = {
rejectUnauthorized:
process.env.SHARELATEX_LDAP_TLS_OPTS_REJECT_UNAUTH === 'true',
ca: ca_paths, // e.g.'/etc/ldap/ca_certs.pem'
}
}
}
if (process.env.SHARELATEX_SAML_ENTRYPOINT) {
// NOTE: see https://github.com/node-saml/passport-saml/blob/master/README.md for docs of `server` options
let _saml_additionalAuthorizeParams,
_saml_additionalLogoutParams,
_saml_additionalParams,
_saml_expiration,
_saml_skew
settings.externalAuth = true
settings.saml = {
updateUserDetailsOnLogin:
process.env.SHARELATEX_SAML_UPDATE_USER_DETAILS_ON_LOGIN === 'true',
identityServiceName: process.env.SHARELATEX_SAML_IDENTITY_SERVICE_NAME,
emailField:
process.env.SHARELATEX_SAML_EMAIL_FIELD ||
process.env.SHARELATEX_SAML_EMAIL_FIELD_NAME,
firstNameField: process.env.SHARELATEX_SAML_FIRST_NAME_FIELD,
lastNameField: process.env.SHARELATEX_SAML_LAST_NAME_FIELD,
server: {
// strings
entryPoint: process.env.SHARELATEX_SAML_ENTRYPOINT,
callbackUrl: process.env.SHARELATEX_SAML_CALLBACK_URL,
issuer: process.env.SHARELATEX_SAML_ISSUER,
decryptionPvk: process.env.SHARELATEX_SAML_DECRYPTION_PVK,
decryptionCert: process.env.SHARELATEX_SAML_DECRYPTION_CERT,
signingCert: process.env.SHARELATEX_SAML_SIGNING_CERT,
signatureAlgorithm: process.env.SHARELATEX_SAML_SIGNATURE_ALGORITHM,
identifierFormat: process.env.SHARELATEX_SAML_IDENTIFIER_FORMAT,
attributeConsumingServiceIndex:
process.env.SHARELATEX_SAML_ATTRIBUTE_CONSUMING_SERVICE_INDEX,
authnContext: process.env.SHARELATEX_SAML_AUTHN_CONTEXT,
authnRequestBinding: process.env.SHARELATEX_SAML_AUTHN_REQUEST_BINDING,
validateInResponseTo: process.env.SHARELATEX_SAML_VALIDATE_IN_RESPONSE_TO,
cacheProvider: process.env.SHARELATEX_SAML_CACHE_PROVIDER,
logoutUrl: process.env.SHARELATEX_SAML_LOGOUT_URL,
logoutCallbackUrl: process.env.SHARELATEX_SAML_LOGOUT_CALLBACK_URL,
disableRequestedAuthnContext:
process.env.SHARELATEX_SAML_DISABLE_REQUESTED_AUTHN_CONTEXT === 'true',
forceAuthn: process.env.SHARELATEX_SAML_FORCE_AUTHN === 'true',
skipRequestCompression:
process.env.SHARELATEX_SAML_SKIP_REQUEST_COMPRESSION === 'true',
acceptedClockSkewMs: (_saml_skew =
process.env.SHARELATEX_SAML_ACCEPTED_CLOCK_SKEW_MS)
? (() => {
try {
return parseIntOrFail(_saml_skew)
} catch (error8) {
e = error8
return console.error(
'Cannot parse SHARELATEX_SAML_ACCEPTED_CLOCK_SKEW_MS'
)
}
})()
: undefined,
requestIdExpirationPeriodMs: (_saml_expiration =
process.env.SHARELATEX_SAML_REQUEST_ID_EXPIRATION_PERIOD_MS)
? (() => {
try {
return parseIntOrFail(_saml_expiration)
} catch (error9) {
e = error9
return console.error(
'Cannot parse SHARELATEX_SAML_REQUEST_ID_EXPIRATION_PERIOD_MS'
)
}
})()
: undefined,
additionalParams: (_saml_additionalParams =
process.env.SHARELATEX_SAML_ADDITIONAL_PARAMS)
? (() => {
try {
return JSON.parse(_saml_additionalParams)
} catch (error10) {
e = error10
return console.error(
'Cannot parse SHARELATEX_SAML_ADDITIONAL_PARAMS'
)
}
})()
: undefined,
additionalAuthorizeParams: (_saml_additionalAuthorizeParams =
process.env.SHARELATEX_SAML_ADDITIONAL_AUTHORIZE_PARAMS)
? (() => {
try {
return JSON.parse(_saml_additionalAuthorizeParams)
} catch (error11) {
e = error11
return console.error(
'Cannot parse SHARELATEX_SAML_ADDITIONAL_AUTHORIZE_PARAMS'
)
}
})()
: undefined,
additionalLogoutParams: (_saml_additionalLogoutParams =
process.env.SHARELATEX_SAML_ADDITIONAL_LOGOUT_PARAMS)
? (() => {
try {
return JSON.parse(_saml_additionalLogoutParams)
} catch (error12) {
e = error12
return console.error(
'Cannot parse SHARELATEX_SAML_ADDITIONAL_LOGOUT_PARAMS'
)
}
})()
: undefined,
},
}
// SHARELATEX_SAML_CERT cannot be empty
// https://github.com/node-saml/passport-saml/commit/f6b1c885c0717f1083c664345556b535f217c102
if (process.env.SHARELATEX_SAML_CERT) {
settings.saml.server.cert = process.env.SHARELATEX_SAML_CERT
settings.saml.server.privateKey = process.env.SHARELATEX_SAML_PRIVATE_CERT
}
}
// Compiler // Compiler
// -------- // --------
if (process.env.SANDBOXED_COMPILES === 'true') { if (process.env.SANDBOXED_COMPILES === 'true') {
@ -720,10 +480,12 @@ if (process.env.SHARELATEX_TEMPLATES_USER_ID) {
if (process.env.SHARELATEX_PROXY_LEARN != null) { if (process.env.SHARELATEX_PROXY_LEARN != null) {
settings.proxyLearn = parse(process.env.SHARELATEX_PROXY_LEARN) settings.proxyLearn = parse(process.env.SHARELATEX_PROXY_LEARN)
if (settings.proxyLearn) { if (settings.proxyLearn) {
settings.nav.header_extras = [{ settings.nav.header_extras = [
{
url: '/learn', url: '/learn',
text: 'documentation', text: 'documentation',
}].concat(settings.nav.header_extras || []) },
].concat(settings.nav.header_extras || [])
} }
} }
@ -735,6 +497,41 @@ if (process.env.SHARELATEX_ELASTICSEARCH_URL != null) {
} }
} }
// filestore
switch (process.env.SHARELATEX_FILESTORE_BACKEND) {
case 's3':
settings.filestore = {
backend: 's3',
stores: {
user_files: process.env.SHARELATEX_FILESTORE_USER_FILES_BUCKET_NAME,
template_files:
process.env.SHARELATEX_FILESTORE_TEMPLATE_FILES_BUCKET_NAME,
},
s3: {
key:
process.env.SHARELATEX_FILESTORE_S3_ACCESS_KEY_ID ||
process.env.AWS_ACCESS_KEY_ID,
secret:
process.env.SHARELATEX_FILESTORE_S3_SECRET_ACCESS_KEY ||
process.env.AWS_SECRET_ACCESS_KEY,
endpoint: process.env.SHARELATEX_FILESTORE_S3_ENDPOINT,
pathStyle: process.env.SHARELATEX_FILESTORE_S3_PATH_STYLE === 'true',
region:
process.env.SHARELATEX_FILESTORE_S3_REGION ||
process.env.AWS_DEFAULT_REGION,
},
}
break
default:
settings.filestore = {
backend: 'fs',
stores: {
user_files: Path.join(DATA_DIR, 'user_files'),
template_files: Path.join(DATA_DIR, 'template_files'),
},
}
}
// With lots of incoming and outgoing HTTP connections to different services, // With lots of incoming and outgoing HTTP connections to different services,
// sometimes long running, it is a good idea to increase the default number // sometimes long running, it is a good idea to increase the default number
// of sockets that Node will hold open. // of sockets that Node will hold open.

View file

@ -1,6 +1,7 @@
SHARELATEX_APP_NAME="YunoHost Overleaf Community Edition" SHARELATEX_APP_NAME="YunoHost Overleaf Community Edition"
SHARELATEX_PORT=__PORT__
SHARELATEX_CONFIG="__FINALPATH__/settings.js" SHARELATEX_CONFIG="__INSTALL_DIR__/settings.js"
ADMIN_PRIVILEGE_AVAILABLE=true ADMIN_PRIVILEGE_AVAILABLE=true
OPTIMISE_PDF=true OPTIMISE_PDF=true
NODE_ENV=production NODE_ENV=production
@ -10,7 +11,7 @@ WEB_API_USER="__APP__"
WEB_API_PASSWORD=__WEB_API_PASSWORD__ WEB_API_PASSWORD=__WEB_API_PASSWORD__
CRYPTO_RANDOM=__CRYPTO_RANDOM__ CRYPTO_RANDOM=__CRYPTO_RANDOM__
SHARELATEX_MONGO_URL="mongodb://localhost/__APP__" SHARELATEX_MONGO_URL="mongodb://127.0.0.1:27017/__DB_NAME__"
SHARELATEX_REDIS_HOST="localhost" SHARELATEX_REDIS_HOST="localhost"
@ -19,9 +20,11 @@ REDIS_PORT=6379
SHARELATEX_SITE_LANGUAGE="__LANGUAGE__" SHARELATEX_SITE_LANGUAGE="__LANGUAGE__"
ENABLED_LINKED_FILE_TYPES=project_file,project_output_file ENABLED_LINKED_FILE_TYPES=project_file,project_output_file
SHARELATEX_ALLOW_PUBLIC_ACCESS=true
SHARELATEX_ALLOW_ANONYMOUS_READ_AND_WRITE_SHARING=true
# Enables Thumbnail generation using ImageMagick # Enables Thumbnail generation using ImageMagick
ENABLE_CONVERSIONS=true ENABLE_CONVERSIONS=true
@ -30,7 +33,7 @@ EMAIL_CONFIRMATION_DISABLED=true
# temporary fix for LuaLaTex compiles # temporary fix for LuaLaTex compiles
# see https://github.com/overleaf/overleaf/issues/695 # see https://github.com/overleaf/overleaf/issues/695
TEXMFVAR=__FINALPATH__/tmp/texmf-var TEXMFVAR=__INSTALL_DIR__/tmp/texmf-var
## Nginx ## Nginx
# NGINX_WORKER_PROCESSES=4 # NGINX_WORKER_PROCESSES=4
@ -43,39 +46,41 @@ SHARELATEX_SECURE_COOKIE=false
SHARELATEX_SITE_URL=https://__DOMAIN__ SHARELATEX_SITE_URL=https://__DOMAIN__
# SHARELATEX_NAV_TITLE=Our Overleaf Instance # SHARELATEX_NAV_TITLE=Our Overleaf Instance
# SHARELATEX_HEADER_IMAGE_URL=http://somewhere.com/mylogo.png # SHARELATEX_HEADER_IMAGE_URL=http://somewhere.com/mylogo.png
SHARELATEX_ADMIN_EMAIL=admin@__DOMAIN__ SHARELATEX_ADMIN_EMAIL=__APP__@__DOMAIN__
# SHARELATEX_LEFT_FOOTER=[{"text":"Powered by Overleaf © 2021", "url": "https://www.overleaf.com"}, {"text": "Contact your support team", "url": "mailto:support@example.com"} ] # SHARELATEX_LEFT_FOOTER=[{"text":"Powered by Overleaf © 2021", "url": "https://www.overleaf.com"}, {"text": "Contact your support team", "url": "mailto:support@example.com"} ]
# SHARELATEX_RIGHT_FOOTER=[{"text":"Hello I am on the Right"}] # SHARELATEX_RIGHT_FOOTER=[{"text":"Hello I am on the Right"}]
# SHARELATEX_EMAIL_FROM_ADDRESS=team@example.com SHARELATEX_EMAIL_FROM_ADDRESS=__APP__@__DOMAIN__
# SHARELATEX_EMAIL_AWS_SES_ACCESS_KEY_ID= # SHARELATEX_EMAIL_AWS_SES_ACCESS_KEY_ID=
# SHARELATEX_EMAIL_AWS_SES_SECRET_KEY= # SHARELATEX_EMAIL_AWS_SES_SECRET_KEY=
SHARELATEX_EMAIL_SMTP_HOST=localhost SHARELATEX_EMAIL_SMTP_HOST=__MAIN_DOMAIN__
SHARELATEX_EMAIL_SMTP_PORT=25 SHARELATEX_EMAIL_SMTP_PORT=587
SHARELATEX_EMAIL_SMTP_SECURE=false # SHARELATEX_EMAIL_SMTP_SECURE=true
# SHARELATEX_EMAIL_SMTP_USER= SHARELATEX_EMAIL_SMTP_USER=__APP__
# SHARELATEX_EMAIL_SMTP_PASS= SHARELATEX_EMAIL_SMTP_PASS=__MAIL_PWD__
# SHARELATEX_EMAIL_SMTP_NAME= SHARELATEX_EMAIL_SMTP_NAME=__APP__@__DOMAIN__
# SHARELATEX_EMAIL_SMTP_LOGGER=false # SHARELATEX_EMAIL_SMTP_LOGGER=false
# SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH=true # SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH=true
# SHARELATEX_EMAIL_SMTP_IGNORE_TLS=false # SHARELATEX_EMAIL_SMTP_IGNORE_TLS=false
# SHARELATEX_CUSTOM_EMAIL_FOOTER=This system is run by department x # SHARELATEX_CUSTOM_EMAIL_FOOTER=This system is run by department x
OT_JWT_AUTH_KEY=__JWT_KEY__
################ ################
## Server Pro ## ## Server Pro ##
################ ################
LDAP_SERVER=ldap://localhost:389 #LDAP_SERVER=ldap://localhost:389
LDAP_BASE=ou=users,dc=yunohost,dc=org #LDAP_BASE=ou=users,dc=yunohost,dc=org
LDAP_BINDDN=uid=%u,ou=users,dc=yunohost,dc=org #LDAP_BINDDN=uid=%u,ou=users,dc=yunohost,dc=org
LDAP_USER_FILTER='(&(permission=cn=__APP__.main,ou=permission,dc=yunohost,dc=org)(uid=%u))' #LDAP_USER_FILTER='(&(permission=cn=__APP__.main,ou=permission,dc=yunohost,dc=org)(uid=%u))'
LDAP_ADMIN_GROUP_FILTER='(&(permission=cn=__APP__.admin,ou=permission,dc=yunohost,dc=org)(uid=%u))' #LDAP_ADMIN_GROUP_FILTER='(&(permission=cn=__APP__.admin,ou=permission,dc=yunohost,dc=org)(uid=%u))'
ALLOW_EMAIL_LOGIN=true #ALLOW_EMAIL_LOGIN=true
LDAP_CONTACT_FILTER='(permission=cn=__APP__.main,ou=permission,dc=yunohost,dc=org)' #LDAP_CONTACT_FILTER='(permission=cn=__APP__.main,ou=permission,dc=yunohost,dc=org)'
LDAP_CONTACTS=false #LDAP_CONTACTS=false
# EXTERNAL_AUTH=ldap # EXTERNAL_AUTH=ldap
# SHARELATEX_LDAP_URL=ldap://localhost:389 # SHARELATEX_LDAP_URL=ldap://localhost:389

1
doc/ADMIN.md Normal file
View file

@ -0,0 +1 @@
To create the initial administrator account: `https:/__DOMAIN__/launchpad`

1
doc/ADMIN_fr.md Normal file
View file

@ -0,0 +1 @@
Pour créer le compte administrateur initial : `https://__DOMAIN__/launchpad`

View file

@ -1 +0,0 @@
To create the initial administrator account: `https://yourdomain.com/launchpad`

View file

@ -1 +0,0 @@
Pour créer le compte administrateur initial : `https://yourdomain.com/launchpad`

Binary file not shown.

Before

Width:  |  Height:  |  Size: 739 KiB

After

Width:  |  Height:  |  Size: 335 KiB

View file

@ -1,55 +0,0 @@
{
"name": "Overleaf",
"id": "overleaf",
"packaging_format": 1,
"description": {
"en": "Open-source online real-time collaborative LaTeX editor."
},
"version": "2022.04.23~ynh1",
"url": "https://www.overleaf.com",
"upstream": {
"license": "AGPL-3.0-or-later",
"website": "https://www.overleaf.com",
"userdoc": "https://www.overleaf.com/learn",
"code": "https://github.com/overleaf/overleaf"
},
"license": "AGPL-3.0-or-later",
"maintainer": {
"name": "",
"email": ""
},
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": false,
"services": [
"nginx"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "is_public",
"type": "boolean",
"default": true
},
{
"name": "language",
"type": "string",
"ask": {
"en": "Choose the application language",
"fr": "Choisissez la langue de l'application"
},
"choices": ["fr", "en"],
"default": "fr"
},
{
"name": "admin",
"type": "user"
}
]
}
}

96
manifest.toml Normal file
View file

@ -0,0 +1,96 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "overleaf"
name = "Overleaf"
description.en = "Online real-time collaborative LaTeX editor"
description.fr = "Éditeur LaTeX collaboratif en ligne et en temps réel"
version = "2024.01.26~ynh1"
maintainers = []
[upstream]
license = "AGPL-3.0-or-later"
website = "https://www.overleaf.com"
userdoc = "https://www.overleaf.com/learn"
code = "https://github.com/overleaf/overleaf"
[integration]
yunohost = ">= 11.2.0"
architectures = "all"
multi_instance = false
ldap = false
sso = false
disk = "50M"
ram.build = "3G"
ram.runtime = "3G"
[install]
[install.domain]
type = "domain"
[install.init_main_permission]
type = "group"
default = "visitors"
[install.language]
ask.en = "Choose the application language"
ask.fr = "Choisissez la langue de l'application"
type = "select"
choices = ["fr", "en"]
default = "fr"
[install.admin]
type = "user"
[resources]
[resources.sources]
[resources.sources.main]
url = "https://github.com/overleaf/overleaf/archive/fdf8ebe001ec91dc3ab5c23b47bbbb03dc03d1bb.tar.gz"
sha256 = "802e3c0add7690c211fc039f94e1fceffe83040e7e60b0c340f35703087f1704"
autoupdate.strategy = "latest_github_commit"
[resources.system_user]
allow_email = true
[resources.install_dir]
[resources.data_dir]
subdirs = [ "compiles", "output", "cache", "user_files", "template_files", "history" ]
[resources.permissions]
main.url = "/"
main.auth_header = false
admin.url = "/launchpad"
admin.allowed = "admins"
admin.show_tile = false
[resources.ports]
main.default = 8095
[resources.apt]
packages = [
# Overleaf dependencies
"texlive", "texlive-xetex", "texlive-base", "texlive-font-utils", "redis-server", "latexmk", "python3-pygments",
# Aspell dependencies
"aspell-ar", "aspell-ar-large",
"aspell-bg", "aspell-br", "aspell-ca", "aspell-cs", "aspell-cy", "aspell-da", "aspell-de", "aspell-de-1901",
"aspell-el", "aspell-en", "aspell-eo", "aspell-es", "aspell-et", "aspell-eu-es", "aspell-fa",
"aspell-fo", "aspell-fr", "aspell-ga", "aspell-gl-minimos", "aspell-hr", "aspell-hsb",
"aspell-it", "aspell-kk", "aspell-ku", "aspell-lt", "aspell-lv", "aspell-nl", "aspell-no",
"aspell-pa", "aspell-pl", "aspell-pt-br", "aspell-pt-pt", "aspell-ro",
"aspell-ru", "aspell-sk", "aspell-sl", "aspell-sv", "aspell-tl",
# Filestore dependencies
"ghostscript", "imagemagick", "optipng", "iproute2",
# clsi dependencies
"poppler-utils",
]

View file

@ -4,10 +4,7 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
# dependencies used by the app nodejs_version=18.18.2
pkg_dependencies="texlive redis-server latexmk python3-pygments"
nodejs_version=14
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
@ -17,6 +14,365 @@ nodejs_version=14
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================
readonly YNH_DEFAULT_MONGO_VERSION=4.4
# Declare the actual MongoDB version to use: 4.4 ; 5.0 ; 6.0
# A packager willing to use another version of MongoDB can override the variable into its _common.sh.
YNH_MONGO_VERSION=${YNH_MONGO_VERSION:-$YNH_DEFAULT_MONGO_VERSION}
# Execute a mongo command
#
# example: ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("wekan")'
# example: ynh_mongo_exec --command="db.getMongo().getDBNames().indexOf(\"wekan\")"
#
# usage: ynh_mongo_exec [--user=user] [--password=password] [--authenticationdatabase=authenticationdatabase] [--database=database] [--host=host] [--port=port] --command="command" [--eval]
# | arg: -u, --user= - The user name to connect as
# | arg: -p, --password= - The user password
# | arg: -d, --authenticationdatabase= - The authenticationdatabase to connect to
# | arg: -d, --database= - The database to connect to
# | arg: -h, --host= - The host to connect to
# | arg: -P, --port= - The port to connect to
# | arg: -c, --command= - The command to evaluate
# | arg: -e, --eval - Evaluate instead of execute the command.
#
#
ynh_mongo_exec() {
# Declare an array to define the options of this helper.
local legacy_args=upadhPce
local -A args_array=( [u]=user= [p]=password= [a]=authenticationdatabase= [d]=database= [h]=host= [P]=port= [c]=command= [e]=eval )
local user
local password
local authenticationdatabase
local database
local host
local port
local command
local eval
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
user="${user:-}"
password="${password:-}"
authenticationdatabase="${authenticationdatabase:-}"
database="${database:-}"
host="${host:-}"
port="${port:-}"
eval=${eval:-0}
# If user is provided
if [ -n "$user" ]
then
user="--username=$user"
# If password is provided
if [ -n "$password" ]
then
password="--password=$password"
fi
# If authenticationdatabase is provided
if [ -n "$authenticationdatabase" ]
then
authenticationdatabase="--authenticationDatabase=$authenticationdatabase"
else
authenticationdatabase="--authenticationDatabase=admin"
fi
else
password=""
authenticationdatabase=""
fi
# If host is provided
if [ -n "$host" ]
then
host="--host=$host"
fi
# If port is provided
if [ -n "$port" ]
then
port="--port=$port"
fi
# If eval is not provided
if [ $eval -eq 0 ]
then
# If database is provided
if [ -n "$database" ]
then
database="use $database"
else
database=""
fi
mongosh --quiet --username $user --password $password --authenticationDatabase $authenticationdatabase --host $host --port $port <<EOF
$database
${command}
quit()
EOF
else
# If database is provided
if [ -n "$database" ]
then
database="$database"
else
database=""
fi
mongosh --quiet $database --username $user --password $password --authenticationDatabase $authenticationdatabase --host $host --port $port --eval="$command"
fi
}
# Drop a database
#
# [internal]
#
# If you intend to drop the database *and* the associated user,
# consider using ynh_mongo_remove_db instead.
#
# usage: ynh_mongo_drop_db --database=database
# | arg: -d, --database= - The database name to drop
#
#
ynh_mongo_drop_db() {
# Declare an array to define the options of this helper.
local legacy_args=d
local -A args_array=( [d]=database= )
local database
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
ynh_mongo_exec --database="$database" --command='db.runCommand({dropDatabase: 1})'
}
# Dump a database
#
# example: ynh_mongo_dump_db --database=wekan > ./dump.bson
#
# usage: ynh_mongo_dump_db --database=database
# | arg: -d, --database= - The database name to dump
# | ret: the mongodump output
#
#
ynh_mongo_dump_db() {
# Declare an array to define the options of this helper.
local legacy_args=d
local -A args_array=( [d]=database= )
local database
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
mongodump --quiet --db="$database" --archive
}
# Create a user
#
# [internal]
#
# usage: ynh_mongo_create_user --db_user=user --db_pwd=pwd --db_name=name
# | arg: -u, --db_user= - The user name to create
# | arg: -p, --db_pwd= - The password to identify user by
# | arg: -n, --db_name= - Name of the database to grant privilegies
#
#
ynh_mongo_create_user() {
# Declare an array to define the options of this helper.
local legacy_args=unp
local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= )
local db_user
local db_name
local db_pwd
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
# Create the user and set the user as admin of the db
ynh_mongo_exec --database="$db_name" --command='db.createUser( { user: "'${db_user}'", pwd: "'${db_pwd}'", roles: [ { role: "readWrite", db: "'${db_name}'" } ] } );'
# Add clustermonitoring rights
ynh_mongo_exec --database="$db_name" --command='db.grantRolesToUser("'${db_user}'",[{ role: "clusterMonitor", db: "admin" }]);'
}
# Check if a mongo database exists
#
# usage: ynh_mongo_database_exists --database=database
# | arg: -d, --database= - The database for which to check existence
# | exit: Return 1 if the database doesn't exist, 0 otherwise
#
#
ynh_mongo_database_exists() {
# Declare an array to define the options of this helper.
local legacy_args=d
local -A args_array=([d]=database=)
local database
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
if [ $(ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("'${database}'")' --eval) -lt 0 ]
then
return 1
else
return 0
fi
}
# Restore a database
#
# example: ynh_mongo_restore_db --database=wekan < ./dump.bson
#
# usage: ynh_mongo_restore_db --database=database
# | arg: -d, --database= - The database name to restore
#
#
ynh_mongo_restore_db() {
# Declare an array to define the options of this helper.
local legacy_args=d
local -A args_array=( [d]=database= )
local database
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
mongorestore --quiet --db="$database" --archive
}
# Drop a user
#
# [internal]
#
# usage: ynh_mongo_drop_user --db_user=user --db_name=name
# | arg: -u, --db_user= - The user to drop
# | arg: -n, --db_name= - Name of the database
#
#
ynh_mongo_drop_user() {
# Declare an array to define the options of this helper.
local legacy_args=un
local -A args_array=( [u]=db_user= [n]=db_name= )
local db_user
local db_name
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
ynh_mongo_exec --database="$db_name" --command='db.dropUser("'$db_user'", {w: "majority", wtimeout: 5000})'
}
# Create a database, an user and its password. Then store the password in the app's config
#
# usage: ynh_mongo_setup_db --db_user=user --db_name=name [--db_pwd=pwd]
# | arg: -u, --db_user= - Owner of the database
# | arg: -n, --db_name= - Name of the database
# | arg: -p, --db_pwd= - Password of the database. If not provided, a password will be generated
#
# After executing this helper, the password of the created database will be available in $db_pwd
# It will also be stored as "mongopwd" into the app settings.
#
#
ynh_mongo_setup_db() {
# Declare an array to define the options of this helper.
local legacy_args=unp
local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= )
local db_user
local db_name
db_pwd=""
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
local new_db_pwd=$(ynh_string_random) # Generate a random password
# If $db_pwd is not provided, use new_db_pwd instead for db_pwd
db_pwd="${db_pwd:-$new_db_pwd}"
# Create the user and grant access to the database
ynh_mongo_create_user --db_user="$db_user" --db_pwd="$db_pwd" --db_name="$db_name"
# Store the password in the app's config
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
}
# Remove a database if it exists, and the associated user
#
# usage: ynh_mongo_remove_db --db_user=user --db_name=name
# | arg: -u, --db_user= - Owner of the database
# | arg: -n, --db_name= - Name of the database
#
#
ynh_mongo_remove_db() {
# Declare an array to define the options of this helper.
local legacy_args=un
local -A args_array=( [u]=db_user= [n]=db_name= )
local db_user
local db_name
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
if ynh_mongo_database_exists --database=$db_name; then # Check if the database exists
ynh_mongo_drop_db --database=$db_name # Remove the database
else
ynh_print_warn --message="Database $db_name not found"
fi
# Remove mongo user if it exists
ynh_mongo_drop_user --db_user=$db_user --db_name=$db_name
}
# Install MongoDB and integrate MongoDB service in YunoHost
#
# usage: ynh_install_mongo [--mongo_version=mongo_version]
# | arg: -m, --mongo_version= - Version of MongoDB to install
#
#
ynh_install_mongo() {
# Declare an array to define the options of this helper.
local legacy_args=m
local -A args_array=([m]=mongo_version=)
local mongo_version
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
mongo_version="${mongo_version:-$YNH_MONGO_VERSION}"
ynh_print_info --message="Installing MongoDB Community Edition ..."
local mongo_debian_release=$(ynh_get_debian_release)
if [[ $(cat /proc/cpuinfo) != *"avx"* && "$mongo_version" != "4.4" ]]; then
ynh_print_warn --message="Installing Mongo 4.4 as $mongo_version is not compatible with your cpu (see https://docs.mongodb.com/manual/administration/production-notes/#x86_64)."
mongo_version="4.4"
fi
if [[ "$mongo_version" == "4.4" && "$mongo_debian_release" != "buster" ]]; then
ynh_print_warn --message="Switched to buster install as Mongo 4.4 is not compatible with $mongo_debian_release."
mongo_debian_release=buster
fi
ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian $mongo_debian_release/mongodb-org/$mongo_version main" --package="mongodb-org mongodb-org-server mongodb-org-tools mongodb-mongosh" --key="https://www.mongodb.org/static/pgp/server-$mongo_version.asc"
mongodb_servicename=mongod
# Make sure MongoDB is started and enabled
systemctl enable $mongodb_servicename --quiet
systemctl daemon-reload --quiet
ynh_systemd_action --service_name=$mongodb_servicename --action=restart --line_match="aiting for connections" --log_path="/var/log/mongodb/$mongodb_servicename.log"
# Integrate MongoDB service in YunoHost
yunohost service add $mongodb_servicename --description="MongoDB daemon" --log="/var/log/mongodb/$mongodb_servicename.log"
# Store mongo_version into the config of this app
ynh_app_setting_set --app=$app --key=mongo_version --value=$mongo_version
}
# Remove MongoDB
# Only remove the MongoDB service integration in YunoHost for now
# if MongoDB package as been removed
#
# usage: ynh_remove_mongo
#
#
ynh_remove_mongo() {
# Only remove the mongodb service if it is not installed.
if ! ynh_package_is_installed --package="mongodb*"
then
ynh_print_info --message="Removing MongoDB service..."
mongodb_servicename=mongod
# Remove the mongodb service
yunohost service remove $mongodb_servicename
ynh_secure_remove --file="/var/lib/mongodb"
ynh_secure_remove --file="/var/log/mongodb"
fi
}
#================================================= #=================================================
# FUTURE OFFICIAL HELPERS # FUTURE OFFICIAL HELPERS
#================================================= #=================================================

View file

@ -8,31 +8,8 @@
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source ../settings/scripts/ynh_mongo_db
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
@ -42,13 +19,13 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE DATA DIR # BACKUP THE DATA DIR
#================================================= #=================================================
ynh_backup --src_path="$datadir" --is_big ynh_backup --src_path="$data_dir" --is_big
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
@ -74,10 +51,11 @@ ynh_backup --src_path="/etc/systemd/system/$app-contacts.service"
ynh_backup --src_path="/etc/systemd/system/$app-docstore.service" ynh_backup --src_path="/etc/systemd/system/$app-docstore.service"
ynh_backup --src_path="/etc/systemd/system/$app-document-updater.service" ynh_backup --src_path="/etc/systemd/system/$app-document-updater.service"
ynh_backup --src_path="/etc/systemd/system/$app-filestore.service" ynh_backup --src_path="/etc/systemd/system/$app-filestore.service"
ynh_backup --src_path="/etc/systemd/system/$app-history-v1.service"
ynh_backup --src_path="/etc/systemd/system/$app-notifications.service" ynh_backup --src_path="/etc/systemd/system/$app-notifications.service"
ynh_backup --src_path="/etc/systemd/system/$app-project-history.service"
ynh_backup --src_path="/etc/systemd/system/$app-real-time.service" ynh_backup --src_path="/etc/systemd/system/$app-real-time.service"
ynh_backup --src_path="/etc/systemd/system/$app-spelling.service" ynh_backup --src_path="/etc/systemd/system/$app-spelling.service"
ynh_backup --src_path="/etc/systemd/system/$app-track-changes.service"
ynh_backup --src_path="/etc/systemd/system/$app-web.service" ynh_backup --src_path="/etc/systemd/system/$app-web.service"
#================================================= #=================================================

View file

@ -9,70 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path="/"
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Add settings here as needed by your application
language=$(ynh_app_setting_get --app=$app --key=language)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
port=$(ynh_app_setting_get --app=$app --key=port)
web_api_password=$(ynh_app_setting_get --app=$app --key=web_api_password)
crypto_random=$(ynh_app_setting_get --app=$app --key=crypto_random)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
@ -86,10 +22,11 @@ ynh_systemd_action --service_name="$app-contacts" --action="stop" --log_path="/v
ynh_systemd_action --service_name="$app-docstore" --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app-docstore" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-document-updater" --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app-document-updater" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-filestore" --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app-filestore" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-history-v1" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-notifications" --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app-notifications" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-project-history" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-real-time" --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app-real-time" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-spelling" --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app-spelling" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-track-changes" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-web" --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app-web" --action="stop" --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
@ -97,29 +34,7 @@ ynh_systemd_action --service_name="$app-web" --action="stop" --log_path="/var/lo
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." ynh_script_progression --message="Updating NGINX web server configuration..."
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf ynh_change_url_nginx_config
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
@ -129,15 +44,15 @@ fi
ynh_script_progression --message="Updating a configuration file..." ynh_script_progression --message="Updating a configuration file..."
domain=$new_domain domain=$new_domain
path_url=$new_path path=$new_path
ynh_add_config --template="../conf/variables.env" --destination="$final_path/variables.env" ynh_add_config --template="../conf/variables.env" --destination="$install_dir/variables.env"
chmod 400 "$final_path/variables.env" chmod 400 "$install_dir/variables.env"
chown $app:$app "$final_path/variables.env" chown $app:$app "$install_dir/variables.env"
ynh_add_config --template="../conf/settings.js" --destination="$final_path/settings.js" ynh_add_config --template="../conf/settings.js" --destination="$install_dir/settings.js"
chmod 400 "$final_path/settings.js" chmod 400 "$install_dir/settings.js"
chown $app:$app "$final_path/settings.js" chown $app:$app "$install_dir/settings.js"
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
@ -146,25 +61,18 @@ chown $app:$app "$final_path/settings.js"
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service ynh_systemd_action --service_name="$app-chat" --action="start" --log_path="/var/log/$app/chat.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-chat" --action="start" --log_path="/var/log/$app/chat.log" --line_match="listening on" ynh_systemd_action --service_name="$app-clsi" --action="start" --log_path="/var/log/$app/clsi.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-clsi" --action="start" --log_path="/var/log/$app/clsi.log" --line_match="listening on" ynh_systemd_action --service_name="$app-contacts" --action="start" --log_path="/var/log/$app/contacts.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-contacts" --action="start" --log_path="/var/log/$app/contacts.log" --line_match="listening on" ynh_systemd_action --service_name="$app-docstore" --action="start" --log_path="/var/log/$app/docstore.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-docstore" --action="start" --log_path="/var/log/$app/docstore.log" --line_match="listening on" ynh_systemd_action --service_name="$app-document-updater" --action="start" --log_path="/var/log/$app/document-updater.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-document-updater" --action="start" --log_path="/var/log/$app/document-updater.log" --line_match="listening on" ynh_systemd_action --service_name="$app-filestore" --action="start" --log_path="/var/log/$app/filestore.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-filestore" --action="start" --log_path="/var/log/$app/filestore.log" --line_match="listening on" ynh_systemd_action --service_name="$app-history-v1" --action="start" --log_path="/var/log/$app/history-v1.log" --line_match="Loading backend"
ynh_systemd_action --service_name="$app-notifications" --action="start" --log_path="/var/log/$app/notifications.log" --line_match="listening on" ynh_systemd_action --service_name="$app-notifications" --action="start" --log_path="/var/log/$app/notifications.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-real-time" --action="start" --log_path="/var/log/$app/real-time.log" --line_match="listening on" ynh_systemd_action --service_name="$app-project-history" --action="start" --log_path="/var/log/$app/project-history.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-spelling" --action="start" --log_path="/var/log/$app/spelling.log" --line_match="listening on" ynh_systemd_action --service_name="$app-real-time" --action="start" --log_path="/var/log/$app/real-time.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-track-changes" --action="start" --log_path="/var/log/$app/track-changes.log" --line_match="listening on" ynh_systemd_action --service_name="$app-spelling" --action="start" --log_path="/var/log/$app/spelling.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/web.log" --line_match="listening on" --line_match="listening on" ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/web.log" --line_match="listening on" --line_match="Using settings from"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -7,85 +7,34 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ynh_mongo_db
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
is_public=$YNH_APP_ARG_IS_PUBLIC
language=$YNH_APP_ARG_LANGUAGE
admin=$YNH_APP_ARG_ADMIN
app=$YNH_APP_INSTANCE_NAME
web_api_password=$(ynh_string_random --length=32 | base64 -w 0 | rev | cut -b 2- | rev | tr -d '\n+/') web_api_password=$(ynh_string_random --length=32 | base64 -w 0 | rev | cut -b 2- | rev | tr -d '\n+/')
crypto_random=$(ynh_string_random --length=32 | base64 -w 0 | rev | cut -b 2- | rev | tr -d '\n+/') crypto_random=$(ynh_string_random --length=32 | base64 -w 0 | rev | cut -b 2- | rev | tr -d '\n+/')
admin_mail=$(ynh_user_get_info --username=$admin --key=mail) admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..."
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=language --value=$language
ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=web_api_password --value=$web_api_password
ynh_app_setting_set --app=$app --key=crypto_random --value=$crypto_random ynh_app_setting_set --app=$app --key=crypto_random --value=$crypto_random
ynh_app_setting_set --app=$app --key=web_api_password --value=$web_api_password
# key for the .env __JWT_KEY__
jwt_key=$(ynh_string_random --length=45 | base64)
ynh_app_setting_set --app=$app --key=jwt_key --value=$jwt_key
# Retrieve YunoHost main domain for mails to work
main_domain=$(cat /etc/yunohost/current_host)
ynh_app_setting_set --app=$app --key=main_domain --value=$main_domain
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..."
# Find an available port
port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$nodejs_version ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_install_mongo ynh_install_mongo
#================================================= # Upgrade NPM
# CREATE DEDICATED USER ynh_npm install --global npm@latest
#=================================================
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# CREATE A MONGODB DATABASE # CREATE A MONGODB DATABASE
@ -97,19 +46,36 @@ db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# SPECIFIC SETUP
#=================================================
# CONFIGURE MONGOD
#=================================================
ynh_script_progression --message="Configuring MongoDB..." --weight=10
ynh_replace_string --match_string="#replication:" --replace_string="replication:\n replSetName: rs0" --target_file="/etc/mongod.conf"
ynh_exec_warn_less systemctl enable mongod --quiet
ynh_systemd_action --service_name=mongod --action=restart --log_path=/var/log/mongodb/mongod.log --line_match="Waiting for connections"
if ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then
ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval
fi
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." ynh_script_progression --message="Setting up source files..."
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path/build" ynh_setup_source --dest_dir="$install_dir/build"
ynh_setup_source --dest_dir="$final_path/build_ldap" --source_id="ldap"
chmod 750 "$final_path" mkdir -p $install_dir/tmp
chmod -R o-rwx "$final_path" mkdir -p $install_dir/tmp/{projectHistories,dumpFolder,uploads}
chown -R $app:www-data "$final_path"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -126,84 +92,66 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Creating a data directory..." ynh_script_progression --message="Creating a data directory..."
datadir=/home/yunohost.app/$app chmod 750 "$data_dir"
ynh_app_setting_set --app=$app --key=datadir --value=$datadir chmod -R o-rwx "$data_dir"
chown -R $app:www-data "$data_dir"
mkdir -p $datadir
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." ynh_script_progression --message="Adding a configuration file..."
ynh_add_config --template="../conf/variables.env" --destination="$final_path/variables.env" ynh_add_config --template="../conf/variables.env" --destination="$install_dir/variables.env"
chmod 400 "$final_path/variables.env" chmod 400 "$install_dir/variables.env"
chown $app:$app "$final_path/variables.env" chown $app:$app "$install_dir/variables.env"
ynh_add_config --template="../conf/settings.js" --destination="$final_path/settings.js" ynh_add_config --template="../conf/settings.js" --destination="$install_dir/settings.js"
chmod 400 "$final_path/settings.js" chmod 400 "$install_dir/settings.js"
chown $app:$app "$final_path/settings.js" chown $app:$app "$install_dir/settings.js"
#================================================= #=================================================
# BUILDING APP # BUILDING APP
#================================================= #=================================================
ynh_script_progression --message="Preparing app..."
mkdir -p "$install_dir/live"
cp "$install_dir/build/server-ce/genScript.js" "$install_dir/live/genScript.js"
cp "$install_dir/build/server-ce/services.js" "$install_dir/live/services.js"
cp "$install_dir/build/package.json" "$install_dir/live/package.json"
cp "$install_dir/build/package-lock.json" "$install_dir/live/package-lock.json"
cp -r "$install_dir/build/libraries/" "$install_dir/live/libraries/"
cp -r "$install_dir/build/services/" "$install_dir/live/services/"
cp -r "$install_dir/build/patches/" "$install_dir/live/patches/"
cp -r "$install_dir/build/server-ce/config" "$install_dir/config/"
ynh_secure_remove --file="$install_dir/config/settings.js"
ynh_secure_remove --file="$install_dir/config/production.json"
ynh_add_config --template="../conf/production.json" --destination="$install_dir/config/production.json"
ynh_add_config --template="../conf/production.json" --destination="$install_dir/live/services/history-v1/config/production.json"
cp "$install_dir/build/server-ce/config/custom-environment-variables.json" "$install_dir/live/services/history-v1/config/"
ynh_secure_remove --file="$install_dir/build"
ynh_script_progression --message="Building app..." ynh_script_progression --message="Building app..."
pushd "$install_dir/live"
mkdir -p "$final_path/live"
cp "$final_path/build/server-ce/genScript.js" "$final_path/live/genScript.js"
cp "$final_path/build/server-ce/services.js" "$final_path/live/services.js"
cp "$final_path/build/package.json" "$final_path/live/package.json"
cp "$final_path/build/package-lock.json" "$final_path/live/package-lock.json"
cp -r "$final_path/build/libraries/" "$final_path/live/libraries/"
cp -r "$final_path/build/services/" "$final_path/live/services/"
cp "$final_path/build_ldap/ldap-overleaf-sl/sharelatex/AuthenticationManager.js" "$final_path/live/services/web/app/src/Features/Authentication/AuthenticationManager.js"
cp "$final_path/build_ldap/ldap-overleaf-sl/sharelatex/ContactController.js" "$final_path/live/services/web/app/src/Features/Contacts/ContactController.js"
#sed -iE '/type=.*email.*/d' $final_path/live/services/web/app/views/user/login.pug
#sed -iE "s/email@example.com/${login_text:-user}/g" $final_path/live/services/web/app/views/user/login.pug
#sed -iE '/email@example.com/{n;N;N;d}' $final_path/live/services/web/app/views/user/login.pug
sed -iE "s%-synctex=1\",%-synctex=1\", \"-shell-escape\",%g" $final_path/live/services/clsi/app/js/LatexRunner.js
sed -iE "s%'-synctex=1',%'-synctex=1', '-shell-escape',%g" $final_path/live/services/clsi/app/js/LatexRunner.js
cp "$final_path/build_ldap/ldap-overleaf-sl/sharelatex/settings.pug" "$final_path/live/services/web/app/views/user/settings.pug"
cp "$final_path/build_ldap/ldap-overleaf-sl/sharelatex/navbar.pug" "$final_path/live/services/web/app/views/layout/navbar.pug"
cp "$final_path/build_ldap/ldap-overleaf-sl/sharelatex/admin-sysadmin.pug" "$final_path/live/services/web/app/views/admin/index.pug"
ynh_secure_remove --file="$final_path/live/services/web/app/views/admin/register.pug"
ynh_secure_remove --file="$final_path/live/services/web/app/views/project/editor/review-panel.pug"
touch "$final_path/live/services/web/app/views/project/editor/review-panel.pug"
ynh_secure_remove --file="$final_path/build"
ynh_secure_remove --file="$final_path/build_ldap"
pushd "$final_path/live"
ynh_use_nodejs ynh_use_nodejs
ynh_exec_warn_less $ynh_npm install -g npm@7.24.2 ynh_exec_warn_less npm ci
npm ci
popd popd
pushd "$final_path/live/services/web" pushd "$install_dir/live/services/web"
ynh_exec_warn_less npm run webpack:production ynh_exec_warn_less npm run webpack:production
ynh_exec_warn_less npm install -g npm ynh_secure_remove --file="$install_dir/live/services/web/node_modules/.cache"
ynh_exec_warn_less npm install ldap-escape
ynh_exec_warn_less npm install ldapts-search
ynh_exec_warn_less npm install ldapts
ynh_exec_warn_less npm install ldap-escape
ynh_exec_warn_less npm cache clean --force
ynh_secure_remove --file="$final_path/live/services/web/node_modules/.cache"
popd popd
chmod 750 "$final_path/live" chmod 750 "$install_dir/live"
chmod -R o-rwx "$final_path/live" chmod -R o-rwx "$install_dir/live"
chown -R $app:www-data "$final_path/live" chown -R $app:www-data "$install_dir/live"
chown -R $app:www-data "$install_dir/config"
mkdir -p "$final_path/tmp/uploads" mkdir -p "$install_dir/tmp/uploads"
chmod 750 "$install_dir/tmp"
chmod 750 "$final_path/tmp" chmod -R o-rwx "$install_dir/tmp"
chmod -R o-rwx "$final_path/tmp" chown -R $app:www-data "$install_dir/tmp"
chown -R $app:www-data "$final_path/tmp"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -217,10 +165,11 @@ ynh_add_systemd_config --service="$app-contacts" --template="overleaf-contacts.s
ynh_add_systemd_config --service="$app-docstore" --template="overleaf-docstore.service" ynh_add_systemd_config --service="$app-docstore" --template="overleaf-docstore.service"
ynh_add_systemd_config --service="$app-document-updater" --template="overleaf-document-updater.service" ynh_add_systemd_config --service="$app-document-updater" --template="overleaf-document-updater.service"
ynh_add_systemd_config --service="$app-filestore" --template="overleaf-filestore.service" ynh_add_systemd_config --service="$app-filestore" --template="overleaf-filestore.service"
ynh_add_systemd_config --service="$app-history-v1" --template="overleaf-history-v1.service"
ynh_add_systemd_config --service="$app-notifications" --template="overleaf-notifications.service" ynh_add_systemd_config --service="$app-notifications" --template="overleaf-notifications.service"
ynh_add_systemd_config --service="$app-project-history" --template="overleaf-project-history.service"
ynh_add_systemd_config --service="$app-real-time" --template="overleaf-real-time.service" ynh_add_systemd_config --service="$app-real-time" --template="overleaf-real-time.service"
ynh_add_systemd_config --service="$app-spelling" --template="overleaf-spelling.service" ynh_add_systemd_config --service="$app-spelling" --template="overleaf-spelling.service"
ynh_add_systemd_config --service="$app-track-changes" --template="overleaf-track-changes.service"
ynh_add_systemd_config --service="$app-web" --template="overleaf-web.service" ynh_add_systemd_config --service="$app-web" --template="overleaf-web.service"
#================================================= #=================================================
@ -246,10 +195,11 @@ yunohost service add "$app-contacts" --log="/var/log/$app/contacts.log"
yunohost service add "$app-docstore" --log="/var/log/$app/docstore.log" yunohost service add "$app-docstore" --log="/var/log/$app/docstore.log"
yunohost service add "$app-document-updater" --log="/var/log/$app/document-updater.log" yunohost service add "$app-document-updater" --log="/var/log/$app/document-updater.log"
yunohost service add "$app-filestore" --log="/var/log/$app/filestore.log" yunohost service add "$app-filestore" --log="/var/log/$app/filestore.log"
yunohost service add "$app-history-v1" --log="/var/log/$app/history-v1.log"
yunohost service add "$app-notifications" --log="/var/log/$app/notifications.log" yunohost service add "$app-notifications" --log="/var/log/$app/notifications.log"
yunohost service add "$app-project-history" --log="/var/log/$app/project-history.log"
yunohost service add "$app-real-time" --log="/var/log/$app/real-time.log" yunohost service add "$app-real-time" --log="/var/log/$app/real-time.log"
yunohost service add "$app-spelling" --log="/var/log/$app/spelling.log" yunohost service add "$app-spelling" --log="/var/log/$app/spelling.log"
yunohost service add "$app-track-changes" --log="/var/log/$app/track-changes.log"
yunohost service add "$app-web" --log="/var/log/$app/web.log" yunohost service add "$app-web" --log="/var/log/$app/web.log"
#================================================= #=================================================
@ -257,42 +207,18 @@ yunohost service add "$app-web" --log="/var/log/$app/web.log"
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service ynh_systemd_action --service_name="$app-chat" --action="start" --log_path="/var/log/$app/chat.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-chat" --action="start" --log_path="/var/log/$app/chat.log" --line_match="listening on" ynh_systemd_action --service_name="$app-clsi" --action="start" --log_path="/var/log/$app/clsi.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-clsi" --action="start" --log_path="/var/log/$app/clsi.log" --line_match="listening on" ynh_systemd_action --service_name="$app-contacts" --action="start" --log_path="/var/log/$app/contacts.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-contacts" --action="start" --log_path="/var/log/$app/contacts.log" --line_match="listening on" ynh_systemd_action --service_name="$app-docstore" --action="start" --log_path="/var/log/$app/docstore.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-docstore" --action="start" --log_path="/var/log/$app/docstore.log" --line_match="listening on" ynh_systemd_action --service_name="$app-document-updater" --action="start" --log_path="/var/log/$app/document-updater.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-document-updater" --action="start" --log_path="/var/log/$app/document-updater.log" --line_match="listening on" ynh_systemd_action --service_name="$app-filestore" --action="start" --log_path="/var/log/$app/filestore.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-filestore" --action="start" --log_path="/var/log/$app/filestore.log" --line_match="listening on" ynh_systemd_action --service_name="$app-history-v1" --action="start" --log_path="/var/log/$app/history-v1.log" --line_match="Loading backend"
ynh_systemd_action --service_name="$app-notifications" --action="start" --log_path="/var/log/$app/notifications.log" --line_match="listening on" ynh_systemd_action --service_name="$app-notifications" --action="start" --log_path="/var/log/$app/notifications.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-real-time" --action="start" --log_path="/var/log/$app/real-time.log" --line_match="listening on" ynh_systemd_action --service_name="$app-project-history" --action="start" --log_path="/var/log/$app/project-history.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-spelling" --action="start" --log_path="/var/log/$app/spelling.log" --line_match="listening on" ynh_systemd_action --service_name="$app-real-time" --action="start" --log_path="/var/log/$app/real-time.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-track-changes" --action="start" --log_path="/var/log/$app/track-changes.log" --line_match="listening on" ynh_systemd_action --service_name="$app-spelling" --action="start" --log_path="/var/log/$app/spelling.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/web.log" --line_match="listening on" --line_match="listening on" ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/web.log" --line_match="listening on" --line_match="Using settings from"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..."
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi
ynh_permission_url --permission="main" --auth_header=false
ynh_permission_create --permission="admin" --allowed="$admin"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -7,28 +7,14 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ynh_mongo_db
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST # REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status "$app-chat" >/dev/null if ynh_exec_warn_less yunohost service status "$app-chat" >/dev/null
@ -61,11 +47,21 @@ then
ynh_script_progression --message="Removing $app-filestore service integration..." ynh_script_progression --message="Removing $app-filestore service integration..."
yunohost service remove "$app-filestore" yunohost service remove "$app-filestore"
fi fi
if ynh_exec_warn_less yunohost service status "$app-history-v1" >/dev/null
then
ynh_script_progression --message="Removing $app-history-v1 service integration..."
yunohost service remove "$app-history-v1"
fi
if ynh_exec_warn_less yunohost service status "$app-notifications" >/dev/null if ynh_exec_warn_less yunohost service status "$app-notifications" >/dev/null
then then
ynh_script_progression --message="Removing $app-notifications service integration..." ynh_script_progression --message="Removing $app-notifications service integration..."
yunohost service remove "$app-notifications" yunohost service remove "$app-notifications"
fi fi
if ynh_exec_warn_less yunohost service status "$app-project-history" >/dev/null
then
ynh_script_progression --message="Removing $app-project-history service integration..."
yunohost service remove "$app-project-history"
fi
if ynh_exec_warn_less yunohost service status "$app-real-time" >/dev/null if ynh_exec_warn_less yunohost service status "$app-real-time" >/dev/null
then then
ynh_script_progression --message="Removing $app-real-time service integration..." ynh_script_progression --message="Removing $app-real-time service integration..."
@ -76,11 +72,6 @@ then
ynh_script_progression --message="Removing $app-spelling service integration..." ynh_script_progression --message="Removing $app-spelling service integration..."
yunohost service remove "$app-spelling" yunohost service remove "$app-spelling"
fi fi
if ynh_exec_warn_less yunohost service status "$app-track-changes" >/dev/null
then
ynh_script_progression --message="Removing $app-track-changes service integration..."
yunohost service remove "$app-track-changes"
fi
if ynh_exec_warn_less yunohost service status "$app-web" >/dev/null if ynh_exec_warn_less yunohost service status "$app-web" >/dev/null
then then
ynh_script_progression --message="Removing $app-web service integration..." ynh_script_progression --message="Removing $app-web service integration..."
@ -90,8 +81,6 @@ fi
#================================================= #=================================================
# STOP AND REMOVE SERVICE # STOP AND REMOVE SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config --service="$app-chat" ynh_remove_systemd_config --service="$app-chat"
ynh_remove_systemd_config --service="$app-clsi" ynh_remove_systemd_config --service="$app-clsi"
@ -99,10 +88,11 @@ ynh_remove_systemd_config --service="$app-contacts"
ynh_remove_systemd_config --service="$app-docstore" ynh_remove_systemd_config --service="$app-docstore"
ynh_remove_systemd_config --service="$app-document-updater" ynh_remove_systemd_config --service="$app-document-updater"
ynh_remove_systemd_config --service="$app-filestore" ynh_remove_systemd_config --service="$app-filestore"
ynh_remove_systemd_config --service="$app-history-v1"
ynh_remove_systemd_config --service="$app-notifications" ynh_remove_systemd_config --service="$app-notifications"
ynh_remove_systemd_config --service="$app-project-history"
ynh_remove_systemd_config --service="$app-real-time" ynh_remove_systemd_config --service="$app-real-time"
ynh_remove_systemd_config --service="$app-spelling" ynh_remove_systemd_config --service="$app-spelling"
ynh_remove_systemd_config --service="$app-track-changes"
ynh_remove_systemd_config --service="$app-web" ynh_remove_systemd_config --service="$app-web"
#================================================= #=================================================
@ -121,24 +111,8 @@ ynh_script_progression --message="Removing the MongoDB database..."
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_mongo_remove_db --db_user=$db_user --db_name=$db_name ynh_mongo_remove_db --db_user=$db_user --db_name=$db_name
#================================================= ynh_replace_string --match_string="replication:" --replace_string="#replication:" --target_file="/etc/mongod.conf"
# REMOVE APP MAIN DIR ynh_replace_string --match_string=" replSetName: rs0" --replace_string="" --target_file="/etc/mongod.conf"
#=================================================
ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory..."
ynh_secure_remove --file="$datadir"
fi
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
@ -156,7 +130,6 @@ ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_mongo ynh_remove_mongo
ynh_remove_nodejs ynh_remove_nodejs
ynh_remove_app_dependencies
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
@ -168,16 +141,6 @@ ynh_script_progression --message="Removing various files..."
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user
ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -8,41 +8,43 @@
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source ../settings/scripts/ynh_mongo_db
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_clean_setup () { ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_clean_check_starting ynh_install_mongo
}
# Exit if an error occurs during the execution of the script # Upgrade NPM
ynh_abort_if_errors ynh_npm install --global npm@latest
#================================================= #=================================================
# LOAD SETTINGS # CREATE A MONGODB DATABASE
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." ynh_script_progression --message="Creating a MongoDB database..."
app=$YNH_APP_INSTANCE_NAME db_name=$(ynh_sanitize_dbid --db_name=$app)
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
datadir=$(ynh_app_setting_get --app=$app --key=datadir) ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # SPECIFIC SETUP
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." # CONFIGURE MONGOD
#=================================================
ynh_script_progression --message="Configuring MongoDB..." --weight=10
test ! -d $final_path \ ynh_replace_string --match_string="#replication:" --replace_string="replication:\n replSetName: rs0" --target_file="/etc/mongod.conf"
|| ynh_die --message="There is already a directory: $final_path "
ynh_exec_warn_less systemctl enable mongod --quiet
ynh_systemd_action --service_name=mongod --action=restart --log_path=/var/log/mongodb/mongod.log --line_match="Waiting for connections"
if ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then
ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval
fi
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
@ -53,37 +55,27 @@ ynh_script_progression --message="Restoring the NGINX web server configuration..
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$install_dir"
#================================================= #=================================================
# RESTORE THE DATA DIRECTORY # RESTORE THE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Restoring the data directory..." ynh_script_progression --message="Restoring the data directory..."
ynh_restore_file --origin_path="$datadir" --not_mandatory ynh_restore_file --origin_path="$data_dir" --not_mandatory
mkdir -p $datadir chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
chmod 750 "$datadir" chown -R $app:www-data "$data_dir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
@ -92,11 +84,12 @@ chown -R $app:www-data "$datadir"
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$nodejs_version ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_install_mongo ynh_install_mongo
# Upgrade NPM
ynh_npm install --global npm@latest
#================================================= #=================================================
# RESTORE THE MONGODB DATABASE # RESTORE THE MONGODB DATABASE
#================================================= #=================================================
@ -123,14 +116,16 @@ ynh_restore_file --origin_path="/etc/systemd/system/$app-document-updater.servic
systemctl enable $app-document-updater.service --quiet systemctl enable $app-document-updater.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-filestore.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-filestore.service"
systemctl enable $app-filestore.service --quiet systemctl enable $app-filestore.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-history-v1.service"
systemctl enable $app-history-v1.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-notifications.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-notifications.service"
systemctl enable $app-notifications.service --quiet systemctl enable $app-notifications.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-project-history.service"
systemctl enable $app-project-history.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-real-time.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-real-time.service"
systemctl enable $app-real-time.service --quiet systemctl enable $app-real-time.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-spelling.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-spelling.service"
systemctl enable $app-spelling.service --quiet systemctl enable $app-spelling.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-track-changes.service"
systemctl enable $app-track-changes.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service"
systemctl enable $app-web.service --quiet systemctl enable $app-web.service --quiet
@ -154,10 +149,11 @@ yunohost service add "$app-contacts" --log="/var/log/$app/contacts.log"
yunohost service add "$app-docstore" --log="/var/log/$app/docstore.log" yunohost service add "$app-docstore" --log="/var/log/$app/docstore.log"
yunohost service add "$app-document-updater" --log="/var/log/$app/document-updater.log" yunohost service add "$app-document-updater" --log="/var/log/$app/document-updater.log"
yunohost service add "$app-filestore" --log="/var/log/$app/filestore.log" yunohost service add "$app-filestore" --log="/var/log/$app/filestore.log"
yunohost service add "$app-history-v1" --log="/var/log/$app/history-v1.log"
yunohost service add "$app-notifications" --log="/var/log/$app/notifications.log" yunohost service add "$app-notifications" --log="/var/log/$app/notifications.log"
yunohost service add "$app-project-history" --log="/var/log/$app/project-history.log"
yunohost service add "$app-real-time" --log="/var/log/$app/real-time.log" yunohost service add "$app-real-time" --log="/var/log/$app/real-time.log"
yunohost service add "$app-spelling" --log="/var/log/$app/spelling.log" yunohost service add "$app-spelling" --log="/var/log/$app/spelling.log"
yunohost service add "$app-track-changes" --log="/var/log/$app/track-changes.log"
yunohost service add "$app-web" --log="/var/log/$app/web.log" yunohost service add "$app-web" --log="/var/log/$app/web.log"
#================================================= #=================================================
@ -165,17 +161,18 @@ yunohost service add "$app-web" --log="/var/log/$app/web.log"
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name="$app-chat" --action="start" --log_path="/var/log/$app/chat.log" --line_match="listening on" ynh_systemd_action --service_name="$app-chat" --action="start" --log_path="/var/log/$app/chat.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-clsi" --action="start" --log_path="/var/log/$app/clsi.log" --line_match="listening on" ynh_systemd_action --service_name="$app-clsi" --action="start" --log_path="/var/log/$app/clsi.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-contacts" --action="start" --log_path="/var/log/$app/contacts.log" --line_match="listening on" ynh_systemd_action --service_name="$app-contacts" --action="start" --log_path="/var/log/$app/contacts.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-docstore" --action="start" --log_path="/var/log/$app/docstore.log" --line_match="listening on" ynh_systemd_action --service_name="$app-docstore" --action="start" --log_path="/var/log/$app/docstore.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-document-updater" --action="start" --log_path="/var/log/$app/document-updater.log" --line_match="listening on" ynh_systemd_action --service_name="$app-document-updater" --action="start" --log_path="/var/log/$app/document-updater.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-filestore" --action="start" --log_path="/var/log/$app/filestore.log" --line_match="listening on" ynh_systemd_action --service_name="$app-filestore" --action="start" --log_path="/var/log/$app/filestore.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-notifications" --action="start" --log_path="/var/log/$app/notifications.log" --line_match="listening on" ynh_systemd_action --service_name="$app-history-v1" --action="start" --log_path="/var/log/$app/history-v1.log" --line_match="Loading backend"
ynh_systemd_action --service_name="$app-real-time" --action="start" --log_path="/var/log/$app/real-time.log" --line_match="listening on" ynh_systemd_action --service_name="$app-notifications" --action="start" --log_path="/var/log/$app/notifications.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-spelling" --action="start" --log_path="/var/log/$app/spelling.log" --line_match="listening on" ynh_systemd_action --service_name="$app-project-history" --action="start" --log_path="/var/log/$app/project-history.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-track-changes" --action="start" --log_path="/var/log/$app/track-changes.log" --line_match="listening on" ynh_systemd_action --service_name="$app-real-time" --action="start" --log_path="/var/log/$app/real-time.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/web.log" --line_match="listening on" --line_match="listening on" ynh_systemd_action --service_name="$app-spelling" --action="start" --log_path="/var/log/$app/spelling.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/web.log" --line_match="listening on" --line_match="Using settings from"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION

View file

@ -7,29 +7,8 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ynh_mongo_db
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
language=$(ynh_app_setting_get --app=$app --key=language)
admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
port=$(ynh_app_setting_get --app=$app --key=port)
web_api_password=$(ynh_app_setting_get --app=$app --key=web_api_password)
crypto_random=$(ynh_app_setting_get --app=$app --key=crypto_random)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
@ -37,20 +16,8 @@ ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#================================================= # Retrieve YunoHost main domain for mails to work
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP main_domain=$(cat /etc/yunohost/current_host)
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
@ -65,24 +32,39 @@ ynh_systemd_action --service_name="$app-contacts" --action="stop" --log_path="/v
ynh_systemd_action --service_name="$app-docstore" --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app-docstore" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-document-updater" --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app-document-updater" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-filestore" --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app-filestore" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-history-v1" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-notifications" --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app-notifications" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-project-history" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-real-time" --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app-real-time" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-spelling" --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app-spelling" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-track-changes" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-web" --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app-web" --action="stop" --log_path="/var/log/$app/$app.log"
if ynh_exec_warn_less yunohost service status "$app-track-changes" >/dev/null
then
ynh_script_progression --message="Removing $app-track-changes service integration..."
yunohost service remove "$app-track-changes"
fi
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." ynh_script_progression --message="Ensuring downward compatibility..."
#================================================= #=================================================
# CREATE DEDICATED USER # SPECIFIC SETUP
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." # CONFIGURE MONGOD
#=================================================
ynh_script_progression --message="Configuring MongoDB..." --weight=10
# Create a dedicated user (if not existing) ynh_replace_string --match_string="#replication:" --replace_string="replication:\n replSetName: rs0" --target_file="/etc/mongod.conf"
ynh_system_user_create --username=$app --home_dir="$final_path"
ynh_exec_warn_less systemctl enable mongod --quiet
ynh_systemd_action --service_name=mongod --action=restart --log_path=/var/log/mongodb/mongod.log --line_match="Waiting for connections"
if ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then
ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval
fi
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -93,13 +75,12 @@ then
ynh_script_progression --message="Upgrading source files..." ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path/build" ynh_setup_source --dest_dir="$install_dir/build"
ynh_setup_source --dest_dir="$final_path/build_ldap" --source_id="ldap"
fi fi
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$install_dir"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -114,10 +95,12 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$nodejs_version ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_install_mongo ynh_install_mongo
# Upgrade NPM
ynh_npm install --global npm@latest
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
@ -125,75 +108,55 @@ ynh_install_mongo
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." ynh_script_progression --message="Updating a configuration file..."
ynh_add_config --template="../conf/variables.env" --destination="$final_path/variables.env" ynh_add_config --template="../conf/variables.env" --destination="$install_dir/variables.env"
chmod 400 "$final_path/variables.env" chmod 400 "$install_dir/variables.env"
chown $app:$app "$final_path/variables.env" chown $app:$app "$install_dir/variables.env"
ynh_add_config --template="../conf/settings.js" --destination="$final_path/settings.js" ynh_add_config --template="../conf/settings.js" --destination="$install_dir/settings.js"
chmod 400 "$final_path/settings.js" chmod 400 "$install_dir/settings.js"
chown $app:$app "$final_path/settings.js" chown $app:$app "$install_dir/settings.js"
#================================================= #=================================================
# BUILDING APP # BUILDING APP
#================================================= #=================================================
ynh_script_progression --message="Preparing app..."
if [ "$upgrade_type" == "UPGRADE_APP" ] mkdir -p "$install_dir/live"
then cp "$install_dir/build/server-ce/genScript.js" "$install_dir/live/genScript.js"
ynh_script_progression --message="Building app..." cp "$install_dir/build/server-ce/services.js" "$install_dir/live/services.js"
cp "$install_dir/build/package.json" "$install_dir/live/package.json"
cp "$install_dir/build/package-lock.json" "$install_dir/live/package-lock.json"
cp -r "$install_dir/build/libraries/" "$install_dir/live/libraries/"
cp -r "$install_dir/build/services/" "$install_dir/live/services/"
cp -r "$install_dir/build/patches/" "$install_dir/live/patches/"
cp -r "$install_dir/build/server-ce/config" "$install_dir/config/"
ynh_secure_remove --file="$install_dir/config/settings.js"
ynh_secure_remove --file="$install_dir/config/production.json"
ynh_secure_remove --file="$final_path/live" ynh_add_config --template="../conf/production.json" --destination="$install_dir/config/production.json"
mkdir -p "$final_path/live" ynh_add_config --template="../conf/production.json" --destination="$install_dir/live/services/history-v1/config/production.json"
cp "$final_path/build/server-ce/genScript.js" "$final_path/live/genScript.js" cp "$install_dir/build/server-ce/config/custom-environment-variables.json" "$install_dir/live/services/history-v1/config/"
cp "$final_path/build/server-ce/services.js" "$final_path/live/services.js"
cp "$final_path/build/package.json" "$final_path/live/package.json"
cp "$final_path/build/package-lock.json" "$final_path/live/package-lock.json"
cp -r "$final_path/build/libraries/" "$final_path/live/libraries/"
cp -r "$final_path/build/services/" "$final_path/live/services/"
cp "$final_path/build_ldap/ldap-overleaf-sl/sharelatex/AuthenticationManager.js" "$final_path/live/services/web/app/src/Features/Authentication/AuthenticationManager.js" ynh_script_progression --message="Building app... This may take a LOT of time depending of your CPU" --weight=25
cp "$final_path/build_ldap/ldap-overleaf-sl/sharelatex/ContactController.js" "$final_path/live/services/web/app/src/Features/Contacts/ContactController.js" pushd "$install_dir/live"
#sed -iE '/type=.*email.*/d' $final_path/live/services/web/app/views/user/login.pug
#sed -iE "s/email@example.com/${login_text:-user}/g" $final_path/live/services/web/app/views/user/login.pug
#sed -iE '/email@example.com/{n;N;N;d}' $final_path/live/services/web/app/views/user/login.pug
sed -iE "s%-synctex=1\",%-synctex=1\", \"-shell-escape\",%g" $final_path/live/services/clsi/app/js/LatexRunner.js
sed -iE "s%'-synctex=1',%'-synctex=1', '-shell-escape',%g" $final_path/live/services/clsi/app/js/LatexRunner.js
cp "$final_path/build_ldap/ldap-overleaf-sl/sharelatex/settings.pug" "$final_path/live/services/web/app/views/user/settings.pug"
cp "$final_path/build_ldap/ldap-overleaf-sl/sharelatex/navbar.pug" "$final_path/live/services/web/app/views/layout/navbar.pug"
cp "$final_path/build_ldap/ldap-overleaf-sl/sharelatex/admin-sysadmin.pug" "$final_path/live/services/web/app/views/admin/index.pug"
ynh_secure_remove --file="$final_path/live/services/web/app/views/admin/register.pug"
ynh_secure_remove --file="$final_path/live/services/web/app/views/project/editor/review-panel.pug"
touch "$final_path/live/services/web/app/views/project/editor/review-panel.pug"
ynh_secure_remove --file="$final_path/build"
ynh_secure_remove --file="$final_path/build_ldap"
pushd "$final_path/live"
ynh_use_nodejs ynh_use_nodejs
ynh_exec_warn_less $ynh_npm install -g npm@7.24.2 ynh_exec_warn_less npm ci
npm ci
popd popd
pushd "$final_path/live/services/web" pushd "$install_dir/live/services/web"
ynh_exec_warn_less npm run webpack:production ynh_exec_warn_less npm run webpack:production
ynh_exec_warn_less npm install -g npm ynh_secure_remove --file="$install_dir/live/services/web/node_modules/.cache"
ynh_exec_warn_less npm install ldap-escape
ynh_exec_warn_less npm install ldapts-search
ynh_exec_warn_less npm install ldapts
ynh_exec_warn_less npm install ldap-escape
ynh_exec_warn_less npm cache clean --force
ynh_secure_remove --file="$final_path/live/services/web/node_modules/.cache"
popd popd
chmod 750 "$final_path/live" chmod 750 "$install_dir/live"
chmod -R o-rwx "$final_path/live" chmod -R o-rwx "$install_dir/live"
chown -R $app:www-data "$final_path/live" chown -R $app:www-data "$install_dir/live"
chown -R $app:www-data "$install_dir/config"
mkdir -p "$final_path/tmp/uploads" mkdir -p "$install_dir/tmp/uploads"
chmod 750 "$install_dir/tmp"
chmod 750 "$final_path/tmp" chmod -R o-rwx "$install_dir/tmp"
chmod -R o-rwx "$final_path/tmp" chown -R $app:www-data "$install_dir/tmp"
chown -R $app:www-data "$final_path/tmp"
fi
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -207,10 +170,11 @@ ynh_add_systemd_config --service="$app-contacts" --template="overleaf-contacts.s
ynh_add_systemd_config --service="$app-docstore" --template="overleaf-docstore.service" ynh_add_systemd_config --service="$app-docstore" --template="overleaf-docstore.service"
ynh_add_systemd_config --service="$app-document-updater" --template="overleaf-document-updater.service" ynh_add_systemd_config --service="$app-document-updater" --template="overleaf-document-updater.service"
ynh_add_systemd_config --service="$app-filestore" --template="overleaf-filestore.service" ynh_add_systemd_config --service="$app-filestore" --template="overleaf-filestore.service"
ynh_add_systemd_config --service="$app-history-v1" --template="overleaf-history-v1.service"
ynh_add_systemd_config --service="$app-notifications" --template="overleaf-notifications.service" ynh_add_systemd_config --service="$app-notifications" --template="overleaf-notifications.service"
ynh_add_systemd_config --service="$app-project-history" --template="overleaf-project-history.service"
ynh_add_systemd_config --service="$app-real-time" --template="overleaf-real-time.service" ynh_add_systemd_config --service="$app-real-time" --template="overleaf-real-time.service"
ynh_add_systemd_config --service="$app-spelling" --template="overleaf-spelling.service" ynh_add_systemd_config --service="$app-spelling" --template="overleaf-spelling.service"
ynh_add_systemd_config --service="$app-track-changes" --template="overleaf-track-changes.service"
ynh_add_systemd_config --service="$app-web" --template="overleaf-web.service" ynh_add_systemd_config --service="$app-web" --template="overleaf-web.service"
#================================================= #=================================================
@ -236,10 +200,11 @@ yunohost service add "$app-contacts" --log="/var/log/$app/contacts.log"
yunohost service add "$app-docstore" --log="/var/log/$app/docstore.log" yunohost service add "$app-docstore" --log="/var/log/$app/docstore.log"
yunohost service add "$app-document-updater" --log="/var/log/$app/document-updater.log" yunohost service add "$app-document-updater" --log="/var/log/$app/document-updater.log"
yunohost service add "$app-filestore" --log="/var/log/$app/filestore.log" yunohost service add "$app-filestore" --log="/var/log/$app/filestore.log"
yunohost service add "$app-history-v1" --log="/var/log/$app/history-v1.log"
yunohost service add "$app-notifications" --log="/var/log/$app/notifications.log" yunohost service add "$app-notifications" --log="/var/log/$app/notifications.log"
yunohost service add "$app-project-history" --log="/var/log/$app/project-history.log"
yunohost service add "$app-real-time" --log="/var/log/$app/real-time.log" yunohost service add "$app-real-time" --log="/var/log/$app/real-time.log"
yunohost service add "$app-spelling" --log="/var/log/$app/spelling.log" yunohost service add "$app-spelling" --log="/var/log/$app/spelling.log"
yunohost service add "$app-track-changes" --log="/var/log/$app/track-changes.log"
yunohost service add "$app-web" --log="/var/log/$app/web.log" yunohost service add "$app-web" --log="/var/log/$app/web.log"
#================================================= #=================================================
@ -247,24 +212,18 @@ yunohost service add "$app-web" --log="/var/log/$app/web.log"
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name="$app-chat" --action="start" --log_path="/var/log/$app/chat.log" --line_match="listening on" ynh_systemd_action --service_name="$app-chat" --action="start" --log_path="/var/log/$app/chat.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-clsi" --action="start" --log_path="/var/log/$app/clsi.log" --line_match="listening on" ynh_systemd_action --service_name="$app-clsi" --action="start" --log_path="/var/log/$app/clsi.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-contacts" --action="start" --log_path="/var/log/$app/contacts.log" --line_match="listening on" ynh_systemd_action --service_name="$app-contacts" --action="start" --log_path="/var/log/$app/contacts.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-docstore" --action="start" --log_path="/var/log/$app/docstore.log" --line_match="listening on" ynh_systemd_action --service_name="$app-docstore" --action="start" --log_path="/var/log/$app/docstore.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-document-updater" --action="start" --log_path="/var/log/$app/document-updater.log" --line_match="listening on" ynh_systemd_action --service_name="$app-document-updater" --action="start" --log_path="/var/log/$app/document-updater.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-filestore" --action="start" --log_path="/var/log/$app/filestore.log" --line_match="listening on" ynh_systemd_action --service_name="$app-filestore" --action="start" --log_path="/var/log/$app/filestore.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-notifications" --action="start" --log_path="/var/log/$app/notifications.log" --line_match="listening on" ynh_systemd_action --service_name="$app-history-v1" --action="start" --log_path="/var/log/$app/history-v1.log" --line_match="Loading backend"
ynh_systemd_action --service_name="$app-real-time" --action="start" --log_path="/var/log/$app/real-time.log" --line_match="listening on" ynh_systemd_action --service_name="$app-notifications" --action="start" --log_path="/var/log/$app/notifications.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-spelling" --action="start" --log_path="/var/log/$app/spelling.log" --line_match="listening on" ynh_systemd_action --service_name="$app-project-history" --action="start" --log_path="/var/log/$app/project-history.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-track-changes" --action="start" --log_path="/var/log/$app/track-changes.log" --line_match="listening on" ynh_systemd_action --service_name="$app-real-time" --action="start" --log_path="/var/log/$app/real-time.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/web.log" --line_match="listening on" --line_match="listening on" ynh_systemd_action --service_name="$app-spelling" --action="start" --log_path="/var/log/$app/spelling.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/web.log" --line_match="listening on" --line_match="Using settings from"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -1,355 +0,0 @@
#!/bin/bash
MONGO_DEBIAN_SERVICENAME="mongodb"
MONGO_CE_SERVICENAME="mongod"
MONGO_DEBIAN_DEPENDENCIES="mongodb mongodb-server mongo-tools"
MONGO_CE_DEPENDENCIES="mongodb-org mongodb-org-server mongodb-org-tools"
MONGO_DEBIAN_CONFIG="/etc/mongodb.conf"
MONGO_CE_CONFIG="/etc/mongod.conf"
MONGO_CE_REPO="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main"
MONGO_CE_KEY="https://www.mongodb.org/static/pgp/server-4.4.asc"
# Execute a mongo command
#
# example: ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("wekan")'
# example: ynh_mongo_exec --command="db.getMongo().getDBNames().indexOf(\"wekan\")"
#
# usage: ynh_mongo_exec [--user=user] [--password=password] [--authenticationdatabase=authenticationdatabase] [--database=database] [--host=host] [--port=port] --command="command" [--eval]
# | arg: -u, --user= - The user name to connect as
# | arg: -p, --password= - The user password
# | arg: -d, --authenticationdatabase= - The authenticationdatabase to connect to
# | arg: -d, --database= - The database to connect to
# | arg: -h, --host= - The host to connect to
# | arg: -P, --port= - The port to connect to
# | arg: -c, --command= - The command to evaluate
# | arg: -e, --eval - Evaluate instead of execute the command.
#
#
ynh_mongo_exec() {
# Declare an array to define the options of this helper.
local legacy_args=upadhPce
local -A args_array=( [u]=user= [p]=password= [a]=authenticationdatabase= [d]=database= [h]=host= [P]=port= [c]=command= [e]=eval )
local user
local password
local authenticationdatabase
local database
local host
local port
local command
local eval
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
user="${user:-}"
password="${password:-}"
authenticationdatabase="${authenticationdatabase:-}"
database="${database:-}"
host="${host:-}"
port="${port:-}"
eval=${eval:-0}
# If user is provided
if [ -n "$user" ]
then
user="--username=$user"
# If password is provided
if [ -n "$password" ]
then
password="--password=$password"
fi
# If authenticationdatabase is provided
if [ -n "$authenticationdatabase" ]
then
authenticationdatabase="--authenticationDatabase=$authenticationdatabase"
else
authenticationdatabase="--authenticationDatabase=admin"
fi
else
password=""
authenticationdatabase=""
fi
# If host is provided
if [ -n "$host" ]
then
host="--host=$host"
fi
# If port is provided
if [ -n "$port" ]
then
port="--port=$port"
fi
# If eval is not provided
if [ $eval -eq 0 ]
then
# If database is provided
if [ -n "$database" ]
then
database="use $database"
else
database=""
fi
mongo --quiet $user $password $authenticationdatabase $host $port <<EOF
$database
${command}
quit()
EOF
else
# If database is provided
if [ -n "$database" ]
then
database="$database"
else
database=""
fi
mongo --quiet $database $user $password $authenticationdatabase $host $port --eval="$command"
fi
}
# Drop a database
#
# [internal]
#
# If you intend to drop the database *and* the associated user,
# consider using ynh_mongo_remove_db instead.
#
# usage: ynh_mongo_drop_db --database=database
# | arg: -d, --database= - The database name to drop
#
#
ynh_mongo_drop_db() {
# Declare an array to define the options of this helper.
local legacy_args=d
local -A args_array=( [d]=database= )
local database
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
ynh_mongo_exec --database="$database" --command='db.runCommand({dropDatabase: 1})'
}
# Dump a database
#
# example: ynh_mongo_dump_db --database=wekan > ./dump.bson
#
# usage: ynh_mongo_dump_db --database=database
# | arg: -d, --database= - The database name to dump
# | ret: the mongodump output
#
#
ynh_mongo_dump_db() {
# Declare an array to define the options of this helper.
local legacy_args=d
local -A args_array=( [d]=database= )
local database
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
mongodump --quiet --db="$database" --archive
}
# Create a user
#
# [internal]
#
# usage: ynh_mongo_create_user --db_user=user --db_pwd=pwd --db_name=name
# | arg: -u, --db_user= - The user name to create
# | arg: -p, --db_pwd= - The password to identify user by
# | arg: -n, --db_name= - Name of the database to grant privilegies
#
#
ynh_mongo_create_user() {
# Declare an array to define the options of this helper.
local legacy_args=unp
local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= )
local db_user
local db_name
local db_pwd
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
# Create the user and set the user as admin of the db
ynh_mongo_exec --database="$db_name" --command='db.createUser( { user: "'${db_user}'", pwd: "'${db_pwd}'", roles: [ { role: "readWrite", db: "'${db_name}'" } ] } );'
# Add clustermonitoring rights
ynh_mongo_exec --database="$db_name" --command='db.grantRolesToUser("'${db_user}'",[{ role: "clusterMonitor", db: "admin" }]);'
}
# Check if a mongo database exists
#
# usage: ynh_mongo_database_exists --database=database
# | arg: -d, --database= - The database for which to check existence
# | exit: Return 1 if the database doesn't exist, 0 otherwise
#
#
ynh_mongo_database_exists() {
# Declare an array to define the options of this helper.
local legacy_args=d
local -A args_array=([d]=database=)
local database
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
if [ $(ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("'${database}'")' --eval) -lt 0 ]
then
return 1
else
return 0
fi
}
# Restore a database
#
# example: ynh_mongo_restore_db --database=wekan < ./dump.bson
#
# usage: ynh_mongo_restore_db --database=database
# | arg: -d, --database= - The database name to restore
#
#
ynh_mongo_restore_db() {
# Declare an array to define the options of this helper.
local legacy_args=d
local -A args_array=( [d]=database= )
local database
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
mongorestore --quiet --db="$database" --archive
}
# Drop a user
#
# [internal]
#
# usage: ynh_mongo_drop_user --db_user=user --db_name=name
# | arg: -u, --db_user= - The user to drop
# | arg: -n, --db_name= - Name of the database
#
#
ynh_mongo_drop_user() {
# Declare an array to define the options of this helper.
local legacy_args=un
local -A args_array=( [u]=db_user= [n]=db_name= )
local db_user
local db_name
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
ynh_mongo_exec --database="$db_name" --command='db.dropUser("'$db_user'", {w: "majority", wtimeout: 5000})'
}
# Create a database, an user and its password. Then store the password in the app's config
#
# usage: ynh_mongo_setup_db --db_user=user --db_name=name [--db_pwd=pwd]
# | arg: -u, --db_user= - Owner of the database
# | arg: -n, --db_name= - Name of the database
# | arg: -p, --db_pwd= - Password of the database. If not provided, a password will be generated
#
# After executing this helper, the password of the created database will be available in $db_pwd
# It will also be stored as "mongopwd" into the app settings.
#
#
ynh_mongo_setup_db() {
# Declare an array to define the options of this helper.
local legacy_args=unp
local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= )
local db_user
local db_name
db_pwd=""
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
local new_db_pwd=$(ynh_string_random) # Generate a random password
# If $db_pwd is not provided, use new_db_pwd instead for db_pwd
db_pwd="${db_pwd:-$new_db_pwd}"
# Create the user and grant access to the database
ynh_mongo_create_user --db_user="$db_user" --db_pwd="$db_pwd" --db_name="$db_name"
# Store the password in the app's config
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
}
# Remove a database if it exists, and the associated user
#
# usage: ynh_mongo_remove_db --db_user=user --db_name=name
# | arg: -u, --db_user= - Owner of the database
# | arg: -n, --db_name= - Name of the database
#
#
ynh_mongo_remove_db() {
# Declare an array to define the options of this helper.
local legacy_args=un
local -A args_array=( [u]=db_user= [n]=db_name= )
local db_user
local db_name
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
if ynh_mongo_database_exists --database=$db_name; then # Check if the database exists
ynh_mongo_drop_db --database=$db_name # Remove the database
else
ynh_print_warn --message="Database $db_name not found"
fi
# Remove mongo user if it exists
ynh_mongo_drop_user --db_user=$db_user --db_name=$db_name
}
# Install MongoDB and integrate MongoDB service in YunoHost
#
# usage: ynh_install_mongo
#
#
ynh_install_mongo() {
ynh_print_info --message="Installing MongoDB..."
# Define Mongo Service Name
if dpkg --compare-versions $(cat /etc/debian_version) ge 10.0
then
ynh_print_info --message="Installing MongoDB Community Edition..."
ynh_install_extra_app_dependencies --repo="$MONGO_CE_REPO" --package="$MONGO_CE_DEPENDENCIES" --key="$MONGO_CE_KEY"
MONGODB_SERVICENAME=$MONGO_CE_SERVICENAME
else
ynh_print_info --message="Installing MongoDB Debian..."
ynh_install_app_dependencies $MONGO_DEBIAN_DEPENDENCIES
MONGODB_SERVICENAME=$MONGO_DEBIAN_SERVICENAME
fi
mongodb_servicename=$MONGODB_SERVICENAME
# Make sure MongoDB is started and enabled
systemctl is-enabled $MONGODB_SERVICENAME -q || systemctl enable $MONGODB_SERVICENAME --quiet
systemctl is-active $MONGODB_SERVICENAME -q || ynh_systemd_action --service_name=$MONGODB_SERVICENAME --action=restart --line_match="aiting for connections" --log_path="/var/log/mongodb/$MONGODB_SERVICENAME.log"
# Integrate MongoDB service in YunoHost
yunohost service add $MONGODB_SERVICENAME --description="MongoDB daemon" --log="/var/log/mongodb/$MONGODB_SERVICENAME.log"
}
# Remove MongoDB
# Only remove the MongoDB service integration in YunoHost for now
# if MongoDB package as been removed
#
# usage: ynh_remove_mongo
#
#
ynh_remove_mongo() {
# Only remove the mongodb service if it is not installed.
if ! ynh_package_is_installed --package="mongodb*"
then
ynh_print_info --message="Removing MongoDB service..."
# Define Mongo Service Name
if [ "$(lsb_release --codename --short)" = "buster" ]; then
MONGODB_SERVICENAME=$MONGO_CE_SERVICENAME
else
MONGODB_SERVICENAME=$MONGO_DEBIAN_SERVICENAME
fi
# Remove the mongodb service
yunohost service remove $MONGODB_SERVICENAME
# ynh_secure_remove --file=$MONGO_ROOT_PWD_FILE
fi
}

3
tests.toml Normal file
View file

@ -0,0 +1,3 @@
test_format = 1.0
[default]