mirror of
https://github.com/YunoHost-Apps/tracim_ynh.git
synced 2024-10-01 13:34:52 +02:00
Merge pull request #17 from YunoHost-Apps/testing
This commit is contained in:
commit
33d69b4288
25 changed files with 364 additions and 981 deletions
125
.github/workflows/updater.sh
vendored
125
.github/workflows/updater.sh
vendored
|
@ -1,125 +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]')
|
|
||||||
# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions)
|
|
||||||
tag_name=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
|
|
||||||
version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .name' | sort -V | tail -1)
|
|
||||||
assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$tag_name'").tarball_url ] | join(" ") | @sh' | tr -d "'"))
|
|
||||||
|
|
||||||
# Later down the script, we assume the version has only digits and dots
|
|
||||||
# Sometimes the release name starts with a "v", so let's filter it out.
|
|
||||||
# You may need more tweaks here if the upstream repository has different naming conventions.
|
|
||||||
if [[ ${version:0:8} == "version " || ${version:0:8} == "Version " || ${version:0:8} == "VERSION " ]]; then
|
|
||||||
version=${version:8}
|
|
||||||
fi
|
|
||||||
if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then
|
|
||||||
version=${version:1}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Setting up the environment variables
|
|
||||||
echo "Current version: $current_version"
|
|
||||||
echo "Latest release from upstream: $version"
|
|
||||||
echo "VERSION=$version" >> $GITHUB_ENV
|
|
||||||
echo "REPO=$repo" >> $GITHUB_ENV
|
|
||||||
# For the time being, let's assume the script will fail
|
|
||||||
echo "PROCEED=false" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
# Proceed only if the retrieved version is greater than the current one
|
|
||||||
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
|
|
||||||
echo "::warning ::No new version available"
|
|
||||||
exit 0
|
|
||||||
# Proceed only if a PR for this new version does not already exist
|
|
||||||
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then
|
|
||||||
echo "::warning ::A branch already exists for this update"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.)
|
|
||||||
echo "${#assets[@]} available asset(s)"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# UPDATE SOURCE FILES
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Here we use the $assets variable to get the resources published in the upstream release.
|
|
||||||
# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like.
|
|
||||||
|
|
||||||
# Let's loop over the array of assets URLs
|
|
||||||
for asset_url in ${assets[@]}; do
|
|
||||||
|
|
||||||
echo "Handling asset at $asset_url"
|
|
||||||
|
|
||||||
# Assign the asset to a source file in conf/ directory
|
|
||||||
# Here we base the source file name upon a unique keyword in the assets url (admin vs. update)
|
|
||||||
# Leave $src empty to ignore the asset
|
|
||||||
case $asset_url in
|
|
||||||
*"tarball"*)
|
|
||||||
src="app"
|
|
||||||
esac
|
|
||||||
|
|
||||||
# If $src is not empty, let's process the asset
|
|
||||||
if [ ! -z "$src" ]; then
|
|
||||||
|
|
||||||
# Create the temporary directory
|
|
||||||
tempdir="$(mktemp -d)"
|
|
||||||
|
|
||||||
# Download sources and calculate checksum
|
|
||||||
filename=${asset_url##*/}
|
|
||||||
curl --silent -4 -L $asset_url -o "$tempdir/$filename"
|
|
||||||
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
|
|
||||||
|
|
||||||
# Delete temporary directory
|
|
||||||
rm -rf $tempdir
|
|
||||||
|
|
||||||
# Rewrite source file
|
|
||||||
cat <<EOT > conf/$src.src
|
|
||||||
SOURCE_URL=$asset_url
|
|
||||||
SOURCE_SUM=$checksum
|
|
||||||
SOURCE_SUM_PRG=sha256sum
|
|
||||||
SOURCE_FORMAT=tar.gz
|
|
||||||
SOURCE_IN_SUBDIR=true
|
|
||||||
SOURCE_FILENAME=
|
|
||||||
SOURCE_EXTRACT=true
|
|
||||||
EOT
|
|
||||||
echo "... conf/$src.src updated"
|
|
||||||
|
|
||||||
else
|
|
||||||
echo "... asset ignored"
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC UPDATE STEPS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Any action on the app's source code can be done.
|
|
||||||
# The GitHub Action workflow takes care of committing all changes after this script ends.
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Replace new version in manifest
|
|
||||||
echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json
|
|
||||||
|
|
||||||
# No need to update the README, yunohost-bot takes care of it
|
|
||||||
|
|
||||||
# The Action will proceed only if the PROCEED environment variable is set to true
|
|
||||||
echo "PROCEED=true" >> $GITHUB_ENV
|
|
||||||
exit 0
|
|
50
.github/workflows/updater.yml
vendored
50
.github/workflows/updater.yml
vendored
|
@ -1,50 +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 day at 6:00 UTC
|
|
||||||
schedule:
|
|
||||||
- cron: '0 6 * * *'
|
|
||||||
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 v$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 version ${{ env.VERSION }}
|
|
||||||
committer: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
|
|
||||||
author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
|
|
||||||
signoff: false
|
|
||||||
base: testing
|
|
||||||
branch: ci-auto-update-v${{ env.VERSION }}
|
|
||||||
delete-branch: true
|
|
||||||
title: 'Upgrade to version ${{ env.VERSION }}'
|
|
||||||
body: |
|
|
||||||
Upgrade to v${{ env.VERSION }}
|
|
||||||
draft: false
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ It shall NOT be edited by hand.
|
||||||
# Tracim for YunoHost
|
# Tracim for YunoHost
|
||||||
|
|
||||||
[![Integration level](https://dash.yunohost.org/integration/tracim.svg)](https://dash.yunohost.org/appci/app/tracim) ![Working status](https://ci-apps.yunohost.org/ci/badges/tracim.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/tracim.maintain.svg)
|
[![Integration level](https://dash.yunohost.org/integration/tracim.svg)](https://dash.yunohost.org/appci/app/tracim) ![Working status](https://ci-apps.yunohost.org/ci/badges/tracim.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/tracim.maintain.svg)
|
||||||
|
|
||||||
[![Install Tracim with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=tracim)
|
[![Install Tracim with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=tracim)
|
||||||
|
|
||||||
*[Lire ce readme en français.](./README_fr.md)*
|
*[Lire ce readme en français.](./README_fr.md)*
|
||||||
|
|
|
@ -6,6 +6,7 @@ It shall NOT be edited by hand.
|
||||||
# Tracim pour YunoHost
|
# Tracim pour YunoHost
|
||||||
|
|
||||||
[![Niveau d’intégration](https://dash.yunohost.org/integration/tracim.svg)](https://dash.yunohost.org/appci/app/tracim) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/tracim.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/tracim.maintain.svg)
|
[![Niveau d’intégration](https://dash.yunohost.org/integration/tracim.svg)](https://dash.yunohost.org/appci/app/tracim) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/tracim.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/tracim.maintain.svg)
|
||||||
|
|
||||||
[![Installer Tracim avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=tracim)
|
[![Installer Tracim avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=tracim)
|
||||||
|
|
||||||
*[Read this readme in english.](./README.md)*
|
*[Read this readme in english.](./README.md)*
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
;; Test complet
|
|
||||||
; Manifest
|
|
||||||
domain="domain.tld"
|
|
||||||
is_public=1
|
|
||||||
language="fr"
|
|
||||||
admin="john"
|
|
||||||
password="1Strong-Password"
|
|
||||||
; Checks
|
|
||||||
pkg_linter=1
|
|
||||||
setup_sub_dir=0
|
|
||||||
setup_root=1
|
|
||||||
setup_nourl=0
|
|
||||||
setup_private=1
|
|
||||||
setup_public=1
|
|
||||||
upgrade=1
|
|
||||||
#upgrade=1 from_commit=CommitHash
|
|
||||||
backup_restore=1
|
|
||||||
multi_instance=1
|
|
||||||
port_already_use=0
|
|
||||||
change_url=1
|
|
||||||
;;; Options
|
|
||||||
Email=
|
|
||||||
Notification=none
|
|
|
@ -1,7 +0,0 @@
|
||||||
SOURCE_URL=https://api.github.com/repos/tracim/tracim/tarball/release_04.04.03
|
|
||||||
SOURCE_SUM=e661be5481e262a5f3927ea9d62e1c7e15f63ba87fc12d038a301b936ab22a52
|
|
||||||
SOURCE_SUM_PRG=sha256sum
|
|
||||||
SOURCE_FORMAT=tar.gz
|
|
||||||
SOURCE_IN_SUBDIR=true
|
|
||||||
SOURCE_FILENAME=
|
|
||||||
SOURCE_EXTRACT=true
|
|
|
@ -2,10 +2,10 @@
|
||||||
uid = __APP__
|
uid = __APP__
|
||||||
gid = www-data
|
gid = www-data
|
||||||
plugins = python3
|
plugins = python3
|
||||||
chdir = __FINALPATH__/backend/
|
chdir = __INSTALL_DIR__/backend/
|
||||||
module = wsgi.caldav:application
|
module = wsgi.caldav:application
|
||||||
home = __FINALPATH__/backend/env/
|
home = __INSTALL_DIR__/backend/env/
|
||||||
threads = 8
|
threads = 8
|
||||||
env = TRACIM_CONF_PATH=__FINALPATH__/backend/development.ini
|
env = TRACIM_CONF_PATH=__INSTALL_DIR__/backend/development.ini
|
||||||
socket = /tmp/uwsgi-__APP__-caldav.socket
|
socket = /tmp/uwsgi-__APP__-caldav.socket
|
||||||
chmod-socket = 660
|
chmod-socket = 660
|
||||||
|
|
|
@ -41,8 +41,8 @@ basic_setup.listen = localhost:6543
|
||||||
## storage path/connection
|
## storage path/connection
|
||||||
basic_setup.sqlalchemy_url = postgresql://__DB_USER__:__DB_PWD__@localhost:5432/__DB_NAME__?client_encoding=utf8
|
basic_setup.sqlalchemy_url = postgresql://__DB_USER__:__DB_PWD__@localhost:5432/__DB_NAME__?client_encoding=utf8
|
||||||
basic_setup.uploaded_files_storage_type = local
|
basic_setup.uploaded_files_storage_type = local
|
||||||
basic_setup.uploaded_files_storage_path = __DATADIR__/depot
|
basic_setup.uploaded_files_storage_path = __DATA_DIR__/depot
|
||||||
basic_setup.caldav_storage_dir = __DATADIR__/radicale_storage
|
basic_setup.caldav_storage_dir = __DATA_DIR__/radicale_storage
|
||||||
basic_setup.preview_cache_dir = %(here)s/previews
|
basic_setup.preview_cache_dir = %(here)s/previews
|
||||||
basic_setup.sessions_data_root_dir = %(here)s
|
basic_setup.sessions_data_root_dir = %(here)s
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ location __PATH__/dav {
|
||||||
location __PATH__/assets/ {
|
location __PATH__/assets/ {
|
||||||
|
|
||||||
# Path to source
|
# Path to source
|
||||||
alias __FINALPATH__/frontend/dist/assets/ ;
|
alias __INSTALL_DIR__/frontend/dist/assets/ ;
|
||||||
|
|
||||||
try_files $uri $uri/;
|
try_files $uri $uri/;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ location __PATH__/assets/ {
|
||||||
location __PATH__/app/ {
|
location __PATH__/app/ {
|
||||||
|
|
||||||
# Path to source
|
# Path to source
|
||||||
alias __FINALPATH__/frontend/dist/app/ ;
|
alias __INSTALL_DIR__/frontend/dist/app/ ;
|
||||||
|
|
||||||
try_files $uri $uri/;
|
try_files $uri $uri/;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ location __PATH__/app/ {
|
||||||
location __PATH__/favicon.ico {
|
location __PATH__/favicon.ico {
|
||||||
|
|
||||||
# Path to source
|
# Path to source
|
||||||
alias __FINALPATH__/frontend/dist/assets/branding/images/favicon/favicon.ico ;
|
alias __INSTALL_DIR__/frontend/dist/assets/branding/images/favicon/favicon.ico ;
|
||||||
|
|
||||||
try_files $uri $uri/;
|
try_files $uri $uri/;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,40 +4,40 @@ user=root
|
||||||
|
|
||||||
; email notifier (if async jobs processing is enabled)
|
; email notifier (if async jobs processing is enabled)
|
||||||
[program:tracim_mail_notifier]
|
[program:tracim_mail_notifier]
|
||||||
directory=__FINALPATH__/backend/
|
directory=__INSTALL_DIR__/backend/
|
||||||
command=__FINALPATH__/backend/env/bin/python __FINALPATH__/backend/daemons/mail_notifier.py
|
command=__INSTALL_DIR__/backend/env/bin/python __INSTALL_DIR__/backend/daemons/mail_notifier.py
|
||||||
stdout_logfile =/tmp/mail_notifier.log
|
stdout_logfile =/tmp/mail_notifier.log
|
||||||
redirect_stderr=true
|
redirect_stderr=true
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
environment=TRACIM_CONF_PATH=__FINALPATH__/backend/development.ini
|
environment=TRACIM_CONF_PATH=__INSTALL_DIR__/backend/development.ini
|
||||||
|
|
||||||
; email fetcher (if email reply is enabled)
|
; email fetcher (if email reply is enabled)
|
||||||
[program:tracim_mail_fetcher]
|
[program:tracim_mail_fetcher]
|
||||||
directory=__FINALPATH__/backend/
|
directory=__INSTALL_DIR__/backend/
|
||||||
command=__FINALPATH__/backend/env/bin/python __FINALPATH__/backend/daemons/mail_fetcher.py
|
command=__INSTALL_DIR__/backend/env/bin/python __INSTALL_DIR__/backend/daemons/mail_fetcher.py
|
||||||
stdout_logfile =/tmp/mail_fetcher.log
|
stdout_logfile =/tmp/mail_fetcher.log
|
||||||
redirect_stderr=true
|
redirect_stderr=true
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
environment=TRACIM_CONF_PATH=__FINALPATH__/backend/development.ini
|
environment=TRACIM_CONF_PATH=__INSTALL_DIR__/backend/development.ini
|
||||||
|
|
||||||
; user connection status monitor (online / offline0)
|
; user connection status monitor (online / offline0)
|
||||||
[program:tracim_user_connection_state_monitor]
|
[program:tracim_user_connection_state_monitor]
|
||||||
directory=__FINALPATH__/backend/
|
directory=__INSTALL_DIR__/backend/
|
||||||
command=__FINALPATH__/backend/env/bin/python3 __FINALPATH__/backend/daemons/user_connection_state_monitor.py
|
command=__INSTALL_DIR__/backend/env/bin/python3 __INSTALL_DIR__/backend/daemons/user_connection_state_monitor.py
|
||||||
stdout_logfile=/tmp/user_connection_state_monitor.log
|
stdout_logfile=/tmp/user_connection_state_monitor.log
|
||||||
redirect_stderr=true
|
redirect_stderr=true
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=false
|
autorestart=false
|
||||||
environment=TRACIM_CONF_PATH=__FINALPATH__/backend/development.ini
|
environment=TRACIM_CONF_PATH=__INSTALL_DIR__/backend/development.ini
|
||||||
|
|
||||||
; RQ worker (if async jobs processing is enabled)
|
; RQ worker (if async jobs processing is enabled)
|
||||||
[program:rq_database_worker]
|
[program:rq_database_worker]
|
||||||
directory=__FINALPATH__/backend/
|
directory=__INSTALL_DIR__/backend/
|
||||||
command=__FINALPATH__/backend/env/bin/rq worker -q -w tracim_backend.lib.rq.worker.DatabaseWorker event elasticsearch_indexer
|
command=__INSTALL_DIR__/backend/env/bin/rq worker -q -w tracim_backend.lib.rq.worker.DatabaseWorker event elasticsearch_indexer
|
||||||
stdout_logfile =/tmp/rq_database_worker.log
|
stdout_logfile =/tmp/rq_database_worker.log
|
||||||
redirect_stderr=true
|
redirect_stderr=true
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
environment=TRACIM_CONF_PATH=__FINALPATH__/backend/development.ini
|
environment=TRACIM_CONF_PATH=__INSTALL_DIR__/backend/development.ini
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
uid = __APP__
|
uid = __APP__
|
||||||
gid = www-data
|
gid = www-data
|
||||||
plugins = python3
|
plugins = python3
|
||||||
chdir = __FINALPATH__/backend/
|
chdir = __INSTALL_DIR__/backend/
|
||||||
module = wsgi.web:application
|
module = wsgi.web:application
|
||||||
home = __FINALPATH__/backend/env
|
home = __INSTALL_DIR__/backend/env
|
||||||
socket = /tmp/uwsgi-__APP__-web.socket
|
socket = /tmp/uwsgi-__APP__-web.socket
|
||||||
chmod-socket = 660
|
chmod-socket = 660
|
||||||
workers = 4
|
workers = 4
|
||||||
threads = 4
|
threads = 4
|
||||||
env = TRACIM_CONF_PATH=__FINALPATH__/backend/development.ini
|
env = TRACIM_CONF_PATH=__INSTALL_DIR__/backend/development.ini
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
uid = __APP__
|
uid = __APP__
|
||||||
gid = www-data
|
gid = www-data
|
||||||
plugins = python3
|
plugins = python3
|
||||||
chdir = __FINALPATH__/backend/
|
chdir = __INSTALL_DIR__/backend/
|
||||||
module = wsgi.webdav:application
|
module = wsgi.webdav:application
|
||||||
home = __FINALPATH__/backend/env/
|
home = __INSTALL_DIR__/backend/env/
|
||||||
threads = 8
|
threads = 8
|
||||||
env = TRACIM_CONF_PATH=__FINALPATH__/backend/development.ini
|
env = TRACIM_CONF_PATH=__INSTALL_DIR__/backend/development.ini
|
||||||
socket = /tmp/uwsgi-__APP__-webdav.socket
|
socket = /tmp/uwsgi-__APP__-webdav.socket
|
||||||
chmod-socket = 660
|
chmod-socket = 660
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
{
|
|
||||||
"name": "Tracim",
|
|
||||||
"id": "tracim",
|
|
||||||
"packaging_format": 1,
|
|
||||||
"description": {
|
|
||||||
"en": "Collaborative platform software intended for (not only technical) team collaboration."
|
|
||||||
},
|
|
||||||
"version": "4.4.3~ynh1",
|
|
||||||
"url": "https://www.tracim.fr",
|
|
||||||
"upstream": {
|
|
||||||
"license": "AGPL-3.0-or-later,LGPL-3.0-or-later,CC-BY-SA-2.5,MIT",
|
|
||||||
"website": "https://www.tracim.fr",
|
|
||||||
"demo": "https://www.algoo.fr/fr/tracim/demo",
|
|
||||||
"admindoc": "https://public-community.tracim.fr/ui/workspaces/143/contents",
|
|
||||||
"code": "https://github.com/tracim/tracim"
|
|
||||||
},
|
|
||||||
"license": "AGPL-3.0-or-later",
|
|
||||||
"maintainer": {
|
|
||||||
"name": "",
|
|
||||||
"email": ""
|
|
||||||
},
|
|
||||||
"requirements": {
|
|
||||||
"yunohost": ">= 4.3.0"
|
|
||||||
},
|
|
||||||
"multi_instance": true,
|
|
||||||
"services": [
|
|
||||||
"nginx"
|
|
||||||
],
|
|
||||||
"arguments": {
|
|
||||||
"install": [
|
|
||||||
{
|
|
||||||
"name": "domain",
|
|
||||||
"type": "domain"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "is_public",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "language",
|
|
||||||
"type": "string",
|
|
||||||
"ask": {
|
|
||||||
"en": "Choose the application language",
|
|
||||||
"fr": "Choisissez la langue de l'application"
|
|
||||||
},
|
|
||||||
"choices": [
|
|
||||||
"fr",
|
|
||||||
"en",
|
|
||||||
"pt",
|
|
||||||
"de",
|
|
||||||
"ar"
|
|
||||||
],
|
|
||||||
"default": "fr"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "admin",
|
|
||||||
"type": "user"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "password",
|
|
||||||
"type": "password"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
76
manifest.toml
Normal file
76
manifest.toml
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
packaging_format = 2
|
||||||
|
|
||||||
|
id = "tracim"
|
||||||
|
name = "Tracim"
|
||||||
|
description.en = "Collaborative platform software intended for (not only technical) team collaboration."
|
||||||
|
|
||||||
|
version = "4.4.3~ynh1"
|
||||||
|
|
||||||
|
maintainers = []
|
||||||
|
|
||||||
|
[upstream]
|
||||||
|
license = "AGPL-3.0-or-later,LGPL-3.0-or-later,CC-BY-SA-2.5,MIT"
|
||||||
|
website = "https://www.tracim.fr"
|
||||||
|
demo = "https://www.algoo.fr/fr/tracim/demo"
|
||||||
|
admindoc = "https://public-community.tracim.fr/ui/workspaces/143/contents"
|
||||||
|
code = "https://github.com/tracim/tracim"
|
||||||
|
|
||||||
|
[integration]
|
||||||
|
yunohost = ">= 11.1.18"
|
||||||
|
architectures = "all"
|
||||||
|
multi_instance = true
|
||||||
|
ldap = false
|
||||||
|
sso = false
|
||||||
|
disk = "50M"
|
||||||
|
ram.build = "50M"
|
||||||
|
ram.runtime = "50M"
|
||||||
|
|
||||||
|
[install]
|
||||||
|
[install.domain]
|
||||||
|
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||||
|
type = "domain"
|
||||||
|
full_domain = true
|
||||||
|
|
||||||
|
[install.init_main_permission]
|
||||||
|
type = "group"
|
||||||
|
default = "visitors"
|
||||||
|
|
||||||
|
[install.language]
|
||||||
|
ask.en = "Choose the application language"
|
||||||
|
ask.fr = "Choisissez la langue de l'application"
|
||||||
|
type = "string"
|
||||||
|
choices = ["fr", "en", "pt", "de", "ar"]
|
||||||
|
default = "fr"
|
||||||
|
|
||||||
|
[install.admin]
|
||||||
|
type = "user"
|
||||||
|
|
||||||
|
[install.password]
|
||||||
|
type = "password"
|
||||||
|
|
||||||
|
[resources]
|
||||||
|
[resources.sources.main]
|
||||||
|
url = "https://api.github.com/repos/tracim/tracim/tarball/release_04.04.03"
|
||||||
|
sha256 = "e661be5481e262a5f3927ea9d62e1c7e15f63ba87fc12d038a301b936ab22a52"
|
||||||
|
|
||||||
|
[resources.ports]
|
||||||
|
|
||||||
|
[resources.system_user]
|
||||||
|
|
||||||
|
[resources.install_dir]
|
||||||
|
|
||||||
|
[resources.data_dir]
|
||||||
|
subdirs = ["depot", "radicale_storage"]
|
||||||
|
|
||||||
|
[resources.permissions]
|
||||||
|
main.url = "/"
|
||||||
|
|
||||||
|
[resources.apt]
|
||||||
|
packages = "ffmpeg xvfb inkscape libreoffice postgresql ghostscript git imagemagick iproute2 libfile-mimeinfo-perl libimage-exiftool-perl webp libmagic1 locales poppler-utils python3 python3-pip uwsgi uwsgi-plugin-python3 supervisor build-essential libjpeg-dev libmagickwand-dev libpq-dev python3-dev python3-venv"
|
||||||
|
|
||||||
|
extras.yarn.repo = "deb https://dl.yarnpkg.com/debian/ stable main"
|
||||||
|
extras.yarn.key = "https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||||
|
extras.yarn.packages = "yarn"
|
||||||
|
|
||||||
|
[resources.database]
|
||||||
|
type = "postgresql"
|
|
@ -4,15 +4,6 @@
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# dependencies used by the app
|
|
||||||
pkg_dependencies="postgresql ghostscript git imagemagick iproute2 libfile-mimeinfo-perl libimage-exiftool-perl webp libmagic1 locales poppler-utils python3 python3-pip uwsgi uwsgi-plugin-python3 supervisor redis-server"
|
|
||||||
|
|
||||||
preview_pkg_dependencies="ffmpeg xvfb inkscape libreoffice"
|
|
||||||
|
|
||||||
pkg_dependencies="$pkg_dependencies $preview_pkg_dependencies"
|
|
||||||
|
|
||||||
build_pkg_dependencies="build-essential libjpeg-dev libmagickwand-dev libpq-dev python3-dev python3-venv"
|
|
||||||
|
|
||||||
nodejs_version=14
|
nodejs_version=14
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -26,3 +17,212 @@ nodejs_version=14
|
||||||
#=================================================
|
#=================================================
|
||||||
# FUTURE OFFICIAL HELPERS
|
# FUTURE OFFICIAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
# get the first available redis database
|
||||||
|
#
|
||||||
|
# usage: ynh_redis_get_free_db
|
||||||
|
# | returns: the database number to use
|
||||||
|
ynh_redis_get_free_db() {
|
||||||
|
local result max db
|
||||||
|
result=$(redis-cli INFO keyspace)
|
||||||
|
|
||||||
|
# get the num
|
||||||
|
max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+")
|
||||||
|
|
||||||
|
db=0
|
||||||
|
# default Debian setting is 15 databases
|
||||||
|
for i in $(seq 0 "$max")
|
||||||
|
do
|
||||||
|
if ! echo "$result" | grep -q "db$i"
|
||||||
|
then
|
||||||
|
db=$i
|
||||||
|
break 1
|
||||||
|
fi
|
||||||
|
db=-1
|
||||||
|
done
|
||||||
|
|
||||||
|
test "$db" -eq -1 && ynh_die --message="No available Redis databases..."
|
||||||
|
|
||||||
|
echo "$db"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create a master password and set up global settings
|
||||||
|
# Please always call this script in install and restore scripts
|
||||||
|
#
|
||||||
|
# usage: ynh_redis_remove_db database
|
||||||
|
# | arg: database - the database to erase
|
||||||
|
ynh_redis_remove_db() {
|
||||||
|
local db=$1
|
||||||
|
redis-cli -n "$db" flushall
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
|
||||||
|
# Create a dedicated supervisor config
|
||||||
|
#
|
||||||
|
# usage: ynh_add_supervisor_config [--service=service] [--template=template]
|
||||||
|
# | arg: -s, --service= - Service name (optionnal, `$app` by default)
|
||||||
|
# | arg: -t, --template= - Name of template file (optionnal, this is 'supervisor' by default, meaning ./conf/supervisor.service will be used as template)
|
||||||
|
#
|
||||||
|
# This will use the template `../conf/<templatename>.service`.
|
||||||
|
#
|
||||||
|
# See the documentation of `ynh_add_config` for a description of the template
|
||||||
|
# format and how placeholders are replaced with actual variables.
|
||||||
|
#
|
||||||
|
# Requires YunoHost version 2.7.11 or higher.
|
||||||
|
ynh_add_supervisor_config () {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
local legacy_args=stv
|
||||||
|
local -A args_array=( [s]=service= [t]=template= [v]=others_var=)
|
||||||
|
local service
|
||||||
|
local template
|
||||||
|
local others_var
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
local service="${service:-$app}"
|
||||||
|
local template="${template:-supervisor.service}"
|
||||||
|
others_var="${others_var:-}"
|
||||||
|
|
||||||
|
[[ -z "$others_var" ]] || ynh_print_warn --message="Packagers: using others_var is unecessary since Yunohost 4.2"
|
||||||
|
|
||||||
|
ynh_add_config --template="$YNH_APP_BASEDIR/conf/$template" --destination="/etc/supervisor/conf.d/$service.conf"
|
||||||
|
|
||||||
|
supervisorctl reread
|
||||||
|
supervisorctl update
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove the dedicated supervisor config
|
||||||
|
#
|
||||||
|
# usage: ynh_remove_supervisor_config [--service=service]
|
||||||
|
# | arg: -s, --service= - Service name (optionnal, $app by default)
|
||||||
|
#
|
||||||
|
# Requires YunoHost version 2.7.2 or higher.
|
||||||
|
ynh_remove_supervisor_config () {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
local legacy_args=s
|
||||||
|
local -A args_array=( [s]=service= )
|
||||||
|
local service
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
local service="${service:-$app}"
|
||||||
|
|
||||||
|
local finalsupervisorconf="/etc/supervisor/conf.d/$service.conf"
|
||||||
|
if [ -e "$finalsupervisorconf" ]
|
||||||
|
then
|
||||||
|
ynh_supervisor_action --service_name=$service --action=stop
|
||||||
|
ynh_secure_remove --file="$finalsupervisorconf"
|
||||||
|
supervisorctl reread
|
||||||
|
supervisorctl update
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
|
||||||
|
#
|
||||||
|
# usage: ynh_supervisor_action [--service_name=service_name] [--action=action] [ [--line_match="line to match"] [--log_path=log_path] [--timeout=300] [--length=20] ]
|
||||||
|
# | arg: -n, --service_name= - Name of the service to start. Default : `$app`
|
||||||
|
# | arg: -a, --action= - Action to perform with supervisorctl. Default: start
|
||||||
|
# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. If not defined it don't wait until the service is completely started.
|
||||||
|
# | arg: -p, --log_path= - Log file - Path to the log file. Default : `/var/log/$app/$app.log`
|
||||||
|
# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds.
|
||||||
|
# | arg: -e, --length= - Length of the error log : Default : 20
|
||||||
|
#
|
||||||
|
# Requires YunoHost version 3.5.0 or higher.
|
||||||
|
ynh_supervisor_action() {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
local legacy_args=nalpte
|
||||||
|
declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= )
|
||||||
|
local service_name
|
||||||
|
local action
|
||||||
|
local line_match
|
||||||
|
local length
|
||||||
|
local log_path
|
||||||
|
local timeout
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
service_name="${service_name:-$app}"
|
||||||
|
action=${action:-start}
|
||||||
|
line_match=${line_match:-}
|
||||||
|
length=${length:-20}
|
||||||
|
log_path="${log_path:-/var/log/$service_name/$service_name.log}"
|
||||||
|
timeout=${timeout:-300}
|
||||||
|
|
||||||
|
# Start to read the log
|
||||||
|
if [[ -n "$line_match" ]]
|
||||||
|
then
|
||||||
|
local templog="$(mktemp)"
|
||||||
|
# Following the starting of the app in its log
|
||||||
|
if [ "$log_path" == "systemd" ]
|
||||||
|
then
|
||||||
|
# Read the supervisor journal
|
||||||
|
journalctl --unit=supervisor --follow --since=-0 --quiet > "$templog" &
|
||||||
|
# Get the PID of the journalctl command
|
||||||
|
local pid_tail=$!
|
||||||
|
else
|
||||||
|
# Read the specified log file
|
||||||
|
tail --follow=name --retry --lines=0 "$log_path" > "$templog" 2>&1 &
|
||||||
|
# Get the PID of the tail command
|
||||||
|
local pid_tail=$!
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use reload-or-restart instead of reload. So it wouldn't fail if the service isn't running.
|
||||||
|
if [ "$action" == "reload" ]; then
|
||||||
|
action="update"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the service fails to perform the action
|
||||||
|
if ! supervisorctl $action $service_name
|
||||||
|
then
|
||||||
|
# Show syslog for this service
|
||||||
|
ynh_exec_err journalctl --quiet --no-hostname --no-pager --lines=$length --unit=$service_name
|
||||||
|
# If a log is specified for this service, show also the content of this log
|
||||||
|
if [ -e "$log_path" ]
|
||||||
|
then
|
||||||
|
ynh_exec_err tail --lines=$length "$log_path"
|
||||||
|
fi
|
||||||
|
ynh_clean_check_starting
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start the timeout and try to find line_match
|
||||||
|
if [[ -n "${line_match:-}" ]]
|
||||||
|
then
|
||||||
|
set +x
|
||||||
|
local i=0
|
||||||
|
for i in $(seq 1 $timeout)
|
||||||
|
do
|
||||||
|
# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
|
||||||
|
if grep --extended-regexp --quiet "$line_match" "$templog"
|
||||||
|
then
|
||||||
|
ynh_print_info --message="The service $service_name has correctly executed the action ${action}."
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if [ $i -eq 3 ]; then
|
||||||
|
echo -n "Please wait, the service $service_name is ${action}ing" >&2
|
||||||
|
fi
|
||||||
|
if [ $i -ge 3 ]; then
|
||||||
|
echo -n "." >&2
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
set -x
|
||||||
|
if [ $i -ge 3 ]; then
|
||||||
|
echo "" >&2
|
||||||
|
fi
|
||||||
|
if [ $i -eq $timeout ]
|
||||||
|
then
|
||||||
|
ynh_print_warn --message="The service $service_name didn't fully executed the action ${action} before the timeout."
|
||||||
|
ynh_print_warn --message="Please find here an extract of the end of the log of the service $service_name:"
|
||||||
|
ynh_exec_warn journalctl --quiet --no-hostname --no-pager --lines=$length --unit=$service_name
|
||||||
|
if [ -e "$log_path" ]
|
||||||
|
then
|
||||||
|
ynh_print_warn --message="\-\-\-"
|
||||||
|
ynh_exec_warn tail --lines=$length "$log_path"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
ynh_clean_check_starting
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
|
@ -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,13 +19,13 @@ ynh_print_info --message="Declaring files to be backed up..."
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$final_path"
|
ynh_backup --src_path="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE DATA DIR
|
# BACKUP THE DATA DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$datadir" --is_big
|
ynh_backup --src_path="$data_dir" --is_big
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
|
|
@ -7,75 +7,8 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source ynh_supervisor
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RETRIEVE ARGUMENTS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
old_domain=$YNH_APP_OLD_DOMAIN
|
|
||||||
old_path=$YNH_APP_OLD_PATH
|
|
||||||
|
|
||||||
new_domain=$YNH_APP_NEW_DOMAIN
|
|
||||||
new_path="/"
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
|
||||||
|
|
||||||
# Needed for helper "ynh_add_nginx_config"
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
||||||
|
|
||||||
# Add settings here as needed by your application
|
|
||||||
language=$(ynh_app_setting_get --app=$app --key=language)
|
|
||||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
||||||
db_user=$db_name
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
|
||||||
api_key=$(ynh_app_setting_get --app=$app --key=api_key)
|
|
||||||
session_secret=$(ynh_app_setting_get --app=$app --key=session_secret)
|
|
||||||
website_title=$(ynh_app_setting_get --app=$app --key=website_title)
|
|
||||||
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
|
|
||||||
|
|
||||||
# Backup the current version of the app
|
|
||||||
ynh_backup_before_upgrade
|
|
||||||
ynh_clean_setup () {
|
|
||||||
ynh_clean_check_starting
|
|
||||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
|
||||||
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
|
||||||
|
|
||||||
# Restore it if the upgrade fails
|
|
||||||
ynh_restore_upgradebackup
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
change_domain=0
|
|
||||||
if [ "$old_domain" != "$new_domain" ]
|
|
||||||
then
|
|
||||||
change_domain=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
change_path=0
|
|
||||||
if [ "$old_path" != "$new_path" ]
|
|
||||||
then
|
|
||||||
change_path=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -83,29 +16,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating NGINX web server configuration..."
|
ynh_script_progression --message="Updating NGINX web server configuration..."
|
||||||
|
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
ynh_change_url_nginx_config
|
||||||
|
|
||||||
# Change the path in the NGINX config file
|
|
||||||
if [ $change_path -eq 1 ]
|
|
||||||
then
|
|
||||||
# Make a backup of the original NGINX config file if modified
|
|
||||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
|
||||||
# Set global variables for NGINX helper
|
|
||||||
domain="$old_domain"
|
|
||||||
path_url="$new_path"
|
|
||||||
# Create a dedicated NGINX config
|
|
||||||
ynh_add_nginx_config
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Change the domain for NGINX
|
|
||||||
if [ $change_domain -eq 1 ]
|
|
||||||
then
|
|
||||||
# Delete file checksum for the old conf file location
|
|
||||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
|
||||||
# Store file checksum for the new config file location
|
|
||||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC MODIFICATIONS
|
# SPECIFIC MODIFICATIONS
|
||||||
|
@ -113,17 +24,17 @@ fi
|
||||||
# UPDATE A CONFIG FILE
|
# UPDATE A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating a configuration file..."
|
ynh_script_progression --message="Updating a configuration file..."
|
||||||
|
#REMOVEME?
|
||||||
domain=$new_domain
|
domain=$new_domain
|
||||||
path_url=$new_path
|
path=$new_path
|
||||||
|
|
||||||
ynh_add_config --template="../conf/development.ini.sample" --destination="$final_path/backend/development.ini"
|
ynh_add_config --template="../conf/development.ini.sample" --destination="$install_dir/backend/development.ini"
|
||||||
chmod 400 "$final_path/backend/development.ini"
|
chmod 400 "$install_dir/backend/development.ini"
|
||||||
chown $app:$app "$final_path/backend/development.ini"
|
chown $app:$app "$install_dir/backend/development.ini"
|
||||||
|
|
||||||
ynh_add_config --template="../conf/configEnv.json.sample" --destination="$final_path/frontend/configEnv.json"
|
ynh_add_config --template="../conf/configEnv.json.sample" --destination="$install_dir/frontend/configEnv.json"
|
||||||
chmod 400 "$final_path/frontend/configEnv.json"
|
chmod 400 "$install_dir/frontend/configEnv.json"
|
||||||
chown $app:$app "$final_path/frontend/configEnv.json"
|
chown $app:$app "$install_dir/frontend/configEnv.json"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
|
@ -135,13 +46,6 @@ ynh_script_progression --message="Starting a systemd service..."
|
||||||
# Start a systemd service
|
# Start a systemd service
|
||||||
ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app-web.log" --line_match="spawned uWSGI"
|
ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app-web.log" --line_match="spawned uWSGI"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Reloading NGINX web server..."
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
147
scripts/install
147
scripts/install
|
@ -7,114 +7,42 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source ynh_supervisor
|
|
||||||
source ynh_redis
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# MANAGE SCRIPT FAILURE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_clean_setup () {
|
|
||||||
ynh_clean_check_starting
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
|
||||||
path_url="/"
|
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
||||||
language=$YNH_APP_ARG_LANGUAGE
|
|
||||||
admin=$YNH_APP_ARG_ADMIN
|
|
||||||
password=$YNH_APP_ARG_PASSWORD
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
api_key=$(ynh_string_random --length=8)
|
api_key=$(ynh_string_random --length=8)
|
||||||
session_secret=$(ynh_string_random --length=8)
|
session_secret=$(ynh_string_random --length=8)
|
||||||
website_title="YunoHost Tracim"
|
website_title="YunoHost Tracim"
|
||||||
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
|
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Validating installation parameters..."
|
|
||||||
|
|
||||||
final_path=/var/www/$app
|
|
||||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
|
||||||
|
|
||||||
# Register (book) web path
|
|
||||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Storing installation settings..."
|
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
|
||||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
|
||||||
ynh_app_setting_set --app=$app --key=language --value=$language
|
|
||||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
|
||||||
ynh_app_setting_set --app=$app --key=api_key --value=$api_key
|
ynh_app_setting_set --app=$app --key=api_key --value=$api_key
|
||||||
ynh_app_setting_set --app=$app --key=session_secret --value=$session_secret
|
ynh_app_setting_set --app=$app --key=session_secret --value=$session_secret
|
||||||
ynh_app_setting_set --app=$app --key=website_title --value=$website_title
|
ynh_app_setting_set --app=$app --key=website_title --value=$website_title
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD MODIFICATIONS
|
|
||||||
#=================================================
|
|
||||||
# FIND AND OPEN A PORT
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Finding an available port..."
|
|
||||||
|
|
||||||
# Find an available port
|
|
||||||
port=$(ynh_find_port --port=8095)
|
|
||||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..."
|
ynh_script_progression --message="Installing dependencies..."
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_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"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CREATE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring system user..."
|
|
||||||
|
|
||||||
# Create a system user
|
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CREATE A POSTGRESQL DATABASE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Creating a PostgreSQL database..."
|
|
||||||
|
|
||||||
ynh_psql_test_if_first_run
|
|
||||||
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_psql_setup_db --db_user=$db_user --db_name=$db_name
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setting up source files..."
|
ynh_script_progression --message="Setting up source files..."
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --dest_dir="$final_path"
|
ynh_setup_source --dest_dir="$install_dir"
|
||||||
|
|
||||||
chmod 750 "$final_path"
|
chmod -R o-rwx "$install_dir"
|
||||||
chmod -R o-rwx "$final_path"
|
chown -R $app:www-data "$install_dir"
|
||||||
chown -R $app:www-data "$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -124,24 +52,6 @@ ynh_script_progression --message="Configuring NGINX web server..."
|
||||||
# Create a dedicated NGINX config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC SETUP
|
|
||||||
#=================================================
|
|
||||||
# CREATE DATA DIRECTORY
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Creating a data directory..."
|
|
||||||
|
|
||||||
datadir=/home/yunohost.app/$app
|
|
||||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
|
||||||
|
|
||||||
mkdir -p $datadir
|
|
||||||
mkdir -p $datadir/depot
|
|
||||||
mkdir -p $datadir/radicale_storage
|
|
||||||
|
|
||||||
chmod 750 "$datadir"
|
|
||||||
chmod -R o-rwx "$datadir"
|
|
||||||
chown -R $app:www-data "$datadir"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD A CONFIGURATION
|
# ADD A CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -150,27 +60,25 @@ ynh_script_progression --message="Adding a configuration file..."
|
||||||
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
|
||||||
|
|
||||||
ynh_add_config --template="../conf/development.ini.sample" --destination="$final_path/backend/development.ini"
|
ynh_add_config --template="../conf/development.ini.sample" --destination="$install_dir/backend/development.ini"
|
||||||
chmod 400 "$final_path/backend/development.ini"
|
chmod 400 "$install_dir/backend/development.ini"
|
||||||
chown $app:$app "$final_path/backend/development.ini"
|
chown $app:$app "$install_dir/backend/development.ini"
|
||||||
|
|
||||||
ynh_add_config --template="../conf/configEnv.json.sample" --destination="$final_path/frontend/configEnv.json"
|
ynh_add_config --template="../conf/configEnv.json.sample" --destination="$install_dir/frontend/configEnv.json"
|
||||||
chmod 400 "$final_path/frontend/configEnv.json"
|
chmod 400 "$install_dir/frontend/configEnv.json"
|
||||||
chown $app:$app "$final_path/frontend/configEnv.json"
|
chown $app:$app "$install_dir/frontend/configEnv.json"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD APP
|
# BUILD APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Building app..."
|
ynh_script_progression --message="Building app..."
|
||||||
|
|
||||||
cp -r $final_path/frontend/dist/assets/branding.sample $final_path/frontend/dist/assets/branding
|
cp -r $install_dir/frontend/dist/assets/branding.sample $install_dir/frontend/dist/assets/branding
|
||||||
|
|
||||||
pushd "$final_path/backend"
|
pushd "$install_dir/backend"
|
||||||
ynh_use_nodejs
|
ynh_use_nodejs
|
||||||
python3 -m venv env
|
python3 -m venv env
|
||||||
set +u;
|
|
||||||
source env/bin/activate
|
source env/bin/activate
|
||||||
set -u;
|
|
||||||
ynh_exec_warn_less pip install -r requirements-build.txt
|
ynh_exec_warn_less pip install -r requirements-build.txt
|
||||||
ynh_exec_warn_less pip install -r requirements.txt
|
ynh_exec_warn_less pip install -r requirements.txt
|
||||||
ynh_exec_warn_less pip install -r requirements-full-preview-generator.txt
|
ynh_exec_warn_less pip install -r requirements-full-preview-generator.txt
|
||||||
|
@ -180,25 +88,20 @@ pushd "$final_path/backend"
|
||||||
ynh_exec_warn_less tracimcli db init
|
ynh_exec_warn_less tracimcli db init
|
||||||
ynh_exec_warn_less tracimcli user create -e $admin_mail -u $admin --lang $language -p $password --profile administrators
|
ynh_exec_warn_less tracimcli user create -e $admin_mail -u $admin --lang $language -p $password --profile administrators
|
||||||
ynh_exec_warn_less tracimcli user delete -l admin@admin.admin
|
ynh_exec_warn_less tracimcli user delete -l admin@admin.admin
|
||||||
set +u;
|
|
||||||
deactivate
|
deactivate
|
||||||
set -u;
|
|
||||||
ynh_exec_warn_less $ynh_npm install "i18next-conv@<8" -g
|
ynh_exec_warn_less $ynh_npm install "i18next-conv@<8" -g
|
||||||
ynh_exec_warn_less ./update_i18n_json_file.sh || exit 1
|
ynh_exec_warn_less ./update_i18n_json_file.sh || exit 1
|
||||||
popd
|
popd
|
||||||
|
|
||||||
pushd "$final_path"
|
pushd "$install_dir"
|
||||||
echo 'nodeLinker: node-modules' >> .yarnrc.yml
|
echo 'nodeLinker: node-modules' >> .yarnrc.yml
|
||||||
ynh_exec_warn_less yarn install
|
ynh_exec_warn_less yarn install
|
||||||
ynh_exec_warn_less ./build_full_frontend.sh
|
ynh_exec_warn_less ./build_full_frontend.sh
|
||||||
popd
|
popd
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
chmod 750 "$install_dir"
|
||||||
ynh_exec_warn_less ynh_package_autoremove
|
chmod -R o-rwx "$install_dir"
|
||||||
|
chown -R $app:www-data "$install_dir"
|
||||||
chmod 750 "$final_path"
|
|
||||||
chmod -R o-rwx "$final_path"
|
|
||||||
chown -R $app:www-data "$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
|
@ -241,26 +144,6 @@ ynh_script_progression --message="Starting a systemd service..."
|
||||||
# Start a systemd service
|
# Start a systemd service
|
||||||
ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app-web.log" --line_match="spawned uWSGI"
|
ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app-web.log" --line_match="spawned uWSGI"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP SSOWAT
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring permissions..."
|
|
||||||
|
|
||||||
# Make app public if necessary
|
|
||||||
if [ $is_public -eq 1 ]
|
|
||||||
then
|
|
||||||
# Everyone can access the app.
|
|
||||||
# The "main" permission is automatically created before the install script.
|
|
||||||
ynh_permission_update --permission="main" --add="visitors"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Reloading NGINX web server..."
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -7,25 +7,8 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source ynh_supervisor
|
|
||||||
source ynh_redis
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
||||||
db_user=$db_name
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
|
||||||
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -60,33 +43,6 @@ ynh_secure_remove --file="/etc/uwsgi/apps-enabled/$app-caldav.ini"
|
||||||
ynh_secure_remove --file="/etc/uwsgi/apps-available/$app-caldav.ini"
|
ynh_secure_remove --file="/etc/uwsgi/apps-available/$app-caldav.ini"
|
||||||
ynh_systemd_action --service_name="uwsgi" --action="restart"
|
ynh_systemd_action --service_name="uwsgi" --action="restart"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE THE POSTGRESQL DATABASE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing the PostgreSQL database..."
|
|
||||||
|
|
||||||
# Remove a database if it exists, along with the associated user
|
|
||||||
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE APP MAIN DIR
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing app main directory..."
|
|
||||||
|
|
||||||
# Remove the app directory securely
|
|
||||||
ynh_secure_remove --file="$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE DATA DIR
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Remove the data directory if --purge option is used
|
|
||||||
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
|
|
||||||
then
|
|
||||||
ynh_script_progression --message="Removing app data directory..."
|
|
||||||
ynh_secure_remove --file="$datadir"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NGINX CONFIGURATION
|
# REMOVE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -98,12 +54,11 @@ ynh_remove_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEPENDENCIES
|
# REMOVE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing dependencies..."
|
#REMOVEME? ynh_script_progression --message="Removing dependencies..."
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
# Remove metapackage and its dependencies
|
||||||
ynh_redis_remove_db "$redis_db"
|
ynh_redis_remove_db "$redis_db"
|
||||||
ynh_remove_nodejs
|
ynh_remove_nodejs
|
||||||
ynh_remove_app_dependencies
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC REMOVE
|
# SPECIFIC REMOVE
|
||||||
|
@ -117,16 +72,6 @@ ynh_secure_remove --file="/var/log/uwsgi/app/$app-web.log"
|
||||||
ynh_secure_remove --file="/var/log/uwsgi/app/$app-webdav.log"
|
ynh_secure_remove --file="/var/log/uwsgi/app/$app-webdav.log"
|
||||||
ynh_secure_remove --file="/var/log/uwsgi/app/$app-caldav.log"
|
ynh_secure_remove --file="/var/log/uwsgi/app/$app-caldav.log"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
|
||||||
# REMOVE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing the dedicated system user..."
|
|
||||||
|
|
||||||
# Delete a system user
|
|
||||||
ynh_system_user_delete --username=$app
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -8,41 +8,8 @@
|
||||||
|
|
||||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source ../settings/scripts/ynh_supervisor
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# MANAGE SCRIPT FAILURE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_clean_setup () {
|
|
||||||
ynh_clean_check_starting
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|
||||||
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)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Validating restoration parameters..."
|
|
||||||
|
|
||||||
test ! -d $final_path \
|
|
||||||
|| ynh_die --message="There is already a directory: $final_path "
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORATION STEPS
|
# STANDARD RESTORATION STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -52,39 +19,24 @@ ynh_script_progression --message="Restoring the NGINX web server configuration..
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RECREATE THE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the app main directory..."
|
ynh_script_progression --message="Restoring the app main directory..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$final_path"
|
ynh_restore_file --origin_path="$install_dir"
|
||||||
|
|
||||||
chmod 750 "$final_path"
|
chmod -R o-rwx "$install_dir"
|
||||||
chmod -R o-rwx "$final_path"
|
chown -R $app:www-data "$install_dir"
|
||||||
chown -R $app:www-data "$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE DATA DIRECTORY
|
# RESTORE THE DATA DIRECTORY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the data directory..."
|
ynh_script_progression --message="Restoring the data directory..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$datadir" --not_mandatory
|
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
||||||
|
|
||||||
mkdir -p $datadir
|
chown -R $app:www-data "$data_dir"
|
||||||
mkdir -p $datadir/depot
|
|
||||||
mkdir -p $datadir/radicale_storage
|
|
||||||
|
|
||||||
chmod 750 "$datadir"
|
|
||||||
chmod -R o-rwx "$datadir"
|
|
||||||
chown -R $app:www-data "$datadir"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# SPECIFIC RESTORATION
|
||||||
|
@ -94,18 +46,13 @@ chown -R $app:www-data "$datadir"
|
||||||
ynh_script_progression --message="Reinstalling dependencies..."
|
ynh_script_progression --message="Reinstalling dependencies..."
|
||||||
|
|
||||||
# Define and install dependencies
|
# Define and install dependencies
|
||||||
ynh_exec_warn_less 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"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE POSTGRESQL DATABASE
|
# RESTORE THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the PostgreSQL database..."
|
ynh_script_progression --message="Restoring the PostgreSQL database..."
|
||||||
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
|
||||||
ynh_psql_test_if_first_run
|
|
||||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
|
||||||
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
|
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
110
scripts/upgrade
110
scripts/upgrade
|
@ -7,75 +7,14 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source ynh_supervisor
|
|
||||||
source ynh_redis
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|
||||||
language=$(ynh_app_setting_get --app=$app --key=language)
|
|
||||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
||||||
db_user=$db_name
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
|
||||||
api_key=$(ynh_app_setting_get --app=$app --key=api_key)
|
|
||||||
session_secret=$(ynh_app_setting_get --app=$app --key=session_secret)
|
|
||||||
website_title=$(ynh_app_setting_get --app=$app --key=website_title)
|
|
||||||
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Checking version..."
|
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
|
||||||
|
|
||||||
# Backup the current version of the app
|
|
||||||
ynh_backup_before_upgrade
|
|
||||||
ynh_clean_setup () {
|
|
||||||
ynh_clean_check_starting
|
|
||||||
# Restore it if the upgrade fails
|
|
||||||
ynh_restore_upgradebackup
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD UPGRADE STEPS
|
|
||||||
#=================================================
|
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
|
||||||
|
|
||||||
# Cleaning legacy permissions
|
|
||||||
if ynh_legacy_permissions_exists; then
|
|
||||||
ynh_legacy_permissions_delete_all
|
|
||||||
|
|
||||||
ynh_app_setting_delete --app=$app --key=is_public
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CREATE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -85,12 +24,11 @@ then
|
||||||
ynh_script_progression --message="Upgrading source files..."
|
ynh_script_progression --message="Upgrading source files..."
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --dest_dir="$final_path" --keep="backend/development.ini frontend/configEnv.json"
|
ynh_setup_source --dest_dir="$install_dir" --keep="backend/development.ini frontend/configEnv.json"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod 750 "$final_path"
|
chmod -R o-rwx "$install_dir"
|
||||||
chmod -R o-rwx "$final_path"
|
chown -R $app:www-data "$install_dir"
|
||||||
chown -R $app:www-data "$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -105,9 +43,7 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..."
|
ynh_script_progression --message="Upgrading dependencies..."
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_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"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
|
@ -116,52 +52,45 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating a configuration file..."
|
ynh_script_progression --message="Updating a configuration file..."
|
||||||
|
|
||||||
ynh_add_config --template="../conf/development.ini.sample" --destination="$final_path/backend/development.ini"
|
ynh_add_config --template="../conf/development.ini.sample" --destination="$install_dir/backend/development.ini"
|
||||||
chmod 400 "$final_path/backend/development.ini"
|
chmod 400 "$install_dir/backend/development.ini"
|
||||||
chown $app:$app "$final_path/backend/development.ini"
|
chown $app:$app "$install_dir/backend/development.ini"
|
||||||
|
|
||||||
ynh_add_config --template="../conf/configEnv.json.sample" --destination="$final_path/frontend/configEnv.json"
|
ynh_add_config --template="../conf/configEnv.json.sample" --destination="$install_dir/frontend/configEnv.json"
|
||||||
chmod 400 "$final_path/frontend/configEnv.json"
|
chmod 400 "$install_dir/frontend/configEnv.json"
|
||||||
chown $app:$app "$final_path/frontend/configEnv.json"
|
chown $app:$app "$install_dir/frontend/configEnv.json"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD APP
|
# BUILD APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Building app..."
|
ynh_script_progression --message="Building app..."
|
||||||
|
|
||||||
cp -r $final_path/frontend/dist/assets/branding.sample $final_path/frontend/dist/assets/branding
|
cp -r $install_dir/frontend/dist/assets/branding.sample $install_dir/frontend/dist/assets/branding
|
||||||
|
|
||||||
pushd "$final_path/backend"
|
pushd "$install_dir/backend"
|
||||||
ynh_use_nodejs
|
ynh_use_nodejs
|
||||||
ynh_secure_remove --file="$final_path/backend/env"
|
ynh_secure_remove --file="$install_dir/backend/env"
|
||||||
python3 -m venv env
|
python3 -m venv env
|
||||||
set +u;
|
|
||||||
source env/bin/activate
|
source env/bin/activate
|
||||||
set -u;
|
|
||||||
ynh_exec_warn_less pip install -r requirements-build.txt
|
ynh_exec_warn_less pip install -r requirements-build.txt
|
||||||
ynh_exec_warn_less ynh_exec_warn_less pip install -r requirements.txt
|
ynh_exec_warn_less ynh_exec_warn_less pip install -r requirements.txt
|
||||||
ynh_exec_warn_less pip install -r requirements-full-preview-generator.txt
|
ynh_exec_warn_less pip install -r requirements-full-preview-generator.txt
|
||||||
ynh_exec_warn_less pip install -r requirements-db-postgres.txt
|
ynh_exec_warn_less pip install -r requirements-db-postgres.txt
|
||||||
ynh_exec_warn_less pip install -e "."
|
ynh_exec_warn_less pip install -e "."
|
||||||
ynh_exec_warn_less alembic -c development.ini upgrade head
|
ynh_exec_warn_less alembic -c development.ini upgrade head
|
||||||
set +u;
|
|
||||||
deactivate
|
deactivate
|
||||||
set -u;
|
|
||||||
ynh_exec_warn_less $ynh_npm install "i18next-conv@<8" -g
|
ynh_exec_warn_less $ynh_npm install "i18next-conv@<8" -g
|
||||||
ynh_exec_warn_less ./update_i18n_json_file.sh || exit 1
|
ynh_exec_warn_less ./update_i18n_json_file.sh || exit 1
|
||||||
popd
|
popd
|
||||||
|
|
||||||
pushd "$final_path"
|
pushd "$install_dir"
|
||||||
ynh_exec_warn_less yarn install
|
ynh_exec_warn_less yarn install
|
||||||
ynh_exec_warn_less ./build_full_frontend.sh
|
ynh_exec_warn_less ./build_full_frontend.sh
|
||||||
popd
|
popd
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
chmod 750 "$install_dir"
|
||||||
ynh_exec_warn_less ynh_package_autoremove
|
chmod -R o-rwx "$install_dir"
|
||||||
|
chown -R $app:www-data "$install_dir"
|
||||||
chmod 750 "$final_path"
|
|
||||||
chmod -R o-rwx "$final_path"
|
|
||||||
chown -R $app:www-data "$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
|
@ -204,13 +133,6 @@ ynh_script_progression --message="Starting a systemd service..."
|
||||||
# Start a systemd service
|
# Start a systemd service
|
||||||
ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app-web.log" --line_match="spawned uWSGI"
|
ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app-web.log" --line_match="spawned uWSGI"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Reloading NGINX web server..."
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# get the first available redis database
|
|
||||||
#
|
|
||||||
# usage: ynh_redis_get_free_db
|
|
||||||
# | returns: the database number to use
|
|
||||||
ynh_redis_get_free_db() {
|
|
||||||
local result max db
|
|
||||||
result=$(redis-cli INFO keyspace)
|
|
||||||
|
|
||||||
# get the num
|
|
||||||
max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+")
|
|
||||||
|
|
||||||
db=0
|
|
||||||
# default Debian setting is 15 databases
|
|
||||||
for i in $(seq 0 "$max")
|
|
||||||
do
|
|
||||||
if ! echo "$result" | grep -q "db$i"
|
|
||||||
then
|
|
||||||
db=$i
|
|
||||||
break 1
|
|
||||||
fi
|
|
||||||
db=-1
|
|
||||||
done
|
|
||||||
|
|
||||||
test "$db" -eq -1 && ynh_die --message="No available Redis databases..."
|
|
||||||
|
|
||||||
echo "$db"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create a master password and set up global settings
|
|
||||||
# Please always call this script in install and restore scripts
|
|
||||||
#
|
|
||||||
# usage: ynh_redis_remove_db database
|
|
||||||
# | arg: database - the database to erase
|
|
||||||
ynh_redis_remove_db() {
|
|
||||||
local db=$1
|
|
||||||
redis-cli -n "$db" flushall
|
|
||||||
}
|
|
|
@ -1,167 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Create a dedicated supervisor config
|
|
||||||
#
|
|
||||||
# usage: ynh_add_supervisor_config [--service=service] [--template=template]
|
|
||||||
# | arg: -s, --service= - Service name (optionnal, `$app` by default)
|
|
||||||
# | arg: -t, --template= - Name of template file (optionnal, this is 'supervisor' by default, meaning ./conf/supervisor.service will be used as template)
|
|
||||||
#
|
|
||||||
# This will use the template `../conf/<templatename>.service`.
|
|
||||||
#
|
|
||||||
# See the documentation of `ynh_add_config` for a description of the template
|
|
||||||
# format and how placeholders are replaced with actual variables.
|
|
||||||
#
|
|
||||||
# Requires YunoHost version 2.7.11 or higher.
|
|
||||||
ynh_add_supervisor_config () {
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local legacy_args=stv
|
|
||||||
local -A args_array=( [s]=service= [t]=template= [v]=others_var=)
|
|
||||||
local service
|
|
||||||
local template
|
|
||||||
local others_var
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
local service="${service:-$app}"
|
|
||||||
local template="${template:-supervisor.service}"
|
|
||||||
others_var="${others_var:-}"
|
|
||||||
|
|
||||||
[[ -z "$others_var" ]] || ynh_print_warn --message="Packagers: using --others_var is unecessary since Yunohost 4.2"
|
|
||||||
|
|
||||||
ynh_add_config --template="$YNH_APP_BASEDIR/conf/$template" --destination="/etc/supervisor/conf.d/$service.conf"
|
|
||||||
|
|
||||||
supervisorctl reread
|
|
||||||
supervisorctl update
|
|
||||||
}
|
|
||||||
|
|
||||||
# Remove the dedicated supervisor config
|
|
||||||
#
|
|
||||||
# usage: ynh_remove_supervisor_config [--service=service]
|
|
||||||
# | arg: -s, --service= - Service name (optionnal, $app by default)
|
|
||||||
#
|
|
||||||
# Requires YunoHost version 2.7.2 or higher.
|
|
||||||
ynh_remove_supervisor_config () {
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local legacy_args=s
|
|
||||||
local -A args_array=( [s]=service= )
|
|
||||||
local service
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
local service="${service:-$app}"
|
|
||||||
|
|
||||||
local finalsupervisorconf="/etc/supervisor/conf.d/$service.conf"
|
|
||||||
if [ -e "$finalsupervisorconf" ]
|
|
||||||
then
|
|
||||||
ynh_supervisor_action --service_name=$service --action=stop
|
|
||||||
ynh_secure_remove --file="$finalsupervisorconf"
|
|
||||||
supervisorctl reread
|
|
||||||
supervisorctl update
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
|
|
||||||
#
|
|
||||||
# usage: ynh_supervisor_action [--service_name=service_name] [--action=action] [ [--line_match="line to match"] [--log_path=log_path] [--timeout=300] [--length=20] ]
|
|
||||||
# | arg: -n, --service_name= - Name of the service to start. Default : `$app`
|
|
||||||
# | arg: -a, --action= - Action to perform with supervisorctl. Default: start
|
|
||||||
# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. If not defined it don't wait until the service is completely started.
|
|
||||||
# | arg: -p, --log_path= - Log file - Path to the log file. Default : `/var/log/$app/$app.log`
|
|
||||||
# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds.
|
|
||||||
# | arg: -e, --length= - Length of the error log : Default : 20
|
|
||||||
#
|
|
||||||
# Requires YunoHost version 3.5.0 or higher.
|
|
||||||
ynh_supervisor_action() {
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local legacy_args=nalpte
|
|
||||||
declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= )
|
|
||||||
local service_name
|
|
||||||
local action
|
|
||||||
local line_match
|
|
||||||
local length
|
|
||||||
local log_path
|
|
||||||
local timeout
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
service_name="${service_name:-$app}"
|
|
||||||
action=${action:-start}
|
|
||||||
line_match=${line_match:-}
|
|
||||||
length=${length:-20}
|
|
||||||
log_path="${log_path:-/var/log/$service_name/$service_name.log}"
|
|
||||||
timeout=${timeout:-300}
|
|
||||||
|
|
||||||
# Start to read the log
|
|
||||||
if [[ -n "$line_match" ]]
|
|
||||||
then
|
|
||||||
local templog="$(mktemp)"
|
|
||||||
# Following the starting of the app in its log
|
|
||||||
if [ "$log_path" == "systemd" ]
|
|
||||||
then
|
|
||||||
# Read the supervisor journal
|
|
||||||
journalctl --unit=supervisor --follow --since=-0 --quiet > "$templog" &
|
|
||||||
# Get the PID of the journalctl command
|
|
||||||
local pid_tail=$!
|
|
||||||
else
|
|
||||||
# Read the specified log file
|
|
||||||
tail --follow=name --retry --lines=0 "$log_path" > "$templog" 2>&1 &
|
|
||||||
# Get the PID of the tail command
|
|
||||||
local pid_tail=$!
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Use reload-or-restart instead of reload. So it wouldn't fail if the service isn't running.
|
|
||||||
if [ "$action" == "reload" ]; then
|
|
||||||
action="update"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If the service fails to perform the action
|
|
||||||
if ! supervisorctl $action $service_name
|
|
||||||
then
|
|
||||||
# Show syslog for this service
|
|
||||||
ynh_exec_err journalctl --quiet --no-hostname --no-pager --lines=$length --unit=$service_name
|
|
||||||
# If a log is specified for this service, show also the content of this log
|
|
||||||
if [ -e "$log_path" ]
|
|
||||||
then
|
|
||||||
ynh_exec_err tail --lines=$length "$log_path"
|
|
||||||
fi
|
|
||||||
ynh_clean_check_starting
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Start the timeout and try to find line_match
|
|
||||||
if [[ -n "${line_match:-}" ]]
|
|
||||||
then
|
|
||||||
set +x
|
|
||||||
local i=0
|
|
||||||
for i in $(seq 1 $timeout)
|
|
||||||
do
|
|
||||||
# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
|
|
||||||
if grep --extended-regexp --quiet "$line_match" "$templog"
|
|
||||||
then
|
|
||||||
ynh_print_info --message="The service $service_name has correctly executed the action ${action}."
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
if [ $i -eq 3 ]; then
|
|
||||||
echo -n "Please wait, the service $service_name is ${action}ing" >&2
|
|
||||||
fi
|
|
||||||
if [ $i -ge 3 ]; then
|
|
||||||
echo -n "." >&2
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
set -x
|
|
||||||
if [ $i -ge 3 ]; then
|
|
||||||
echo "" >&2
|
|
||||||
fi
|
|
||||||
if [ $i -eq $timeout ]
|
|
||||||
then
|
|
||||||
ynh_print_warn --message="The service $service_name didn't fully executed the action ${action} before the timeout."
|
|
||||||
ynh_print_warn --message="Please find here an extract of the end of the log of the service $service_name:"
|
|
||||||
ynh_exec_warn journalctl --quiet --no-hostname --no-pager --lines=$length --unit=$service_name
|
|
||||||
if [ -e "$log_path" ]
|
|
||||||
then
|
|
||||||
ynh_print_warn --message="\-\-\-"
|
|
||||||
ynh_exec_warn tail --lines=$length "$log_path"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
ynh_clean_check_starting
|
|
||||||
fi
|
|
||||||
}
|
|
3
tests.toml
Normal file
3
tests.toml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
test_format = 1.0
|
||||||
|
|
||||||
|
[default]
|
Loading…
Reference in a new issue