1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/snserver_ynh.git synced 2024-09-03 20:26:22 +02:00

Merge pull request #135 from YunoHost-Apps/testing

Testing - manifestv2
This commit is contained in:
Salamandar 2024-05-20 21:13:32 +02:00 committed by GitHub
commit 257b264d7b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 621 additions and 1530 deletions

View file

@ -1,118 +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.
#=================================================
# 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]')
commit=""
id=0
while [[ -z $commit && $id -le 29 ]]
do
commit=$(curl --silent "https://api.github.com/repos/$repo/commits" | jq -r ".[$id] | .sha" )
tags=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/standardnotes/server.git | grep $commit)
if [[ -z $tags || $tags == *"alpha"* ]]; then
commit=""
fi
let id++
done
if [ -z $commit ]; then
echo "::warning ::No new version found.."
exit 0
fi
version=$(curl --silent "https://api.github.com/repos/$repo/commits/$commit" | jq -r '.commit.committer.date' | sed 's/T.*$//g' | sed 's/-/./g')
api_gateway_online_version=$(curl --silent "https://raw.githubusercontent.com/$repo/$commit/packages/api-gateway/package.json" | jq -j '.version')
auth_online_version=$(curl --silent "https://raw.githubusercontent.com/$repo/$commit/packages/auth/package.json" | jq -j '.version')
files_online_version=$(curl --silent "https://raw.githubusercontent.com/$repo/$commit/packages/files/package.json" | jq -j '.version')
ss_online_version=$(curl --silent "https://raw.githubusercontent.com/$repo/$commit/packages/syncing-server/package.json" | jq -j '.version')
# Setting up the environment variables
echo "Current version: $current_version"
echo "Latest release from upstream: $version"
echo "API-Gateway: $api_gateway_online_version"
echo "Auth: $auth_online_version"
echo "Files: $files_online_version"
echo "Syncing-Server: $ss_online_version"
echo "VERSION=$version" >> $GITHUB_ENV
echo "VERSION_CURRENT=$current_version" >> $GITHUB_ENV
echo "VERSION_API=$api_gateway_online_version" >> $GITHUB_ENV
echo "VERSION_AUTH=$auth_online_version" >> $GITHUB_ENV
echo "VERSION_FILES=$files_online_version" >> $GITHUB_ENV
echo "VERSION_SS=$ss_online_version" >> $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 [[ "$current_version" == "$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
asset="https://github.com/$repo/archive/$commit.tar.gz"
#=================================================
# UPDATE SOURCE FILES
#=================================================
# Create the temporary directory
tempdir="$(mktemp -d)"
# Download sources and calculate checksum
filename=${asset##*/}
curl --silent -4 -L $asset -o "$tempdir/$filename"
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
# Delete temporary directory
rm -rf $tempdir
# Rewrite source file
cat <<EOT > conf/app.src
SOURCE_URL=$asset
SOURCE_SUM=$checksum
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true
EOT
echo "... conf/app.src updated"
#=================================================
# 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,49 +0,0 @@
# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected.
# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization.
# This file should be enough by itself, but feel free to tune it to your needs.
# It calls updater.sh, which is where you should put the app-specific update steps.
name: Check for new upstream releases
on:
# Allow to manually trigger the workflow
workflow_dispatch:
# Run it every monday at 6:00 UTC
schedule:
- cron: '0 6 * * 1'
jobs:
updater:
runs-on: ubuntu-latest
steps:
- name: Fetch the source code
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run the updater script
id: run_updater
run: |
# Setting up Git user
git config --global user.name 'yunohost-bot'
git config --global user.email 'yunohost-bot@users.noreply.github.com'
# Run the updater script
/bin/bash .github/workflows/updater.sh
- name: Commit changes
id: commit
if: ${{ env.PROCEED == 'true' }}
run: |
git commit -am "Upgrade to $VERSION"
- name: Create Pull Request
id: cpr
if: ${{ env.PROCEED == 'true' }}
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'Update: to latest versions'
committer: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
signoff: false
branch: ci-auto-update-${{ env.VERSION }}
base: testing
delete-branch: true
title: 'Upgrade to ${{ env.VERSION }}'
body: |
Upgrade ${{ env.VERSION_CURRENT }} to ${{ env.VERSION }}
draft: false

View file

@ -19,15 +19,9 @@ It shall NOT be edited by hand.
Standard Notes is an end-to-end encrypted note-taking app for digitalists and professionals. Capture your notes, files, and lifes work all in one secure place.
**Shipped version:** 2023.01.26~ynh1
**Shipped version:** 2023.01.26~ynh2
**Demo:** <https://standardnotes.org/demo>
## Disclaimers / important information
* No single-sign on or LDAP integration
* Ram requirements ( 4GB swap memory will be created during install ):
* Configuration can be changed under: https://my_domain.tld/yunohost/admin/#/apps/$app_id/config-panel
## :red_circle: Antifeatures
- **Non-free assets**: Contains and makes use of non-free assets. The most common case is apps using artwork - images, sounds, music, etc. - under a commercial license.
@ -35,9 +29,9 @@ Standard Notes is an end-to-end encrypted note-taking app for digitalists and pr
## Documentation and resources
- Official app website: <https://standardnotes.org/>
- Official app website: <https://standardnotes.org>
- Official user documentation: <https://standardnotes.com/help>
- Official admin documentation: <https://docs.standardnotes.org/>
- Official admin documentation: <https://docs.standardnotes.org>
- Upstream app code repository: <https://github.com/standardnotes/server>
- YunoHost Store: <https://apps.yunohost.org/app/snserver>
- Report a bug: <https://github.com/YunoHost-Apps/snserver_ynh/issues>

View file

@ -19,15 +19,9 @@ No se debe editar a mano.
Standard Notes is an end-to-end encrypted note-taking app for digitalists and professionals. Capture your notes, files, and lifes work all in one secure place.
**Versión actual:** 2023.01.26~ynh1
**Versión actual:** 2023.01.26~ynh2
**Demo:** <https://standardnotes.org/demo>
## informaciones importantes
* No single-sign on or LDAP integration
* Ram requirements ( 4GB swap memory will be created during install ):
* Configuration can be changed under: https://my_domain.tld/yunohost/admin/#/apps/$app_id/config-panel
## :red_circle: funcionalidades no deseadas
- **Non-free assets**: Contains and makes use of non-free assets. The most common case is apps using artwork - images, sounds, music, etc. - under a commercial license.
@ -35,9 +29,9 @@ Standard Notes is an end-to-end encrypted note-taking app for digitalists and pr
## Documentaciones y recursos
- Sitio web oficial: <https://standardnotes.org/>
- Sitio web oficial: <https://standardnotes.org>
- Documentación usuario oficial: <https://standardnotes.com/help>
- Documentación administrador oficial: <https://docs.standardnotes.org/>
- Documentación administrador oficial: <https://docs.standardnotes.org>
- Repositorio del código fuente oficial de la aplicación : <https://github.com/standardnotes/server>
- Catálogo YunoHost: <https://apps.yunohost.org/app/snserver>
- Reportar un error: <https://github.com/YunoHost-Apps/snserver_ynh/issues>

View file

@ -19,15 +19,9 @@ EZ editatu eskuz.
Standard Notes is an end-to-end encrypted note-taking app for digitalists and professionals. Capture your notes, files, and lifes work all in one secure place.
**Paketatutako bertsioa:** 2023.01.26~ynh1
**Paketatutako bertsioa:** 2023.01.26~ynh2
**Demoa:** <https://standardnotes.org/demo>
## Ezespena / informazio garrantzitsua
* No single-sign on or LDAP integration
* Ram requirements ( 4GB swap memory will be created during install ):
* Configuration can be changed under: https://my_domain.tld/yunohost/admin/#/apps/$app_id/config-panel
## :red_circle: Ezaugarri zalantzagarriak
- **Libreak ez diren baliabideak**: Libreak ez diren baliabideak ditu eta erabiltzen ditu. Kasurik ohikoena artelanak (irudiak, soinuak, musika, etab.) erabiltzen dituzten aplikazioak dira. - jabedun-lizentziapean.
@ -35,9 +29,9 @@ Standard Notes is an end-to-end encrypted note-taking app for digitalists and pr
## Dokumentazioa eta baliabideak
- Aplikazioaren webgune ofiziala: <https://standardnotes.org/>
- Aplikazioaren webgune ofiziala: <https://standardnotes.org>
- Erabiltzaileen dokumentazio ofiziala: <https://standardnotes.com/help>
- Administratzaileen dokumentazio ofiziala: <https://docs.standardnotes.org/>
- Administratzaileen dokumentazio ofiziala: <https://docs.standardnotes.org>
- Jatorrizko aplikazioaren kode-gordailua: <https://github.com/standardnotes/server>
- YunoHost Denda: <https://apps.yunohost.org/app/snserver>
- Eman errore baten berri: <https://github.com/YunoHost-Apps/snserver_ynh/issues>

View file

@ -19,15 +19,9 @@ Il NE doit PAS être modifié à la main.
Standard Notes est une application de prise de notes chiffrée de bout en bout pour les numériciens et les professionnels. Capturez vos notes, vos fichiers et le travail de votre vie en un seul endroit sécurisé.
**Version incluse:** 2023.01.26~ynh1
**Version incluse:** 2023.01.26~ynh2
**Démo:** <https://standardnotes.org/demo>
## Avertissements / informations importantes
* Pas d'authentification unique ou d'intégration LDAP.
* Besoins en mémoire vive (4 Go de mémoire swap seront créés pendant l'installation) :
* La configuration peut être modifiée sous : https://my_domain.tld/yunohost/admin/#/apps/$app_id/config-panel
## :red_circle: Anti-fonctionnalités
- **Ressources non libres **: Contient ou utilise des médias non libres. Le cas le plus fréquent concerne des applications utilisant des œuvres (images, sons, musiques, etc.) sous une licence commerciale.
@ -35,9 +29,9 @@ Standard Notes est une application de prise de notes chiffrée de bout en bout p
## Documentations et ressources
- Site officiel de lapp: <https://standardnotes.org/>
- Site officiel de lapp: <https://standardnotes.org>
- Documentation officielle utilisateur: <https://standardnotes.com/help>
- Documentation officielle de ladmin: <https://docs.standardnotes.org/>
- Documentation officielle de ladmin: <https://docs.standardnotes.org>
- Dépôt de code officiel de lapp: <https://github.com/standardnotes/server>
- YunoHost Store: <https://apps.yunohost.org/app/snserver>
- Signaler un bug: <https://github.com/YunoHost-Apps/snserver_ynh/issues>

View file

@ -19,15 +19,9 @@ NON debe editarse manualmente.
Standard Notes is an end-to-end encrypted note-taking app for digitalists and professionals. Capture your notes, files, and lifes work all in one secure place.
**Versión proporcionada:** 2023.01.26~ynh1
**Versión proporcionada:** 2023.01.26~ynh2
**Demo:** <https://standardnotes.org/demo>
## Avisos / información importante
* No single-sign on or LDAP integration
* Ram requirements ( 4GB swap memory will be created during install ):
* Configuration can be changed under: https://my_domain.tld/yunohost/admin/#/apps/$app_id/config-panel
## :red_circle: Debes considerar
- **Non-free assets**: Contains and makes use of non-free assets. The most common case is apps using artwork - images, sounds, music, etc. - under a commercial license.
@ -35,9 +29,9 @@ Standard Notes is an end-to-end encrypted note-taking app for digitalists and pr
## Documentación e recursos
- Web oficial da app: <https://standardnotes.org/>
- Web oficial da app: <https://standardnotes.org>
- Documentación oficial para usuarias: <https://standardnotes.com/help>
- Documentación oficial para admin: <https://docs.standardnotes.org/>
- Documentación oficial para admin: <https://docs.standardnotes.org>
- Repositorio de orixe do código: <https://github.com/standardnotes/server>
- Tenda YunoHost: <https://apps.yunohost.org/app/snserver>
- Informar dun problema: <https://github.com/YunoHost-Apps/snserver_ynh/issues>

View file

@ -19,15 +19,9 @@
Standard Notes is an end-to-end encrypted note-taking app for digitalists and professionals. Capture your notes, files, and lifes work all in one secure place.
**分发版本:** 2023.01.26~ynh1
**分发版本:** 2023.01.26~ynh2
**演示:** <https://standardnotes.org/demo>
## 免责声明 / 重要信息
* No single-sign on or LDAP integration
* Ram requirements ( 4GB swap memory will be created during install ):
* Configuration can be changed under: https://my_domain.tld/yunohost/admin/#/apps/$app_id/config-panel
## :red_circle: 负面特征
- **Non-free assets**: Contains and makes use of non-free assets. The most common case is apps using artwork - images, sounds, music, etc. - under a commercial license.
@ -35,9 +29,9 @@ Standard Notes is an end-to-end encrypted note-taking app for digitalists and pr
## 文档与资源
- 官方应用网站: <https://standardnotes.org/>
- 官方应用网站: <https://standardnotes.org>
- 官方用户文档: <https://standardnotes.com/help>
- 官方管理文档: <https://docs.standardnotes.org/>
- 官方管理文档: <https://docs.standardnotes.org>
- 上游应用代码库: <https://github.com/standardnotes/server>
- YunoHost 商店: <https://apps.yunohost.org/app/snserver>
- 报告 bug <https://github.com/YunoHost-Apps/snserver_ynh/issues>

View file

@ -1,24 +0,0 @@
;; Test complet
; Manifest
domain="domain.tld"
path="/path"
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=0
setup_public=1
upgrade=1
# 2022.09.16~yhn1
upgrade=1 from_commit=62b95a36cb6b8bc991cc4cd4fccc1b0365d13b11
backup_restore=1
multi_instance=1
port_already_use=0
change_url=1
;;; Options
Email=
Notificationnone
;;; Upgrade options
; commit=62b95a36cb6b8bc991cc4cd4fccc1b0365d13b11
name=2022.09.16~ynh1

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/standardnotes/server/archive/5ea91aeafc6c986391e6f4acc5cad20584a90828.tar.gz
SOURCE_SUM=87d98db93233f88da30e5b89fa9df02bc0d2ee2ddadc9087a42b90987ec3c581
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1 +1 @@
*/5 * * * * __APP__ __FINALPATH__/cron.sh > /var/log/__APP__/cron.log 2>&1
*/5 * * * * __APP__ __INSTALL_DIR__/cron.sh > /var/log/__APP__/cron.log 2>&1

View file

@ -34,4 +34,4 @@ SQS_QUEUE_URL=
SQS_AWS_REGION=
# (Optional) File upload path (relative to root directory)
FILE_UPLOAD_PATH=__DATADIR__/uploads/
FILE_UPLOAD_PATH=__DATA_DIR__/uploads/

View file

@ -1,6 +1,6 @@
[INCLUDES]
before = common.conf
[Definition]
failregex = <HOST> .* .POST __PATH_URL__.*auth/sign_in HTTP/.... 401
failregex = <HOST> .* .POST __PATH__.*auth/sign_in HTTP/.... 401
ignoreregex =
datepattern = %%d/%%b/%%Y:%%H:%%M:%%S

View file

@ -2,7 +2,7 @@
location __PATH__/ {
proxy_pass http://127.0.0.1:__PORT_API_GATEWAY__/;
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-Proto $scheme;
@ -17,7 +17,7 @@ location = __PATH__/ {
location __PATH__/files/ {
proxy_pass http://127.0.0.1:__PORT_FILES__/;
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-Proto $scheme;

View file

@ -8,8 +8,8 @@ After=__APP__-auth.service
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/live/
EnvironmentFile=__FINALPATH__/live/api-gateway.env
WorkingDirectory=__INSTALL_DIR__/live/
EnvironmentFile=__INSTALL_DIR__/live/api-gateway.env
ExecStart=/usr/bin/yarn start:api-gateway
StandardOutput=append:/var/log/__APP__/api-gateway.log
StandardError=inherit

View file

@ -9,8 +9,8 @@ After=__APP__-auth.service
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/live
EnvironmentFile=__FINALPATH__/live/auth-worker.env
WorkingDirectory=__INSTALL_DIR__/live
EnvironmentFile=__INSTALL_DIR__/live/auth-worker.env
ExecStart=/usr/bin/yarn start:auth-worker
StandardOutput=append:/var/log/__APP__/auth-worker.log
StandardError=inherit

View file

@ -9,8 +9,8 @@ After=__APP__-syncing-server-js.service
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/live
EnvironmentFile=__FINALPATH__/live/auth.env
WorkingDirectory=__INSTALL_DIR__/live
EnvironmentFile=__INSTALL_DIR__/live/auth.env
ExecStart=/usr/bin/yarn start:auth
StandardOutput=append:/var/log/__APP__/auth.log
StandardError=inherit

View file

@ -9,8 +9,8 @@ After=__APP__-syncing-server.service
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/live
EnvironmentFile=__FINALPATH__/live/files.env
WorkingDirectory=__INSTALL_DIR__/live
EnvironmentFile=__INSTALL_DIR__/live/files.env
ExecStart=/usr/bin/yarn start:files
StandardOutput=append:/var/log/__APP__/files.log
StandardError=inherit

View file

@ -9,8 +9,8 @@ After=__APP__-syncing-server.service
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/live
EnvironmentFile=__FINALPATH__/live/syncing-server-worker.env
WorkingDirectory=__INSTALL_DIR__/live
EnvironmentFile=__INSTALL_DIR__/live/syncing-server-worker.env
ExecStart=/usr/bin/yarn start:syncing-server-worker
StandardOutput=append:/var/log/__APP__/syncing-server-worker.log
StandardError=inherit

View file

@ -8,8 +8,8 @@ After=redis.service
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/live
EnvironmentFile=__FINALPATH__/live/syncing-server.env
WorkingDirectory=__INSTALL_DIR__/live
EnvironmentFile=__INSTALL_DIR__/live/syncing-server.env
ExecStart=/usr/bin/yarn start:syncing-server
StandardOutput=append:/var/log/__APP__/syncing-server.log
StandardError=inherit

View file

@ -7,8 +7,8 @@ After=__APP__-auth.service
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/live/
EnvironmentFile=__FINALPATH__/live/workspace.env
WorkingDirectory=__INSTALL_DIR__/live/
EnvironmentFile=__INSTALL_DIR__/live/workspace.env
ExecStart=/usr/bin/yarn start:workspace
StandardOutput=append:/var/log/__APP__/workspace.log
StandardError=inherit

View file

@ -1,3 +0,0 @@
* No single-sign on or LDAP integration
* Ram requirements ( 4GB swap memory will be created during install ):
* Configuration can be changed under: https://my_domain.tld/yunohost/admin/#/apps/$app_id/config-panel

View file

@ -1,3 +0,0 @@
* Pas d'authentification unique ou d'intégration LDAP.
* Besoins en mémoire vive (4 Go de mémoire swap seront créés pendant l'installation) :
* La configuration peut être modifiée sous : https://my_domain.tld/yunohost/admin/#/apps/$app_id/config-panel

1
doc/PRE_INSTALL.md Normal file
View file

@ -0,0 +1 @@
* 4GB swap memory will be created during install

1
doc/PRE_INSTALL_fr.md Normal file
View file

@ -0,0 +1 @@
* 4 Go de mémoire swap seront créés pendant l'installation

View file

@ -1,45 +0,0 @@
{
"name": "Standard Notes Server",
"id": "snserver",
"packaging_format": 1,
"description": {
"en": "The Standard Notes syncing server. An end-to-end encrypted note-taking app."
},
"version": "2023.01.26~ynh1",
"url": "https://github.com/standardnotes/standalone",
"upstream": {
"license": "AGPL-3.0-or-later",
"website": "https://standardnotes.org/",
"demo": "https://standardnotes.org/demo",
"admindoc": "https://docs.standardnotes.org/",
"userdoc": "https://standardnotes.com/help",
"code": "https://github.com/standardnotes/server"
},
"license": "AGPL-3.0-or-later",
"maintainer": {
"name": "Fabian Wilkens",
"email": "46000361+FabianWilkens@users.noreply.github.com"
},
"requirements": {
"yunohost": ">= 11.2.12"
},
"multi_instance": true,
"services": [
"nginx",
"mysql"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/example",
"default": "/"
}
]
}
}

84
manifest.toml Normal file
View file

@ -0,0 +1,84 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "snserver"
name = "Standard Notes Server"
description.en = "End-to-end encrypted note-taking app syncing server"
description.fr = "Serveur de synchronisation de prise de notes cryptées de bout en bout"
version = "2023.01.26~ynh2"
maintainers = ["Fabian Wilkens"]
[upstream]
license = "AGPL-3.0-or-later"
website = "https://standardnotes.org"
demo = "https://standardnotes.org/demo"
admindoc = "https://docs.standardnotes.org"
userdoc = "https://standardnotes.com/help"
code = "https://github.com/standardnotes/server"
[integration]
yunohost = ">= 11.2.12"
architectures = "all"
multi_instance = true
ldap = false
sso = false
disk = "50M"
ram.build = "50M"
ram.runtime = "50M"
[install]
[install.domain]
type = "domain"
[install.path]
type = "path"
default = "/"
[install.init_main_permission]
type = "group"
default = "visitors"
[resources]
[resources.sources.main]
url = "https://github.com/standardnotes/server/archive/5ea91aeafc6c986391e6f4acc5cad20584a90828.tar.gz"
sha256 = "87d98db93233f88da30e5b89fa9df02bc0d2ee2ddadc9087a42b90987ec3c581"
autoupdate.strategy = "latest_github_release"
autoupdate.asset = "tarball"
[resources.system_user]
[resources.install_dir]
[resources.data_dir]
subdirs = ["uploads"]
[resources.permissions]
main.url = "/"
[resources.ports]
api_gateway.default = 3000
auth.default = 3001
auth_worker.default = 3002
files.default = 3003
syncing_server.default = 3004
syncing_server_worker.default = 3005
workspace.default = 3006
[resources.apt]
packages = [
"mariadb-server",
]
[resources.apt.extras.yarn]
repo = "deb https://dl.yarnpkg.com/debian/ stable main"
key = "https://dl.yarnpkg.com/debian/pubkey.gpg"
packages = "yarn"
[resources.database]
type = "mysql"

View file

@ -9,8 +9,13 @@ nodejs_version=16.13.1
swap_needed=4096
node_max_old_space_size=6144
# dependencies used by the app (must be on a single line)
pkg_dependencies=""
config_api_gateway="$install_dir/live/api-gateway.env"
config_auth="$install_dir/live/auth.env"
config_auth_worker="$install_dir/live/auth-worker.env"
config_files="$install_dir/live/files.env"
config_syncing_server="$install_dir/live/syncing-server.env"
config_syncing_server_worker="$install_dir/live/syncing-server-worker.env"
config_workspace="$install_dir/live/workspace.env"
#=================================================
# PERSONAL HELPERS

View file

@ -2,24 +2,18 @@
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# LOAD ENV FILE
#=================================================
if [ ! -f .env ]
then
export $(cat $final_path/cron.env | grep -v -E "^#" | xargs)
if [ ! -f .env ]; then
set -a
source "$install_dir/cron.env"
set +a
fi
FILE_UPLOAD_BYTES_PER_MB=1048576
FILE_UPLOAD_BYTES_LIMIT=$(($FILES_SIZE*$FILE_UPLOAD_BYTES_PER_MB))
FILE_UPLOAD_BYTES_LIMIT="$((FILES_SIZE * FILE_UPLOAD_BYTES_PER_MB))"
#=================================================
# ADD SUBSCRIPTION AND FILES SPACE TO ALL USERS
@ -28,11 +22,9 @@ FILE_UPLOAD_BYTES_LIMIT=$(($FILES_SIZE*$FILE_UPLOAD_BYTES_PER_MB))
ynh_script_progression --message="Add a subscription and $FILES_SIZE MB of file space to all users without a subscription"
# Searching for new users in the last 10 minutes without a Pro_Plan subscription.
mysql --password=$DB_PASSWORD --database=$DB_DATABASE <<< " \
mysql --password="$db_pwd" --database="$db_name" <<< " \
SELECT email FROM users WHERE NOT EXISTS( SELECT * FROM user_subscriptions WHERE user_subscriptions.plan_name = \"PRO_PLAN\" AND user_subscriptions.user_uuid = users.uuid ); \
" 2>/dev/null |
# Read through the piped result until it's empty.
" 2>/dev/null | \
while IFS='\n' read email; do
if [[ ${email} = "email" ]]; then
ynh_print_info --message="New users found:"
@ -40,14 +32,14 @@ while IFS='\n' read email; do
else
# ADD new user with Email $EMAIL a PRO_PLAN subscription
ynh_print_info --message="[$(date -Iseconds)] User: $email added to the PRO_PLAN subscription."
mysql --password=$DB_PASSWORD --database=$DB_DATABASE -e \
mysql --password="$db_pwd" --database="$db_name" -e \
"INSERT INTO user_roles (role_uuid , user_uuid) VALUES ((SELECT uuid FROM roles WHERE name=\"PRO_USER\" ORDER BY version DESC limit 1) ,(SELECT uuid FROM users WHERE email=\"$email\")) ON DUPLICATE KEY UPDATE role_uuid = VALUES(role_uuid);"
mysql --password=$DB_PASSWORD --database=$DB_DATABASE -e \
mysql --password="$db_pwd" --database="$db_name" -e \
"INSERT INTO user_subscriptions SET uuid=UUID(), plan_name=\"PRO_PLAN\", ends_at=8640000000000000, created_at=0, updated_at=0, user_uuid=(SELECT uuid FROM users WHERE email=\"$email\"), subscription_id=1, subscription_type=\"regular\";"
# Add new user Files space. Size is 1GB*$FILES_SIZE
ynh_print_info --message="[$(date -Iseconds)] User: $email added $FILES_SIZE MB of file spcae."
mysql --password=$DB_PASSWORD --database=$DB_DATABASE -e \
mysql --password="$db_pwd" --database="$db_name" -e \
"INSERT INTO subscription_settings(uuid, name, value, created_at, updated_at, user_subscription_uuid) VALUES (UUID(), \"FILE_UPLOAD_BYTES_LIMIT\", \"$FILE_UPLOAD_BYTES_LIMIT\", FLOOR(UNIX_TIMESTAMP(NOW(6))*1000000), FLOOR(UNIX_TIMESTAMP(NOW(6))*1000000), (SELECT us.uuid FROM user_subscriptions us INNER JOIN users u ON us.user_uuid=u.uuid WHERE u.email=\"$email\"));"
fi
done

View file

@ -10,28 +10,6 @@
source ../settings/scripts/_common.sh
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
#=================================================
@ -41,39 +19,20 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$datadir" --is_big
ynh_backup --src_path="$data_dir" --is_big
#=================================================
# BACKUP THE NGINX CONFIGURATION
# SYSTEM CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP FAIL2BAN CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app-api-gateway.service"
ynh_backup --src_path="/etc/systemd/system/$app-auth.service"
ynh_backup --src_path="/etc/systemd/system/$app-auth-worker.service"
@ -82,12 +41,15 @@ ynh_backup --src_path="/etc/systemd/system/$app-syncing-server.service"
ynh_backup --src_path="/etc/systemd/system/$app-syncing-server-worker.service"
ynh_backup --src_path="/etc/systemd/system/$app-workspace.service"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
ynh_backup --src_path="/etc/cron.d/$app"
ynh_backup --src_path="/var/log/$app/"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================

View file

@ -9,70 +9,6 @@
source _common.sh
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=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# 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
port_api_gateway=$(ynh_app_setting_get --app=$app --key=port_api_gateway)
port_auth=$(ynh_app_setting_get --app=$app --key=port_auth)
port_auth_worker=$(ynh_app_setting_get --app=$app --key=port_auth_worker)
port_files=$(ynh_app_setting_get --app=$app --key=port_files)
port_syncing_server=$(ynh_app_setting_get --app=$app --key=port_syncing_server)
port_syncing_server_worker=$(ynh_app_setting_get --app=$app --key=port_syncing_server_worker)
port_workspace=$(ynh_app_setting_get --app=$app --key=port_workspace)
config_api_gateway="$final_path/live/api-gateway.env"
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# 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
#=================================================
@ -81,29 +17,7 @@ fi
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# 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
ynh_change_url_nginx_config
#=================================================
# SPECIFIC MODIFICATIONS
@ -120,22 +34,9 @@ ynh_store_file_checksum --file="$config_api_gateway"
#=================================================
ynh_script_progression --message="Configuring Fail2Ban..." --weight=1
domain=$new_domain
path_url=$new_path
# Create a dedicated Fail2Ban config
touch "/var/log/$app/$app.log"
ynh_add_fail2ban_config --use_template
#=================================================
# GENERIC FINALISATION
#=================================================
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -10,38 +10,27 @@ source /usr/share/yunohost/helpers
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
app=$(ynh_app_setting_get $app id)
final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# SPECIFIC GETTERS FOR TOML SHORT KEY
#=================================================
get__disable_user_registration(){
disabled=$(ynh_read_var_in_file --file="$final_path/live/auth.env" --key="DISABLE_USER_REGISTRATION")
echo $disabled
disabled=$(ynh_read_var_in_file --file="$install_dir/live/auth.env" --key="DISABLE_USER_REGISTRATION")
echo "$disabled"
}
get__files_limit(){
limit=$(ynh_read_var_in_file --file="$final_path/cron.env" --key="FILES_SIZE")
echo $limit
limit=$(ynh_read_var_in_file --file="$install_dir/cron.env" --key="FILES_SIZE")
echo "$limit"
}
get__info(){
domain="$(cat /etc/yunohost/current_host)"
limit=$(ynh_read_var_in_file --file="$final_path/cron.env" --key="FILES_SIZE")
limit=$(ynh_read_var_in_file --file="$install_dir/cron.env" --key="FILES_SIZE")
link="https://$domain/yunohost/admin/#/apps/$app/actions"
cat << EOF
ask: "Add subscriptions:\nAdd a subscription and $limit MB of file space to all users without a subscription.\n$link"
EOF
}
#=================================================
@ -56,15 +45,15 @@ set__disable_user_registration(){
#---------------------------------------------
# IMPORTANT: setter are trigger only if a change is detected
#---------------------------------------------
if [ $disable_user_registration = "1" ]; then
if [ "$disable_user_registration" = "1" ]; then
disabled="true"
fi
if [ $disable_user_registration = "0" ]; then
if [ "$disable_user_registration" = "0" ]; then
disabled="false"
fi
config_auth="$final_path/live/auth.env"
config_auth_worker="$final_path/live/auth-worker.env"
config_auth="$install_dir/live/auth.env"
config_auth_worker="$install_dir/live/auth-worker.env"
ynh_write_var_in_file --file="$config_auth" --key="DISABLE_USER_REGISTRATION" --value="$disabled"
ynh_write_var_in_file --file="$config_auth_worker" --key="DISABLE_USER_REGISTRATION" --value="$disabled"
@ -93,7 +82,7 @@ set__files_limit(){
#---------------------------------------------
# IMPORTANT: setter are trigger only if a change is detected
#---------------------------------------------
config_cron="$final_path/cron.env"
config_cron="$install_dir/cron.env"
ynh_write_var_in_file --file="$config_cron" --key="FILES_SIZE" --value="$files_limit"

View file

@ -11,159 +11,43 @@ source ynh_add_swap
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
# INITIALIZE AND STORE SETTINGS
#=================================================
ynh_clean_setup () {
true
}
# 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=$YNH_APP_ARG_PATH
app=$YNH_APP_INSTANCE_NAME
redis_db=$(ynh_redis_get_free_db)
disable_user_registration=false
files_size=100
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/opt/yunohost/$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
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
ynh_app_setting_set --app="$app" --key=DISABLE_USER_REGISTRATION --value=$disable_user_registration
ynh_app_setting_set --app="$app" --key=FILES_SIZE --value=$files_size
#=================================================
# STORE SETTINGS FROM MANIFEST
# INSTALL NODEJS
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=3
ynh_script_progression --message="Installing NodeJS..." --weight=17
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=redis_db --value="$redis_db"
ynh_app_setting_set --app=$app --key=DISABLE_USER_REGISTRATION --value=$disable_user_registration
ynh_app_setting_set --app=$app --key=FILES_SIZE --value=$files_size
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=1
# Find an available port
port_api_gateway=$(ynh_find_port --port=3000)
port_auth=$(ynh_find_port --port=$((port_api_gateway+1)))
port_auth_worker=$(ynh_find_port --port=$((port_auth+1)))
port_files=$(ynh_find_port --port=$((port_auth_worker+1)))
port_syncing_server=$(ynh_find_port --port=$((port_files+1)))
port_syncing_server_worker=$(ynh_find_port --port=$((port_syncing_server+1)))
port_workspace=$(ynh_find_port --port=$((port_syncing_server_worker+1)))
ynh_app_setting_set --app=$app --key=port_api_gateway --value=$port_api_gateway
ynh_app_setting_set --app=$app --key=port_auth --value=$port_auth
ynh_app_setting_set --app=$app --key=port_auth_worker --value=$port_auth_worker
ynh_app_setting_set --app=$app --key=port_files --value=$port_files
ynh_app_setting_set --app=$app --key=port_syncing_server --value=$port_syncing_server
ynh_app_setting_set --app=$app --key=port_syncing_server_worker --value=$port_syncing_server_worker
ynh_app_setting_set --app=$app --key=port_workspace --value=$port_workspace
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=17
ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
ynh_script_progression --message="Creating a MySQL database..." --weight=2
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
ynh_install_nodejs --nodejs_version="$nodejs_version"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=2
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --source_id=app --dest_dir="$final_path/live"
cp "$YNH_APP_BASEDIR/sources/extra_files/cron.sh" "$final_path/cron.sh"
ynh_setup_source --dest_dir="$install_dir/live"
cp "$YNH_APP_BASEDIR/sources/extra_files/cron.sh" "$install_dir/cron.sh"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
chmod -R o-rwx "$install_dir"
chown -R "$app:$app" "$install_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=3
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# ADD SWAP
#=================================================
ynh_script_progression --message="Adding swap..."
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 0 ]; then
ynh_add_swap --size=$swap_needed
fi
#=================================================
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating a data directory..." --weight=1
datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
mkdir -p $datadir/uploads
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir"
chmod -R o-rwx "$data_dir"
chown -R "$app:$app" "$data_dir"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=2
config_api_gateway="$final_path/live/api-gateway.env"
config_auth="$final_path/live/auth.env"
config_auth_worker="$final_path/live/auth-worker.env"
config_files="$final_path/live/files.env"
config_syncing_server="$final_path/live/syncing-server.env"
config_syncing_server_worker="$final_path/live/syncing-server-worker.env"
config_workspace="$final_path/live/workspace.env"
ynh_script_progression --message="Adding configuration files..." --weight=2
jwt_secret=$(ynh_string_random --length=48 | base64)
legacy_jwt_secret=$(ynh_string_random --length=48 | base64)
@ -187,21 +71,26 @@ ynh_add_config --template="env_syncing-server.env.sample" --destination="$config
ynh_add_config --template="env_syncing-server-worker.env.sample" --destination="$config_syncing_server_worker"
ynh_add_config --template="env_workspace.env.sample" --destination="$config_workspace"
ynh_add_config --template="cron.env" --destination="$install_dir/cron.env"
#=================================================
# INSTALLING Standard Notes - Syncing Server
#=================================================
ynh_script_progression --message="Installing Standard Notes - Syncing Server..." --weight=93
ynh_script_progression --message="Building Standard Notes - Syncing Server..." --weight=93
ynh_use_nodejs
pushd "$final_path/live"
ynh_exec_warn_less ynh_exec_as $app env NODE_ENV="production" NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" $ynh_node_load_PATH yarn install --immutable
ynh_exec_warn_less ynh_exec_as $app env NODE_ENV="production" NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" $ynh_node_load_PATH yarn build
pushd "$install_dir/live"
ynh_exec_warn_less ynh_exec_as "$app" env NODE_ENV="production" NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" "$ynh_node_load_PATH" yarn install --immutable
ynh_exec_warn_less ynh_exec_as "$app" env NODE_ENV="production" NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" "$ynh_node_load_PATH" yarn build
popd
#=================================================
# SETUP SYSTEMD
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=4
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config --service="$app-api-gateway" --template="systemd_api-gateway.service"
@ -212,26 +101,13 @@ ynh_add_systemd_config --service="$app-syncing-server" --template="systemd_synci
ynh_add_systemd_config --service="$app-syncing-server-worker" --template="systemd_syncing-server-worker.service"
ynh_add_systemd_config --service="$app-workspace" --template="systemd_workspace.service"
#=================================================
# SETUP A CRON
#=================================================
ynh_script_progression --message="Setup a cron..."
ynh_add_config --template="../conf/cron.env" --destination="$final_path/cron.env"
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 640 "/etc/cron.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
mkdir -p "/var/log/$app"
chown -R "$app": "/var/log/$app"
yunohost service add "$app-api-gateway" --description="Standard Notes - API Gateway" --log="/var/log/$app/api-gateway.log"
yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log"
yunohost service add "$app-auth-worker" --description="Standard Notes - Auth - Worker" --log="/var/log/$app/auth-worker.log"
yunohost service add "$app-files" --description="Standard Notes - Files" --log="/var/log/$app/files.log"
yunohost service add "$app-syncing-server" --description="Standard Notes - Syncing Server" --log="/var/log/$app/syncing-server.log"
yunohost service add "$app-syncing-server-worker" --description="Standard Notes - Syncing Server - Worker" --log="/var/log/$app/syncing-server-worker.log"
yunohost service add "$app-workspace" --description="Standard Notes - Workspace" --log="/var/log/$app/workspace.log"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile="/var/log/$app/api-gateway.log"
@ -242,23 +118,21 @@ ynh_use_logrotate --logfile="/var/log/$app/syncing-server.log"
ynh_use_logrotate --logfile="/var/log/$app/syncing-server-worker.log"
ynh_use_logrotate --logfile="/var/log/$app/workspace.log"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --use_template
yunohost service add "$app-api-gateway" --description="Standard Notes - API Gateway" --log="/var/log/$app/api-gateway.log"
yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log"
yunohost service add "$app-auth-worker" --description="Standard Notes - Auth - Worker" --log="/var/log/$app/auth-worker.log"
yunohost service add "$app-files" --description="Standard Notes - Files" --log="/var/log/$app/files.log"
yunohost service add "$app-syncing-server" --description="Standard Notes - Syncing Server" --log="/var/log/$app/syncing-server.log"
yunohost service add "$app-syncing-server-worker" --description="Standard Notes - Syncing Server - Worker" --log="/var/log/$app/syncing-server-worker.log"
yunohost service add "$app-workspace" --description="Standard Notes - Workspace" --log="/var/log/$app/workspace.log"
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
chmod 640 "/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
if [ "${PACKAGE_CHECK_EXEC:-0}" -eq 0 ]; then
ynh_add_swap --size="$swap_needed"
fi
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression --message="Starting systemd services..." --weight=1
# Start a systemd service
ynh_systemd_action \
@ -297,30 +171,6 @@ ynh_systemd_action \
--log_path="/var/log/$app/workspace.log" \
--line_match='^.*Server started on port.*$|^.*Starting worker.*$'
#=================================================
# SETUP FAIL2BAN
#=================================================
ynh_script_progression --message="Configuring Fail2Ban..." --weight=1
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --use_template
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=3
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors" --show_tile="false"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -11,73 +11,40 @@ source ynh_add_swap
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port_api_gateway=$(ynh_app_setting_get --app=$app --key=port_api_gateway)
port_auth=$(ynh_app_setting_get --app=$app --key=port_auth)
port_auth_worker=$(ynh_app_setting_get --app=$app --key=port_auth_worker)
port_files=$(ynh_app_setting_get --app=$app --key=port_files)
port_syncing_server=$(ynh_app_setting_get --app=$app --key=port_syncing_server)
port_syncing_server_worker=$(ynh_app_setting_get --app=$app --key=port_syncing_server_worker)
port_workspace=$(ynh_app_setting_get --app=$app --key=port_workspace)
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
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# 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-api-gateway" >/dev/null
then
if ynh_exec_warn_less yunohost service status "$app-api-gateway" >/dev/null; then
ynh_script_progression --message="Removing $app-api-gateway service..." --weight=1
yunohost service remove "$app-api-gateway"
fi
if ynh_exec_warn_less yunohost service status "$app-auth" >/dev/null
then
if ynh_exec_warn_less yunohost service status "$app-auth" >/dev/null; then
ynh_script_progression --message="Removing $app-auth service..." --weight=1
yunohost service remove "$app-auth"
fi
if ynh_exec_warn_less yunohost service status "$app-auth-worker" >/dev/null
then
if ynh_exec_warn_less yunohost service status "$app-auth-worker" >/dev/null; then
ynh_script_progression --message="Removing $app-auth-worker service..." --weight=1
yunohost service remove "$app-auth-worker"
fi
if ynh_exec_warn_less yunohost service status "$app-files" >/dev/null
then
if ynh_exec_warn_less yunohost service status "$app-files" >/dev/null; then
ynh_script_progression --message="Removing $app-files service..." --weight=1
yunohost service remove "$app-files"
fi
if ynh_exec_warn_less yunohost service status "$app-syncing-server" >/dev/null
then
if ynh_exec_warn_less yunohost service status "$app-syncing-server" >/dev/null; then
ynh_script_progression --message="Removing $app-syncing-server service..." --weight=1
yunohost service remove "$app-syncing-server"
fi
if ynh_exec_warn_less yunohost service status "$app-syncing-server-worker" >/dev/null
then
if ynh_exec_warn_less yunohost service status "$app-syncing-server-worker" >/dev/null; then
ynh_script_progression --message="Removing $app-syncing-server-worker service..." --weight=1
yunohost service remove "$app-syncing-server-worker"
fi
if ynh_exec_warn_less yunohost service status "$app-workspace" >/dev/null
then
if ynh_exec_warn_less yunohost service status "$app-workspace" >/dev/null; then
ynh_script_progression --message="Removing $app-workspace service..." --weight=1
yunohost service remove "$app-workspace"
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove the dedicated systemd config
ynh_remove_systemd_config --service="$app-api-gateway"
ynh_remove_systemd_config --service="$app-auth"
@ -89,73 +56,24 @@ ynh_remove_systemd_config --service="$app-workspace"
ynh_reset_systemd
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Removing the MySQL database..." --weight=1
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE REDIS DB
#=================================================
ynh_script_progression --message="Removing the Redis database..." --weight=1
ynh_redis_remove_db
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=1
# 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..." --weight=1
ynh_secure_remove --file="$datadir"
fi
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=10
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
ynh_remove_nodejs
#=================================================
# REMOVE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=1
# Remove the dedicated Fail2Ban config
ynh_remove_fail2ban_config
#=================================================
# REMOVE NODEJS
#=================================================
ynh_script_progression --message="Removing NodeJS..." --weight=10
ynh_remove_nodejs
#=================================================
# SPECIFIC REMOVE
#=================================================
@ -178,16 +96,6 @@ if [ ${PACKAGE_CHECK_EXEC:-0} -eq 0 ]; then
ynh_del_swap
fi
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -11,142 +11,85 @@ source ../settings/scripts/_common.sh
source ../settings/scripts/ynh_add_swap
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_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME
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)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db"
config_api_gateway="$final_path/live/api-gateway.env"
config_auth="$final_path/live/auth.env"
config_auth_worker="$final_path/live/auth-worker.env"
config_files="$final_path/live/files.env"
config_syncing_server="$final_path/live/syncing-server.env"
config_syncing_server_worker="$final_path/live/syncing-server-worker.env"
config_workspace="$final_path/live/workspace.env"
config_nginx="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=2
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=1
# Find an available port
port_api_gateway=$(ynh_find_port --port=3000)
port_auth=$(ynh_find_port --port=$((port_api_gateway+1)))
port_auth_worker=$(ynh_find_port --port=$((port_auth+1)))
port_files=$(ynh_find_port --port=$((port_auth_worker+1)))
port_syncing_server=$(ynh_find_port --port=$((port_files+1)))
port_syncing_server_worker=$(ynh_find_port --port=$((port_syncing_server+1)))
port_workspace=$(ynh_find_port --port=$((port_syncing_server_worker+1)))
ynh_app_setting_set --app=$app --key=port_api_gateway --value=$port_api_gateway
ynh_app_setting_set --app=$app --key=port_auth --value=$port_auth
ynh_app_setting_set --app=$app --key=port_auth_worker --value=$port_auth_worker
ynh_app_setting_set --app=$app --key=port_files --value=$port_files
ynh_app_setting_set --app=$app --key=port_syncing_server --value=$port_syncing_server
ynh_app_setting_set --app=$app --key=port_syncing_server_worker --value=$port_syncing_server_worker
ynh_app_setting_set --app=$app --key=port_workspace --value=$port_workspace
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
chown -R "$app:$app" "$install_dir"
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="$datadir" --not_mandatory
ynh_restore_file --origin_path="$data_dir" --not_mandatory
mkdir -p "$datadir/uploads"
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir"
#=================================================
# RESTORE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=1
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=17
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
chown -R "$app:$app" "$data_dir"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=2
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app-api-gateway.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-auth.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-auth-worker.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-files.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-syncing-server.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-syncing-server-worker.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-workspace.service"
systemctl enable "$app-api-gateway.service" --quiet
systemctl enable "$app-auth.service" --quiet
systemctl enable "$app-auth-worker.service" --quiet
systemctl enable "$app-files.service" --quiet
systemctl enable "$app-syncing-server.service" --quiet
systemctl enable "$app-syncing-server-worker.service" --quiet
systemctl enable "$app-workspace.service" --quiet
yunohost service add "$app-api-gateway" --description="Standard Notes - API Gateway" --log="/var/log/$app/api-gateway.log"
yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log"
yunohost service add "$app-auth-worker" --description="Standard Notes - Auth - Worker" --log="/var/log/$app/auth-worker.log"
yunohost service add "$app-files" --description="Standard Notes - Files" --log="/var/log/$app/files.log"
yunohost service add "$app-syncing-server" --description="Standard Notes - Syncing Server" --log="/var/log/$app/syncing-server.log"
yunohost service add "$app-syncing-server-worker" --description="Standard Notes - Syncing Server - Worker" --log="/var/log/$app/syncing-server-worker.log"
yunohost service add "$app-workspace" --description="Standard Notes - Workspace" --log="/var/log/$app/workspace.log"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban
ynh_restore_file --origin_path="/etc/cron.d/$app"
ynh_restore_file --origin_path="/var/log/$app/"
if [ "${PACKAGE_CHECK_EXEC:-0}" -eq 0 ]; then
ynh_add_swap --size="$swap_needed"
fi
#=================================================
# REINSTALL NODEJS
#=================================================
ynh_script_progression --message="Reinstalling NodeJS..." --weight=17
ynh_install_nodejs --nodejs_version="$nodejs_version"
#=================================================
# MODIFY CONFIG
@ -177,78 +120,20 @@ ynh_replace_string --match_string="^AUTH_SERVER_URL.*$" --replace_string="AUTH_S
ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_auth_worker" --target_file="$config_auth_worker"
# API-Gateway Port
ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_api_gateway" --target_file="$config_api_gateway"
ynh_replace_string_on_line --line="2" --match_string="proxy_pass.*$" --replace_string="proxy_pass http://127.0.0.1:$port_api_gateway/;" --target_file="$config_nginx"
ynh_replace_string_on_line --line="2" --match_string="proxy_pass.*$" --replace_string="proxy_pass http://127.0.0.1:$port_api_gateway/;" --target_file="/etc/nginx/conf.d/$domain.d/$app.conf"
# Files Port
ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_files" --target_file="$config_files"
ynh_replace_string_on_line --line="17" --match_string="proxy_pass.*$" --replace_string="proxy_pass http://127.0.0.1:$port_files/;" --target_file="$config_nginx"
ynh_replace_string_on_line --line="17" --match_string="proxy_pass.*$" --replace_string="proxy_pass http://127.0.0.1:$port_files/;" --target_file="/etc/nginx/conf.d/$domain.d/$app.conf"
# Workspace Port
ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_workspace" --target_file="$config_workspace"
ynh_replace_string --match_string="^WORKSPACE_SERVER_URL.*$" --replace_string="WORKSPACE_SERVER_URL=http://localhost:$port_workspace" --target_file="$config_api_gateway"
#=================================================
# RESTORE VARIOUS FILES
# GENERIC FINALIZATION
#=================================================
ynh_script_progression --message="Restoring various files..." --weight=1
ynh_restore_file --origin_path="/etc/cron.d/$app"
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#=================================================
# ADD SWAP
#=================================================
ynh_script_progression --message="Adding swap..."
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 0 ]; then
ynh_add_swap --size=$swap_needed
fi
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app-api-gateway.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-auth.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-auth-worker.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-files.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-syncing-server.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-syncing-server-worker.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-workspace.service"
systemctl enable $app-api-gateway.service --quiet
systemctl enable $app-auth.service --quiet
systemctl enable $app-auth-worker.service --quiet
systemctl enable $app-files.service --quiet
systemctl enable $app-syncing-server.service --quiet
systemctl enable $app-syncing-server-worker.service --quiet
systemctl enable $app-workspace.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
mkdir -p "/var/log/$app"
chown -R $app: "/var/log/$app"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add "$app-api-gateway" --description="Standard Notes - API Gateway" --log="/var/log/$app/api-gateway.log"
yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log"
yunohost service add "$app-auth-worker" --description="Standard Notes - Auth - Worker" --log="/var/log/$app/auth-worker.log"
yunohost service add "$app-files" --description="Standard Notes - Files" --log="/var/log/$app/files.log"
yunohost service add "$app-syncing-server" --description="Standard Notes - Syncing Server" --log="/var/log/$app/syncing-server.log"
yunohost service add "$app-syncing-server-worker" --description="Standard Notes - Syncing Server - Worker" --log="/var/log/$app/syncing-server-worker.log"
yunohost service add "$app-workspace" --description="Standard Notes - Workspace" --log="/var/log/$app/workspace.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression --message="Reloading NGINX web server and $app's services..." --weight=1
ynh_systemd_action \
--service_name="$app-api-gateway" \
@ -286,13 +171,6 @@ ynh_systemd_action \
--log_path="/var/log/$app/workspace.log" \
--line_match='^.*Server started on port.*$|^.*Starting worker.*$'
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
ynh_systemd_action --service_name=nginx --action=reload
#=================================================

View file

@ -10,78 +10,12 @@ source _common.sh
source ynh_add_swap
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
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)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
port_api_gateway=$(ynh_app_setting_get --app=$app --key=port_api_gateway)
port_auth=$(ynh_app_setting_get --app=$app --key=port_auth)
port_auth_worker=$(ynh_app_setting_get --app=$app --key=port_auth_worker)
port_files=$(ynh_app_setting_get --app=$app --key=port_files)
port_syncing_server=$(ynh_app_setting_get --app=$app --key=port_syncing_server)
port_syncing_server_worker=$(ynh_app_setting_get --app=$app --key=port_syncing_server_worker)
port_workspace=$(ynh_app_setting_get --app=$app --key=port_workspace)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
jwt_secret=$(ynh_app_setting_get --app=$app --key=jwt_secret)
legacy_jwt_secret=$(ynh_app_setting_get --app=$app --key=legacy_jwt_secret)
auth_jwt_secret=$(ynh_app_setting_get --app=$app --key=auth_jwt_secret)
pseudo_key_params_key=$(ynh_app_setting_get --app=$app --key=pseudo_key_params_key)
encryption_server_key=$(ynh_app_setting_get --app=$app --key=encryption_server_key)
valet_token_secret=$(ynh_app_setting_get --app=$app --key=valet_token_secret)
disable_user_registration=$(ynh_app_setting_get --app=$app --key=DISABLE_USER_REGISTRATION)
files_size=$(ynh_app_setting_get --app=$app --key=FILES_SIZE)
config_api_gateway="$final_path/live/api-gateway.env"
config_auth="$final_path/live/auth.env"
config_auth_worker="$final_path/live/auth-worker.env"
config_files="$final_path/live/files.env"
config_syncing_server="$final_path/live/syncing-server.env"
config_syncing_server_worker="$final_path/live/syncing-server-worker.env"
config_workspace="$final_path/live/workspace.env"
nodejs_version_installed=$(ynh_app_setting_get --app=$app --key=nodejs_version)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# 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
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_script_progression --message="Stopping systemd services..." --weight=1
ynh_systemd_action \
--service_name="$app-api-gateway" \
@ -117,207 +51,94 @@ ynh_systemd_action \
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
final_path=/opt/yunohost/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi
# If redis_db doesn't exist, create it
if [ -z "$redis_db" ]; then
redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db"
fi
# If one port_* doesn't exist, create all new
if [[ -z "$port_api_gateway" || \
-z "$port_auth" || \
-z "$port_auth_worker" || \
-z "$port_files" || \
-z "$port_syncing_server" || \
-z "$port_syncing_server_worker" || \
-z "$port_workspace" ]]; then
port_api_gateway=$(ynh_find_port --port=3000)
port_auth=$(ynh_find_port --port=$((port_api_gateway+1)))
port_auth_worker=$(ynh_find_port --port=$((port_auth+1)))
port_files=$(ynh_find_port --port=$((port_auth_worker+1)))
port_syncing_server=$(ynh_find_port --port=$((port_files+1)))
port_syncing_server_worker=$(ynh_find_port --port=$((port_syncing_server+1)))
port_workspace=$(ynh_find_port --port=$((port_syncing_server_worker+1)))
ynh_app_setting_set --app=$app --key=port_api_gateway --value=$port_api_gateway
ynh_app_setting_set --app=$app --key=port_auth --value=$port_auth
ynh_app_setting_set --app=$app --key=port_auth_worker --value=$port_auth_worker
ynh_app_setting_set --app=$app --key=port_files --value=$port_files
ynh_app_setting_set --app=$app --key=port_syncing_server --value=$port_syncing_server
ynh_app_setting_set --app=$app --key=port_syncing_server_worker --value=$port_syncing_server_worker
ynh_app_setting_set --app=$app --key=port_workspace --value=$port_workspace
fi
# If jwt_secret doesn't exist, create it
if [ -z "$jwt_secret" ]; then
# Create non existing settings
if [ -z "${jwt_secret:-}" ]; then
jwt_secret=$(ynh_string_random --length=48 | base64)
ynh_app_setting_set --app=$app --key=jwt_secret --value=$jwt_secret
ynh_app_setting_set --app="$app" --key=jwt_secret --value="$jwt_secret"
fi
# If legacy_jwt_secret doesn't exist, create it
if [ -z "$legacy_jwt_secret" ]; then
if [ -z "${legacy_jwt_secret:-}" ]; then
legacy_jwt_secret=$(ynh_string_random --length=48 | base64)
ynh_app_setting_set --app=$app --key=legacy_jwt_secret --value=$legacy_jwt_secret
ynh_app_setting_set --app="$app" --key=legacy_jwt_secret --value="$legacy_jwt_secret"
fi
# If auth_jwt_secret doesn't exist, create it
if [ -z "$auth_jwt_secret" ]; then
if [ -z "${auth_jwt_secret:-}" ]; then
auth_jwt_secret=$(ynh_string_random --length=48 | base64)
ynh_app_setting_set --app=$app --key=auth_jwt_secret --value=$auth_jwt_secret
ynh_app_setting_set --app="$app" --key=auth_jwt_secret --value="$auth_jwt_secret"
fi
# If pseudo_key_params_key doesn't exist, create it
if [ -z "$pseudo_key_params_key" ]; then
if [ -z "${pseudo_key_params_key:-}" ]; then
pseudo_key_params_key=$(ynh_string_random --length=48 | base64)
ynh_app_setting_set --app=$app --key=pseudo_key_params_key --value=$pseudo_key_params_key
ynh_app_setting_set --app="$app" --key=pseudo_key_params_key --value="$pseudo_key_params_key"
fi
# If encryption_server_key doesn't exist, create it
if [ -z "$encryption_server_key" ]; then
if [ -z "${encryption_server_key:-}" ]; then
encryption_server_key=$(hexdump -n 32 -e '4/4 "%08X"' /dev/random) # 32bytes hex key is required
ynh_app_setting_set --app=$app --key=encryption_server_key --value=$encryption_server_key
ynh_app_setting_set --app="$app" --key=encryption_server_key --value="$encryption_server_key"
fi
# If valet_token_secret doesn't exist, create it
if [ -z "$valet_token_secret" ]; then
if [ -z "${valet_token_secret:-}" ]; then
valet_token_secret=$(ynh_string_random --length=48 | base64)
ynh_app_setting_set --app=$app --key=valet_token_secret --value=$valet_token_secret
ynh_app_setting_set --app="$app" --key=valet_token_secret --value="$valet_token_secret"
fi
# If disable_user_registration doesn't exist, create it
if [ -z "$disable_user_registration" ]; then
if [ -z "${disable_user_registration:-}" ]; then
disable_user_registration=false
ynh_app_setting_set --app=$app --key=DISABLE_USER_REGISTRATION --value=$disable_user_registration
ynh_app_setting_set --app="$app" --key=DISABLE_USER_REGISTRATION --value="$disable_user_registration"
fi
# If files_zise doesn't exist, create it
if [ -z "$files_size" ]; then
if [ -z "${files_size:-}" ]; then
files_size=100
ynh_app_setting_set --app=$app --key=FILES_SIZE --value=$files_size
ynh_app_setting_set --app="$app" --key=FILES_SIZE --value="$files_size"
fi
# Remove old Settings, Services, Files, Dependencies
# If final_path_www exist, delete it
api_gateway_version_installed=$(ynh_app_setting_get --app=$app --key=api_gateway_version)
auth_version_installed=$(ynh_app_setting_get --app=$app --key=auth_version)
syncing_server_version_installed=$(ynh_app_setting_get --app=$app --key=syncing_server_version)
final_path_www=$(ynh_app_setting_get --app=$app --key=final_path_www)
final_path_extensions=$(ynh_app_setting_get --app=$app --key=final_path_extensions)
if [ -n ${api_gateway_version_installed+x} ]; then
ynh_app_setting_delete --app=$app --key=api_gateway_version_installed
# Delete legacy settings
if [ -n "${api_gateway_version_installed+x}" ]; then
ynh_app_setting_delete --app="$app" --key=api_gateway_version_installed
fi
if [ -n ${auth_version_installed+x} ]; then
ynh_app_setting_delete --app=$app --key=auth_version_installe
if [ -n "${auth_version_installed+x}" ]; then
ynh_app_setting_delete --app="$app" --key=auth_version_installe
fi
if [ -n ${syncing_server_version_installed+x} ]; then
ynh_app_setting_delete --app=$app --key=syncing_server_version_installed
if [ -n "${syncing_server_version_installed+x}" ]; then
ynh_app_setting_delete --app="$app" --key=syncing_server_version_installed
fi
if [ -n ${final_path_www+x} ]; then
ynh_app_setting_delete --app=$app --key=final_path_www
if [ -n "${install_dir_www+x}" ]; then
ynh_app_setting_delete --app="$app" --key=install_dir_www
fi
# If final_path_extensions exist, delete it
if [ -n ${final_path_extensions+x} ]; then
ynh_app_setting_delete --app=$app --key=final_path_extensions
fi
# If permission help exists, delete it
if ynh_permission_exists --permission="help"
then
ynh_permission_delete --permission="help"
if [ -n "${install_dir_extensions+x}" ]; then
ynh_app_setting_delete --app="$app" --key=install_dir_extensions
fi
# If old service exsits; remove it
if ynh_exec_warn_less yunohost service status "$app-syncing-server-js" >/dev/null
then
if ynh_exec_warn_less yunohost service status "$app-syncing-server-js" >/dev/null; then
ynh_script_progression --message="Removing old service..." --weight=1
yunohost service remove "$app-syncing-server-js"
ynh_remove_systemd_config --service="$app-syncing-server-js"
ynh_reset_systemd
fi
if ynh_exec_warn_less yunohost service status "$app-syncing-server-js-worker" >/dev/null
then
if ynh_exec_warn_less yunohost service status "$app-syncing-server-js-worker" >/dev/null; then
ynh_script_progression --message="Removing old service..." --weight=1
yunohost service remove "$app-syncing-server-js-worker"
ynh_remove_systemd_config --service="$app-syncing-server-js-worker"
ynh_reset_systemd
fi
# Remove unneeded data
if [ -e "/var/www/$app" ]; then
ynh_secure_remove --file="/var/www/$app"
fi
# If datadir doesn't exist, create it
# CREATE DATA DIRECTORY
if [ -z "$datadir" ]; then
datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
mkdir -p $datadir/uploads
chmod -R 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir"
fi
#=================================================
# CREATE DEDICATED USER
# UPGRADE NODEJS
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
ynh_script_progression --message="Upgrading NodeJS..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
ynh_install_nodejs --nodejs_version="$nodejs_version"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src
ynh_secure_remove --file="$final_path/live"
mkdir -p "$final_path/live"
ynh_setup_source --source_id=app --dest_dir="$final_path/live"
cp "$YNH_APP_BASEDIR/sources/extra_files/cron.sh" "$final_path/cron.sh"
ynh_setup_source --dest_dir="$install_dir/live" --full_replace=1
cp "$YNH_APP_BASEDIR/sources/extra_files/cron.sh" "$install_dir/cron.sh"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
fi
chmod -R o-rwx "$install_dir"
chown -R "$app:$app" "$install_dir"
#=================================================
# UPGRADE DEPENDENCIES
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
# ADD SWAP
#=================================================
ynh_script_progression --message="Adding swap..."
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 0 ]; then
ynh_add_swap --size=$swap_needed
fi
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=2
ynh_script_progression --message="Adding configuration files..." --weight=2
ynh_add_config --template="env_api-gateway.env.sample" --destination="$config_api_gateway"
ynh_add_config --template="env_auth.env.sample" --destination="$config_auth"
@ -327,23 +148,26 @@ ynh_add_config --template="env_syncing-server.env.sample" --destination="$config
ynh_add_config --template="env_syncing-server-worker.env.sample" --destination="$config_syncing_server_worker"
ynh_add_config --template="env_workspace.env.sample" --destination="$config_workspace"
ynh_add_config --template="cron.env" --destination="$install_dir/cron.env"
#=================================================
# INSTALLING Standard Notes - Syncing Server
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Installing Standard Notes - Syncing Server..." --weight=93
ynh_script_progression --message="Building Standard Notes - Syncing Server..." --weight=93
ynh_use_nodejs
pushd "$final_path/live"
ynh_exec_warn_less ynh_exec_as $app env NODE_ENV="production" NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" $ynh_node_load_PATH yarn install --immutable
ynh_exec_warn_less ynh_exec_as $app env NODE_ENV="production" NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" $ynh_node_load_PATH yarn build
pushd "$install_dir/live"
ynh_exec_warn_less ynh_exec_as "$app" env NODE_ENV="production" NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" "$ynh_node_load_PATH" yarn install --immutable
ynh_exec_warn_less ynh_exec_as "$app" env NODE_ENV="production" NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" "$ynh_node_load_PATH" yarn build
popd
fi
#=================================================
# SETUP SYSTEMD
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config --service="$app-api-gateway" --template="systemd_api-gateway.service"
@ -354,15 +178,13 @@ ynh_add_systemd_config --service="$app-syncing-server" --template="systemd_synci
ynh_add_systemd_config --service="$app-syncing-server-worker" --template="systemd_syncing-server-worker.service"
ynh_add_systemd_config --service="$app-workspace" --template="systemd_workspace.service"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
mkdir -p "/var/log/$app"
chown -R "$app": "/var/log/$app"
yunohost service add "$app-api-gateway" --description="Standard Notes - API Gateway" --log="/var/log/$app/api-gateway.log"
yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log"
yunohost service add "$app-auth-worker" --description="Standard Notes - Auth - Worker" --log="/var/log/$app/auth-worker.log"
yunohost service add "$app-files" --description="Standard Notes - Files" --log="/var/log/$app/files.log"
yunohost service add "$app-syncing-server" --description="Standard Notes - Syncing Server" --log="/var/log/$app/syncing-server.log"
yunohost service add "$app-syncing-server-worker" --description="Standard Notes - Syncing Server - Worker" --log="/var/log/$app/syncing-server-worker.log"
yunohost service add "$app-workspace" --description="Standard Notes - Workspace" --log="/var/log/$app/workspace.log"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile="/var/log/$app/api-gateway.log"
@ -373,23 +195,21 @@ ynh_use_logrotate --logfile="/var/log/$app/syncing-server.log"
ynh_use_logrotate --logfile="/var/log/$app/syncing-server-worker.log"
ynh_use_logrotate --logfile="/var/log/$app/workspace.log"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --use_template
yunohost service add "$app-api-gateway" --description="Standard Notes - API Gateway" --log="/var/log/$app/api-gateway.log"
yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log"
yunohost service add "$app-auth-worker" --description="Standard Notes - Auth - Worker" --log="/var/log/$app/auth-worker.log"
yunohost service add "$app-files" --description="Standard Notes - Files" --log="/var/log/$app/files.log"
yunohost service add "$app-syncing-server" --description="Standard Notes - Syncing Server" --log="/var/log/$app/syncing-server.log"
yunohost service add "$app-syncing-server-worker" --description="Standard Notes - Syncing Server - Worker" --log="/var/log/$app/syncing-server-worker.log"
yunohost service add "$app-workspace" --description="Standard Notes - Workspace" --log="/var/log/$app/workspace.log"
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 640 "/etc/cron.d/$app"
if [ "${PACKAGE_CHECK_EXEC:-0}" -eq 0 ]; then
ynh_add_swap --size="$swap_needed"
fi
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression --message="Starting systemd services..." --weight=1
# Start a systemd service
ynh_systemd_action \
@ -428,32 +248,6 @@ ynh_systemd_action \
--log_path="/var/log/$app/workspace.log" \
--line_match='^.*Server started on port.*$|^.*Starting worker.*$'
#=================================================
# SETUP A CRON
#=================================================
ynh_script_progression --message="Setup a cron..."
ynh_add_config --template="../conf/cron.env" --destination="$final_path/cron.env"
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 640 "/etc/cron.d/$app"
#=================================================
# UPGRADE FAIL2BAN
#=================================================
ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=1
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --use_template
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================

11
tests.toml Normal file
View file

@ -0,0 +1,11 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
test_format = 1.0
[default]
# ------------
# Tests to run
# ------------
test_upgrade_from.62b95a36.name = "2022.09.16~ynh1"