mirror of
https://github.com/YunoHost-Apps/snserver_ynh.git
synced 2024-09-03 20:26:22 +02:00
manifest v2
This commit is contained in:
parent
40d2cf5fed
commit
eddf934549
28 changed files with 471 additions and 1022 deletions
118
.github/workflows/updater.sh
vendored
118
.github/workflows/updater.sh
vendored
|
@ -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
|
|
49
.github/workflows/updater.yml
vendored
49
.github/workflows/updater.yml
vendored
|
@ -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
|
|
|
@ -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
|
|
|
@ -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
|
|
|
@ -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
|
||||||
|
|
|
@ -34,4 +34,4 @@ SQS_QUEUE_URL=
|
||||||
SQS_AWS_REGION=
|
SQS_AWS_REGION=
|
||||||
|
|
||||||
# (Optional) File upload path (relative to root directory)
|
# (Optional) File upload path (relative to root directory)
|
||||||
FILE_UPLOAD_PATH=__DATADIR__/uploads/
|
FILE_UPLOAD_PATH=__DATA_DIR__/uploads/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[INCLUDES]
|
[INCLUDES]
|
||||||
before = common.conf
|
before = common.conf
|
||||||
[Definition]
|
[Definition]
|
||||||
failregex = <HOST> .* .POST __PATH_URL__.*auth/sign_in HTTP/.... 401
|
failregex = <HOST> .* .POST __PATH__.*auth/sign_in HTTP/.... 401
|
||||||
ignoreregex =
|
ignoreregex =
|
||||||
datepattern = %%d/%%b/%%Y:%%H:%%M:%%S
|
datepattern = %%d/%%b/%%Y:%%H:%%M:%%S
|
||||||
|
|
|
@ -8,8 +8,8 @@ After=__APP__-auth.service
|
||||||
Type=simple
|
Type=simple
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__FINALPATH__/live/
|
WorkingDirectory=__INSTALL_DIR__/live/
|
||||||
EnvironmentFile=__FINALPATH__/live/api-gateway.env
|
EnvironmentFile=__INSTALL_DIR__/live/api-gateway.env
|
||||||
ExecStart=/usr/bin/yarn start:api-gateway
|
ExecStart=/usr/bin/yarn start:api-gateway
|
||||||
StandardOutput=append:/var/log/__APP__/api-gateway.log
|
StandardOutput=append:/var/log/__APP__/api-gateway.log
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
|
|
|
@ -9,8 +9,8 @@ After=__APP__-auth.service
|
||||||
Type=simple
|
Type=simple
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__FINALPATH__/live
|
WorkingDirectory=__INSTALL_DIR__/live
|
||||||
EnvironmentFile=__FINALPATH__/live/auth-worker.env
|
EnvironmentFile=__INSTALL_DIR__/live/auth-worker.env
|
||||||
ExecStart=/usr/bin/yarn start:auth-worker
|
ExecStart=/usr/bin/yarn start:auth-worker
|
||||||
StandardOutput=append:/var/log/__APP__/auth-worker.log
|
StandardOutput=append:/var/log/__APP__/auth-worker.log
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
|
|
|
@ -9,8 +9,8 @@ After=__APP__-syncing-server-js.service
|
||||||
Type=simple
|
Type=simple
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__FINALPATH__/live
|
WorkingDirectory=__INSTALL_DIR__/live
|
||||||
EnvironmentFile=__FINALPATH__/live/auth.env
|
EnvironmentFile=__INSTALL_DIR__/live/auth.env
|
||||||
ExecStart=/usr/bin/yarn start:auth
|
ExecStart=/usr/bin/yarn start:auth
|
||||||
StandardOutput=append:/var/log/__APP__/auth.log
|
StandardOutput=append:/var/log/__APP__/auth.log
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
|
|
|
@ -9,8 +9,8 @@ After=__APP__-syncing-server.service
|
||||||
Type=simple
|
Type=simple
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__FINALPATH__/live
|
WorkingDirectory=__INSTALL_DIR__/live
|
||||||
EnvironmentFile=__FINALPATH__/live/files.env
|
EnvironmentFile=__INSTALL_DIR__/live/files.env
|
||||||
ExecStart=/usr/bin/yarn start:files
|
ExecStart=/usr/bin/yarn start:files
|
||||||
StandardOutput=append:/var/log/__APP__/files.log
|
StandardOutput=append:/var/log/__APP__/files.log
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
|
|
|
@ -9,8 +9,8 @@ After=__APP__-syncing-server.service
|
||||||
Type=simple
|
Type=simple
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__FINALPATH__/live
|
WorkingDirectory=__INSTALL_DIR__/live
|
||||||
EnvironmentFile=__FINALPATH__/live/syncing-server-worker.env
|
EnvironmentFile=__INSTALL_DIR__/live/syncing-server-worker.env
|
||||||
ExecStart=/usr/bin/yarn start:syncing-server-worker
|
ExecStart=/usr/bin/yarn start:syncing-server-worker
|
||||||
StandardOutput=append:/var/log/__APP__/syncing-server-worker.log
|
StandardOutput=append:/var/log/__APP__/syncing-server-worker.log
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
|
|
|
@ -8,8 +8,8 @@ After=redis.service
|
||||||
Type=simple
|
Type=simple
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__FINALPATH__/live
|
WorkingDirectory=__INSTALL_DIR__/live
|
||||||
EnvironmentFile=__FINALPATH__/live/syncing-server.env
|
EnvironmentFile=__INSTALL_DIR__/live/syncing-server.env
|
||||||
ExecStart=/usr/bin/yarn start:syncing-server
|
ExecStart=/usr/bin/yarn start:syncing-server
|
||||||
StandardOutput=append:/var/log/__APP__/syncing-server.log
|
StandardOutput=append:/var/log/__APP__/syncing-server.log
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
|
|
|
@ -7,8 +7,8 @@ After=__APP__-auth.service
|
||||||
Type=simple
|
Type=simple
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__FINALPATH__/live/
|
WorkingDirectory=__INSTALL_DIR__/live/
|
||||||
EnvironmentFile=__FINALPATH__/live/workspace.env
|
EnvironmentFile=__INSTALL_DIR__/live/workspace.env
|
||||||
ExecStart=/usr/bin/yarn start:workspace
|
ExecStart=/usr/bin/yarn start:workspace
|
||||||
StandardOutput=append:/var/log/__APP__/workspace.log
|
StandardOutput=append:/var/log/__APP__/workspace.log
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
|
|
|
@ -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
|
|
|
@ -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
1
doc/PRE_INSTALL.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
* 4GB swap memory will be created during install
|
1
doc/PRE_INSTALL_fr.md
Normal file
1
doc/PRE_INSTALL_fr.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
* 4 Go de mémoire swap seront créés pendant l'installation
|
|
@ -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": "/"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
72
manifest.toml
Normal file
72
manifest.toml
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
|
||||||
|
|
||||||
|
packaging_format = 2
|
||||||
|
|
||||||
|
id = "snserver"
|
||||||
|
name = "Standard Notes Server"
|
||||||
|
description.en = "The Standard Notes syncing server. An end-to-end encrypted note-taking app."
|
||||||
|
|
||||||
|
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" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
|
||||||
|
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
|
||||||
|
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
|
||||||
|
|
||||||
|
[install]
|
||||||
|
[install.domain]
|
||||||
|
type = "domain"
|
||||||
|
|
||||||
|
[install.path]
|
||||||
|
type = "path"
|
||||||
|
default = "/"
|
||||||
|
|
||||||
|
[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]
|
||||||
|
[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"
|
|
@ -9,8 +9,6 @@ nodejs_version=16.13.1
|
||||||
swap_needed=4096
|
swap_needed=4096
|
||||||
node_max_old_space_size=6144
|
node_max_old_space_size=6144
|
||||||
|
|
||||||
# dependencies used by the app (must be on a single line)
|
|
||||||
pkg_dependencies=""
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
|
|
|
@ -10,28 +10,6 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# MANAGE SCRIPT FAILURE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_clean_setup () {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info --message="Loading installation settings..."
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -41,39 +19,20 @@ ynh_print_info --message="Declaring files to be backed up..."
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$final_path"
|
ynh_backup --src_path="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE DATA DIR
|
# BACKUP THE DATA DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$datadir" --is_big
|
ynh_backup --src_path="$data_dir" --is_big
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# SYSTEM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
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-api-gateway.service"
|
||||||
ynh_backup --src_path="/etc/systemd/system/$app-auth.service"
|
ynh_backup --src_path="/etc/systemd/system/$app-auth.service"
|
||||||
ynh_backup --src_path="/etc/systemd/system/$app-auth-worker.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-syncing-server-worker.service"
|
||||||
ynh_backup --src_path="/etc/systemd/system/$app-workspace.service"
|
ynh_backup --src_path="/etc/systemd/system/$app-workspace.service"
|
||||||
|
|
||||||
#=================================================
|
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||||
# BACKUP VARIOUS FILES
|
|
||||||
#=================================================
|
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="/etc/cron.d/$app"
|
||||||
|
|
||||||
|
ynh_backup --src_path="/var/log/$app/"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE MYSQL DATABASE
|
# BACKUP THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -13,64 +13,64 @@ source /usr/share/yunohost/helpers
|
||||||
# RETRIEVE ARGUMENTS
|
# RETRIEVE ARGUMENTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
old_domain=$YNH_APP_OLD_DOMAIN
|
#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
|
||||||
old_path=$YNH_APP_OLD_PATH
|
#REMOVEME? old_path=$YNH_APP_OLD_PATH
|
||||||
|
|
||||||
new_domain=$YNH_APP_NEW_DOMAIN
|
#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
|
||||||
new_path=$YNH_APP_NEW_PATH
|
#REMOVEME? new_path=$YNH_APP_NEW_PATH
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
# Needed for helper "ynh_add_nginx_config"
|
#REMOVEME? # Needed for helper "ynh_add_nginx_config"
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
|
|
||||||
# Add settings here as needed by your application
|
# Add settings here as needed by your application
|
||||||
port_api_gateway=$(ynh_app_setting_get --app=$app --key=port_api_gateway)
|
#REMOVEME? port_api_gateway=$(ynh_app_setting_get --app=$app --key=port_api_gateway)
|
||||||
port_auth=$(ynh_app_setting_get --app=$app --key=port_auth)
|
#REMOVEME? port_auth=$(ynh_app_setting_get --app=$app --key=port_auth)
|
||||||
port_auth_worker=$(ynh_app_setting_get --app=$app --key=port_auth_worker)
|
#REMOVEME? port_auth_worker=$(ynh_app_setting_get --app=$app --key=port_auth_worker)
|
||||||
port_files=$(ynh_app_setting_get --app=$app --key=port_files)
|
#REMOVEME? port_files=$(ynh_app_setting_get --app=$app --key=port_files)
|
||||||
port_syncing_server=$(ynh_app_setting_get --app=$app --key=port_syncing_server)
|
#REMOVEME? 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)
|
#REMOVEME? 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)
|
#REMOVEME? port_workspace=$(ynh_app_setting_get --app=$app --key=port_workspace)
|
||||||
|
|
||||||
config_api_gateway="$final_path/live/api-gateway.env"
|
config_api_gateway="$install_dir/live/api-gateway.env"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
# 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
|
#REMOVEME? 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
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
#REMOVEME? ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
#REMOVEME? ynh_clean_setup () {
|
||||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
# 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"
|
#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
|
|
||||||
# Restore it if the upgrade fails
|
# Restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
#REMOVEME? ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
change_domain=0
|
#REMOVEME? change_domain=0
|
||||||
if [ "$old_domain" != "$new_domain" ]
|
#REMOVEME? if [ "$old_domain" != "$new_domain" ]
|
||||||
then
|
then
|
||||||
change_domain=1
|
#REMOVEME? change_domain=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
change_path=0
|
#REMOVEME? change_path=0
|
||||||
if [ "$old_path" != "$new_path" ]
|
#REMOVEME? if [ "$old_path" != "$new_path" ]
|
||||||
then
|
then
|
||||||
change_path=1
|
#REMOVEME? change_path=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -81,28 +81,30 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
|
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
|
||||||
|
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
ynh_change_url_nginx_config
|
||||||
|
|
||||||
|
#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
|
|
||||||
# Change the path in the NGINX config file
|
# Change the path in the NGINX config file
|
||||||
if [ $change_path -eq 1 ]
|
if [ $change_path -eq 1 ]
|
||||||
then
|
then
|
||||||
# Make a backup of the original NGINX config file if modified
|
# Make a backup of the original NGINX config file if modified
|
||||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||||
# Set global variables for NGINX helper
|
# Set global variables for NGINX helper
|
||||||
domain="$old_domain"
|
#REMOVEME? domain="$old_domain"
|
||||||
path_url="$new_path"
|
#REMOVEME? path="$new_path"
|
||||||
# Create a dedicated NGINX config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
#REMOVEME? ynh_add_nginx_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change the domain for NGINX
|
# Change the domain for NGINX
|
||||||
if [ $change_domain -eq 1 ]
|
if [ $change_domain -eq 1 ]
|
||||||
then
|
then
|
||||||
# Delete file checksum for the old conf file location
|
# Delete file checksum for the old conf file location
|
||||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||||
# Store file checksum for the new config file location
|
# Store file checksum for the new config file location
|
||||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -119,9 +121,9 @@ ynh_store_file_checksum --file="$config_api_gateway"
|
||||||
# SETUP FAIL2BAN
|
# SETUP FAIL2BAN
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring Fail2Ban..." --weight=1
|
ynh_script_progression --message="Configuring Fail2Ban..." --weight=1
|
||||||
|
#REMOVEME?
|
||||||
domain=$new_domain
|
domain=$new_domain
|
||||||
path_url=$new_path
|
path=$new_path
|
||||||
# Create a dedicated Fail2Ban config
|
# Create a dedicated Fail2Ban config
|
||||||
touch "/var/log/$app/$app.log"
|
touch "/var/log/$app/$app.log"
|
||||||
ynh_add_fail2ban_config --use_template
|
ynh_add_fail2ban_config --use_template
|
||||||
|
@ -132,9 +134,9 @@ ynh_add_fail2ban_config --use_template
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
242
scripts/install
242
scripts/install
|
@ -11,159 +11,51 @@ source ynh_add_swap
|
||||||
source /usr/share/yunohost/helpers
|
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)
|
redis_db=$(ynh_redis_get_free_db)
|
||||||
disable_user_registration=false
|
disable_user_registration=false
|
||||||
files_size=100
|
files_size=100
|
||||||
|
|
||||||
#=================================================
|
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
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
|
||||||
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
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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_install_nodejs --nodejs_version="$nodejs_version"
|
||||||
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
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setting up source files..." --weight=2
|
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
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --source_id=app --dest_dir="$final_path/live"
|
ynh_setup_source --dest_dir="$install_dir/live"
|
||||||
cp "$YNH_APP_BASEDIR/sources/extra_files/cron.sh" "$final_path/cron.sh"
|
cp "$YNH_APP_BASEDIR/sources/extra_files/cron.sh" "$install_dir/cron.sh"
|
||||||
|
|
||||||
chmod 750 "$final_path"
|
chmod -R o-rwx "$install_dir"
|
||||||
chmod -R o-rwx "$final_path"
|
chown -R "$app:$app" "$install_dir"
|
||||||
chown -R $app:$app "$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
chmod -R o-rwx "$data_dir"
|
||||||
# NGINX CONFIGURATION
|
chown -R "$app:$app" "$data_dir"
|
||||||
#=================================================
|
|
||||||
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"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD A CONFIGURATION
|
# ADD A CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding a configuration file..." --weight=2
|
ynh_script_progression --message="Adding configuration files..." --weight=2
|
||||||
|
|
||||||
config_api_gateway="$final_path/live/api-gateway.env"
|
config_api_gateway="$install_dir/live/api-gateway.env"
|
||||||
config_auth="$final_path/live/auth.env"
|
config_auth="$install_dir/live/auth.env"
|
||||||
config_auth_worker="$final_path/live/auth-worker.env"
|
config_auth_worker="$install_dir/live/auth-worker.env"
|
||||||
config_files="$final_path/live/files.env"
|
config_files="$install_dir/live/files.env"
|
||||||
config_syncing_server="$final_path/live/syncing-server.env"
|
config_syncing_server="$install_dir/live/syncing-server.env"
|
||||||
config_syncing_server_worker="$final_path/live/syncing-server-worker.env"
|
config_syncing_server_worker="$install_dir/live/syncing-server-worker.env"
|
||||||
config_workspace="$final_path/live/workspace.env"
|
config_workspace="$install_dir/live/workspace.env"
|
||||||
|
|
||||||
jwt_secret=$(ynh_string_random --length=48 | base64)
|
jwt_secret=$(ynh_string_random --length=48 | base64)
|
||||||
legacy_jwt_secret=$(ynh_string_random --length=48 | base64)
|
legacy_jwt_secret=$(ynh_string_random --length=48 | base64)
|
||||||
|
@ -187,21 +79,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_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="env_workspace.env.sample" --destination="$config_workspace"
|
||||||
|
|
||||||
|
ynh_add_config --template="cron.env" --destination="$install_dir/cron.env"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALLING Standard Notes - Syncing Server
|
# 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
|
ynh_use_nodejs
|
||||||
pushd "$final_path/live"
|
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 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
|
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
|
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
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config --service="$app-api-gateway" --template="systemd_api-gateway.service"
|
ynh_add_systemd_config --service="$app-api-gateway" --template="systemd_api-gateway.service"
|
||||||
|
@ -211,27 +108,13 @@ ynh_add_systemd_config --service="$app-files" --template="systemd_files.service"
|
||||||
ynh_add_systemd_config --service="$app-syncing-server" --template="systemd_syncing-server.service"
|
ynh_add_systemd_config --service="$app-syncing-server" --template="systemd_syncing-server.service"
|
||||||
ynh_add_systemd_config --service="$app-syncing-server-worker" --template="systemd_syncing-server-worker.service"
|
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"
|
ynh_add_systemd_config --service="$app-workspace" --template="systemd_workspace.service"
|
||||||
|
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"
|
||||||
# SETUP A CRON
|
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"
|
||||||
ynh_script_progression --message="Setup a cron..."
|
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"
|
||||||
ynh_add_config --template="../conf/cron.env" --destination="$final_path/cron.env"
|
yunohost service add "$app-workspace" --description="Standard Notes - Workspace" --log="/var/log/$app/workspace.log"
|
||||||
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"
|
|
||||||
|
|
||||||
# Use logrotate to manage application logfile(s)
|
# Use logrotate to manage application logfile(s)
|
||||||
ynh_use_logrotate --logfile="/var/log/$app/api-gateway.log"
|
ynh_use_logrotate --logfile="/var/log/$app/api-gateway.log"
|
||||||
|
@ -242,23 +125,22 @@ 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/syncing-server-worker.log"
|
||||||
ynh_use_logrotate --logfile="/var/log/$app/workspace.log"
|
ynh_use_logrotate --logfile="/var/log/$app/workspace.log"
|
||||||
|
|
||||||
#=================================================
|
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
chmod 640 "/etc/cron.d/$app"
|
||||||
#=================================================
|
chown root: "/etc/cron.d/$app"
|
||||||
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"
|
# Create a dedicated Fail2Ban config
|
||||||
yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log"
|
# FIXME:
|
||||||
yunohost service add "$app-auth-worker" --description="Standard Notes - Auth - Worker" --log="/var/log/$app/auth-worker.log"
|
ynh_add_fail2ban_config --use_template
|
||||||
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"
|
if [ "${PACKAGE_CHECK_EXEC:-0}" -eq 0 ]; then
|
||||||
yunohost service add "$app-syncing-server-worker" --description="Standard Notes - Syncing Server - Worker" --log="/var/log/$app/syncing-server-worker.log"
|
ynh_add_swap --size="$swap_needed"
|
||||||
yunohost service add "$app-workspace" --description="Standard Notes - Workspace" --log="/var/log/$app/workspace.log"
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# 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
|
# Start a systemd service
|
||||||
ynh_systemd_action \
|
ynh_systemd_action \
|
||||||
|
@ -297,30 +179,6 @@ ynh_systemd_action \
|
||||||
--log_path="/var/log/$app/workspace.log" \
|
--log_path="/var/log/$app/workspace.log" \
|
||||||
--line_match='^.*Server started on port.*$|^.*Starting worker.*$'
|
--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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
124
scripts/remove
124
scripts/remove
|
@ -11,73 +11,40 @@ source ynh_add_swap
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# REMOVE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
|
||||||
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
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
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`)
|
# 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
|
if ynh_exec_warn_less yunohost service status "$app-api-gateway" >/dev/null; then
|
||||||
then
|
|
||||||
ynh_script_progression --message="Removing $app-api-gateway service..." --weight=1
|
ynh_script_progression --message="Removing $app-api-gateway service..." --weight=1
|
||||||
yunohost service remove "$app-api-gateway"
|
yunohost service remove "$app-api-gateway"
|
||||||
fi
|
fi
|
||||||
if ynh_exec_warn_less yunohost service status "$app-auth" >/dev/null
|
if ynh_exec_warn_less yunohost service status "$app-auth" >/dev/null; then
|
||||||
then
|
|
||||||
ynh_script_progression --message="Removing $app-auth service..." --weight=1
|
ynh_script_progression --message="Removing $app-auth service..." --weight=1
|
||||||
yunohost service remove "$app-auth"
|
yunohost service remove "$app-auth"
|
||||||
fi
|
fi
|
||||||
if ynh_exec_warn_less yunohost service status "$app-auth-worker" >/dev/null
|
if ynh_exec_warn_less yunohost service status "$app-auth-worker" >/dev/null; then
|
||||||
then
|
|
||||||
ynh_script_progression --message="Removing $app-auth-worker service..." --weight=1
|
ynh_script_progression --message="Removing $app-auth-worker service..." --weight=1
|
||||||
yunohost service remove "$app-auth-worker"
|
yunohost service remove "$app-auth-worker"
|
||||||
fi
|
fi
|
||||||
if ynh_exec_warn_less yunohost service status "$app-files" >/dev/null
|
if ynh_exec_warn_less yunohost service status "$app-files" >/dev/null; then
|
||||||
then
|
|
||||||
ynh_script_progression --message="Removing $app-files service..." --weight=1
|
ynh_script_progression --message="Removing $app-files service..." --weight=1
|
||||||
yunohost service remove "$app-files"
|
yunohost service remove "$app-files"
|
||||||
fi
|
fi
|
||||||
if ynh_exec_warn_less yunohost service status "$app-syncing-server" >/dev/null
|
if ynh_exec_warn_less yunohost service status "$app-syncing-server" >/dev/null; then
|
||||||
then
|
|
||||||
ynh_script_progression --message="Removing $app-syncing-server service..." --weight=1
|
ynh_script_progression --message="Removing $app-syncing-server service..." --weight=1
|
||||||
yunohost service remove "$app-syncing-server"
|
yunohost service remove "$app-syncing-server"
|
||||||
fi
|
fi
|
||||||
if ynh_exec_warn_less yunohost service status "$app-syncing-server-worker" >/dev/null
|
if ynh_exec_warn_less yunohost service status "$app-syncing-server-worker" >/dev/null; then
|
||||||
then
|
|
||||||
ynh_script_progression --message="Removing $app-syncing-server-worker service..." --weight=1
|
ynh_script_progression --message="Removing $app-syncing-server-worker service..." --weight=1
|
||||||
yunohost service remove "$app-syncing-server-worker"
|
yunohost service remove "$app-syncing-server-worker"
|
||||||
fi
|
fi
|
||||||
if ynh_exec_warn_less yunohost service status "$app-workspace" >/dev/null
|
if ynh_exec_warn_less yunohost service status "$app-workspace" >/dev/null; then
|
||||||
then
|
|
||||||
ynh_script_progression --message="Removing $app-workspace service..." --weight=1
|
ynh_script_progression --message="Removing $app-workspace service..." --weight=1
|
||||||
yunohost service remove "$app-workspace"
|
yunohost service remove "$app-workspace"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STOP AND REMOVE SERVICE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
|
||||||
|
|
||||||
# Remove the dedicated systemd config
|
# Remove the dedicated systemd config
|
||||||
ynh_remove_systemd_config --service="$app-api-gateway"
|
ynh_remove_systemd_config --service="$app-api-gateway"
|
||||||
ynh_remove_systemd_config --service="$app-auth"
|
ynh_remove_systemd_config --service="$app-auth"
|
||||||
|
@ -89,73 +56,24 @@ ynh_remove_systemd_config --service="$app-workspace"
|
||||||
|
|
||||||
ynh_reset_systemd
|
ynh_reset_systemd
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE LOGROTATE CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
|
||||||
|
|
||||||
# Remove the app-specific logrotate config
|
# Remove the app-specific logrotate config
|
||||||
ynh_remove_logrotate
|
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
|
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
|
# Remove the dedicated NGINX config
|
||||||
ynh_remove_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
|
# Remove the dedicated Fail2Ban config
|
||||||
ynh_remove_fail2ban_config
|
ynh_remove_fail2ban_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE NODEJS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing NodeJS..." --weight=10
|
||||||
|
|
||||||
|
ynh_remove_nodejs
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC REMOVE
|
# SPECIFIC REMOVE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -178,16 +96,6 @@ if [ ${PACKAGE_CHECK_EXEC:-0} -eq 0 ]; then
|
||||||
ynh_del_swap
|
ynh_del_swap
|
||||||
fi
|
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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
247
scripts/restore
247
scripts/restore
|
@ -11,142 +11,94 @@ source ../settings/scripts/_common.sh
|
||||||
source ../settings/scripts/ynh_add_swap
|
source ../settings/scripts/ynh_add_swap
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# MANAGE SCRIPT FAILURE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_clean_setup () {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
ynh_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)
|
redis_db=$(ynh_redis_get_free_db)
|
||||||
ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db"
|
ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db"
|
||||||
|
|
||||||
config_api_gateway="$final_path/live/api-gateway.env"
|
config_api_gateway="$install_dir/live/api-gateway.env"
|
||||||
config_auth="$final_path/live/auth.env"
|
config_auth="$install_dir/live/auth.env"
|
||||||
config_auth_worker="$final_path/live/auth-worker.env"
|
config_auth_worker="$install_dir/live/auth-worker.env"
|
||||||
config_files="$final_path/live/files.env"
|
config_files="$install_dir/live/files.env"
|
||||||
config_syncing_server="$final_path/live/syncing-server.env"
|
config_syncing_server="$install_dir/live/syncing-server.env"
|
||||||
config_syncing_server_worker="$final_path/live/syncing-server-worker.env"
|
config_syncing_server_worker="$install_dir/live/syncing-server-worker.env"
|
||||||
config_workspace="$final_path/live/workspace.env"
|
config_workspace="$install_dir/live/workspace.env"
|
||||||
config_nginx="/etc/nginx/conf.d/$domain.d/$app.conf"
|
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
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
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"
|
chown -R "$app:$app" "$install_dir"
|
||||||
chmod -R o-rwx "$final_path"
|
|
||||||
chown -R $app:$app "$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE DATA DIRECTORY
|
# RESTORE THE DATA DIRECTORY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the data directory..." --weight=1
|
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"
|
chown -R "$app:$app" "$data_dir"
|
||||||
|
|
||||||
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"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE MYSQL DATABASE
|
# RESTORE THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=2
|
ynh_script_progression --message="Restoring the MySQL database..." --weight=2
|
||||||
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
|
||||||
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
|
#=================================================
|
||||||
|
# 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
|
# MODIFY CONFIG
|
||||||
|
@ -186,69 +138,11 @@ ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_worksp
|
||||||
ynh_replace_string --match_string="^WORKSPACE_SERVER_URL.*$" --replace_string="WORKSPACE_SERVER_URL=http://localhost:$port_workspace" --target_file="$config_api_gateway"
|
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
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD SWAP
|
ynh_script_progression --message="Reloading NGINX web server and $app's services..." --weight=1
|
||||||
#=================================================
|
|
||||||
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_systemd_action \
|
ynh_systemd_action \
|
||||||
--service_name="$app-api-gateway" \
|
--service_name="$app-api-gateway" \
|
||||||
|
@ -286,13 +180,6 @@ ynh_systemd_action \
|
||||||
--log_path="/var/log/$app/workspace.log" \
|
--log_path="/var/log/$app/workspace.log" \
|
||||||
--line_match='^.*Server started on port.*$|^.*Starting worker.*$'
|
--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
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
184
scripts/upgrade
184
scripts/upgrade
|
@ -13,47 +13,47 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
#REMOVEME? db_user=$db_name
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||||
|
|
||||||
port_api_gateway=$(ynh_app_setting_get --app=$app --key=port_api_gateway)
|
#REMOVEME? port_api_gateway=$(ynh_app_setting_get --app=$app --key=port_api_gateway)
|
||||||
port_auth=$(ynh_app_setting_get --app=$app --key=port_auth)
|
#REMOVEME? port_auth=$(ynh_app_setting_get --app=$app --key=port_auth)
|
||||||
port_auth_worker=$(ynh_app_setting_get --app=$app --key=port_auth_worker)
|
#REMOVEME? port_auth_worker=$(ynh_app_setting_get --app=$app --key=port_auth_worker)
|
||||||
port_files=$(ynh_app_setting_get --app=$app --key=port_files)
|
#REMOVEME? port_files=$(ynh_app_setting_get --app=$app --key=port_files)
|
||||||
port_syncing_server=$(ynh_app_setting_get --app=$app --key=port_syncing_server)
|
#REMOVEME? 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)
|
#REMOVEME? 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)
|
#REMOVEME? port_workspace=$(ynh_app_setting_get --app=$app --key=port_workspace)
|
||||||
|
|
||||||
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
||||||
|
|
||||||
jwt_secret=$(ynh_app_setting_get --app=$app --key=jwt_secret)
|
#REMOVEME? jwt_secret=$(ynh_app_setting_get --app=$app --key=jwt_secret)
|
||||||
legacy_jwt_secret=$(ynh_app_setting_get --app=$app --key=legacy_jwt_secret)
|
#REMOVEME? 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)
|
#REMOVEME? 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)
|
#REMOVEME? 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)
|
#REMOVEME? 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)
|
#REMOVEME? 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)
|
#REMOVEME? disable_user_registration=$(ynh_app_setting_get --app=$app --key=DISABLE_USER_REGISTRATION)
|
||||||
files_size=$(ynh_app_setting_get --app=$app --key=FILES_SIZE)
|
#REMOVEME? files_size=$(ynh_app_setting_get --app=$app --key=FILES_SIZE)
|
||||||
|
|
||||||
config_api_gateway="$final_path/live/api-gateway.env"
|
config_api_gateway="$install_dir/live/api-gateway.env"
|
||||||
config_auth="$final_path/live/auth.env"
|
config_auth="$install_dir/live/auth.env"
|
||||||
config_auth_worker="$final_path/live/auth-worker.env"
|
config_auth_worker="$install_dir/live/auth-worker.env"
|
||||||
config_files="$final_path/live/files.env"
|
config_files="$install_dir/live/files.env"
|
||||||
config_syncing_server="$final_path/live/syncing-server.env"
|
config_syncing_server="$install_dir/live/syncing-server.env"
|
||||||
config_syncing_server_worker="$final_path/live/syncing-server-worker.env"
|
config_syncing_server_worker="$install_dir/live/syncing-server-worker.env"
|
||||||
config_workspace="$final_path/live/workspace.env"
|
config_workspace="$install_dir/live/workspace.env"
|
||||||
|
|
||||||
nodejs_version_installed=$(ynh_app_setting_get --app=$app --key=nodejs_version)
|
#REMOVEME? nodejs_version_installed=$(ynh_app_setting_get --app=$app --key=nodejs_version)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
|
@ -65,16 +65,16 @@ upgrade_type=$(ynh_check_app_version_changed)
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
|
||||||
|
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
#REMOVEME? ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
#REMOVEME? ynh_clean_setup () {
|
||||||
# Restore it if the upgrade fails
|
# Restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
#REMOVEME? ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
|
@ -117,10 +117,10 @@ ynh_systemd_action \
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||||
|
|
||||||
# If final_path doesn't exist, create it
|
# If install_dir doesn't exist, create it
|
||||||
if [ -z "$final_path" ]; then
|
if [ -z "$install_dir" ]; then
|
||||||
final_path=/opt/yunohost/$app
|
#REMOVEME? install_dir=/opt/yunohost/$app
|
||||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If redis_db doesn't exist, create it
|
# If redis_db doesn't exist, create it
|
||||||
|
@ -138,20 +138,20 @@ if [[ -z "$port_api_gateway" || \
|
||||||
-z "$port_syncing_server" || \
|
-z "$port_syncing_server" || \
|
||||||
-z "$port_syncing_server_worker" || \
|
-z "$port_syncing_server_worker" || \
|
||||||
-z "$port_workspace" ]]; then
|
-z "$port_workspace" ]]; then
|
||||||
port_api_gateway=$(ynh_find_port --port=3000)
|
#REMOVEME? port_api_gateway=$(ynh_find_port --port=3000)
|
||||||
port_auth=$(ynh_find_port --port=$((port_api_gateway+1)))
|
#REMOVEME? port_auth=$(ynh_find_port --port=$((port_api_gateway+1)))
|
||||||
port_auth_worker=$(ynh_find_port --port=$((port_auth+1)))
|
#REMOVEME? port_auth_worker=$(ynh_find_port --port=$((port_auth+1)))
|
||||||
port_files=$(ynh_find_port --port=$((port_auth_worker+1)))
|
#REMOVEME? port_files=$(ynh_find_port --port=$((port_auth_worker+1)))
|
||||||
port_syncing_server=$(ynh_find_port --port=$((port_files+1)))
|
#REMOVEME? port_syncing_server=$(ynh_find_port --port=$((port_files+1)))
|
||||||
port_syncing_server_worker=$(ynh_find_port --port=$((port_syncing_server+1)))
|
#REMOVEME? port_syncing_server_worker=$(ynh_find_port --port=$((port_syncing_server+1)))
|
||||||
port_workspace=$(ynh_find_port --port=$((port_syncing_server_worker+1)))
|
#REMOVEME? 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
|
#REMOVEME? 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
|
#REMOVEME? 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
|
#REMOVEME? 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
|
#REMOVEME? 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
|
#REMOVEME? 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
|
#REMOVEME? 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
|
#REMOVEME? ynh_app_setting_set --app=$app --key=port_workspace --value=$port_workspace
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If jwt_secret doesn't exist, create it
|
# If jwt_secret doesn't exist, create it
|
||||||
|
@ -196,12 +196,12 @@ if [ -z "$files_size" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove old Settings, Services, Files, Dependencies
|
# Remove old Settings, Services, Files, Dependencies
|
||||||
# If final_path_www exist, delete it
|
# If install_dir_www exist, delete it
|
||||||
api_gateway_version_installed=$(ynh_app_setting_get --app=$app --key=api_gateway_version)
|
#REMOVEME? 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)
|
#REMOVEME? 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)
|
#REMOVEME? 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)
|
#REMOVEME? install_dir_www=$(ynh_app_setting_get --app=$app --key=install_dir_www)
|
||||||
final_path_extensions=$(ynh_app_setting_get --app=$app --key=final_path_extensions)
|
#REMOVEME? install_dir_extensions=$(ynh_app_setting_get --app=$app --key=install_dir_extensions)
|
||||||
if [ -n ${api_gateway_version_installed+x} ]; then
|
if [ -n ${api_gateway_version_installed+x} ]; then
|
||||||
ynh_app_setting_delete --app=$app --key=api_gateway_version_installed
|
ynh_app_setting_delete --app=$app --key=api_gateway_version_installed
|
||||||
fi
|
fi
|
||||||
|
@ -211,16 +211,16 @@ fi
|
||||||
if [ -n ${syncing_server_version_installed+x} ]; then
|
if [ -n ${syncing_server_version_installed+x} ]; then
|
||||||
ynh_app_setting_delete --app=$app --key=syncing_server_version_installed
|
ynh_app_setting_delete --app=$app --key=syncing_server_version_installed
|
||||||
fi
|
fi
|
||||||
if [ -n ${final_path_www+x} ]; then
|
if [ -n ${install_dir_www+x} ]; then
|
||||||
ynh_app_setting_delete --app=$app --key=final_path_www
|
ynh_app_setting_delete --app=$app --key=install_dir_www
|
||||||
fi
|
fi
|
||||||
# If final_path_extensions exist, delete it
|
# If install_dir_extensions exist, delete it
|
||||||
if [ -n ${final_path_extensions+x} ]; then
|
if [ -n ${install_dir_extensions+x} ]; then
|
||||||
ynh_app_setting_delete --app=$app --key=final_path_extensions
|
ynh_app_setting_delete --app=$app --key=install_dir_extensions
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If permission help exists, delete it
|
# If permission help exists, delete it
|
||||||
if ynh_permission_exists --permission="help"
|
#REMOVEME? if ynh_permission_exists --permission="help"
|
||||||
then
|
then
|
||||||
ynh_permission_delete --permission="help"
|
ynh_permission_delete --permission="help"
|
||||||
fi
|
fi
|
||||||
|
@ -246,26 +246,26 @@ if [ -e "/var/www/$app" ]; then
|
||||||
ynh_secure_remove --file="/var/www/$app"
|
ynh_secure_remove --file="/var/www/$app"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If datadir doesn't exist, create it
|
# If data_dir doesn't exist, create it
|
||||||
# CREATE DATA DIRECTORY
|
# CREATE DATA DIRECTORY
|
||||||
if [ -z "$datadir" ]; then
|
if [ -z "$data_dir" ]; then
|
||||||
datadir=/home/yunohost.app/$app
|
data_dir=/home/yunohost.app/$app
|
||||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir
|
||||||
|
|
||||||
mkdir -p $datadir/uploads
|
mkdir -p $data_dir/uploads
|
||||||
|
|
||||||
chmod -R 750 "$datadir"
|
chmod -R 750 "$data_dir"
|
||||||
chmod -R o-rwx "$datadir"
|
chmod -R o-rwx "$data_dir"
|
||||||
chown -R $app:$app "$datadir"
|
chown -R $app:$app "$data_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
# Create a dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
@ -276,24 +276,24 @@ then
|
||||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_secure_remove --file="$final_path/live"
|
#REMOVEME? ynh_secure_remove --file="$install_dir/live"
|
||||||
mkdir -p "$final_path/live"
|
mkdir -p "$install_dir/live"
|
||||||
ynh_setup_source --source_id=app --dest_dir="$final_path/live"
|
ynh_setup_source --dest_dir="$install_dir/live"
|
||||||
cp "$YNH_APP_BASEDIR/sources/extra_files/cron.sh" "$final_path/cron.sh"
|
cp "$YNH_APP_BASEDIR/sources/extra_files/cron.sh" "$install_dir/cron.sh"
|
||||||
|
|
||||||
chmod 750 "$final_path"
|
chmod 750 "$install_dir"
|
||||||
chmod -R o-rwx "$final_path"
|
chmod -R o-rwx "$install_dir"
|
||||||
chown -R $app:$app "$final_path"
|
chown -R $app:$app "$install_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE DEPENDENCIES
|
# UPGRADE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
||||||
ynh_install_nodejs --nodejs_version=$nodejs_version
|
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"
|
#REMOVEME? 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
|
# NGINX CONFIGURATION
|
||||||
|
@ -334,7 +334,7 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Installing Standard Notes - Syncing Server..." --weight=93
|
ynh_script_progression --message="Installing Standard Notes - Syncing Server..." --weight=93
|
||||||
ynh_use_nodejs
|
ynh_use_nodejs
|
||||||
pushd "$final_path/live"
|
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 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
|
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
|
popd
|
||||||
|
@ -433,7 +433,7 @@ ynh_systemd_action \
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="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.env" --destination="$install_dir/cron.env"
|
||||||
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
||||||
|
|
||||||
chown root: "/etc/cron.d/$app"
|
chown root: "/etc/cron.d/$app"
|
||||||
|
@ -450,9 +450,9 @@ ynh_add_fail2ban_config --use_template
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
9
tests.toml
Normal file
9
tests.toml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
test_format = 1.0
|
||||||
|
|
||||||
|
[default]
|
||||||
|
|
||||||
|
# ------------
|
||||||
|
# Tests to run
|
||||||
|
# ------------
|
||||||
|
|
||||||
|
test_upgrade_from.62b95a36.name = "2022.09.16~ynh1"
|
Loading…
Reference in a new issue