1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/element_ynh.git synced 2024-09-03 18:36:08 +02:00

Merge pull request #30 from YunoHost-Apps/testing

Testing
This commit is contained in:
Alexandre Aubin 2021-12-31 01:35:53 +01:00 committed by GitHub
commit d11ef84f46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 736 additions and 309 deletions

136
.github/workflows/updater.sh vendored Executable file
View file

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

49
.github/workflows/updater.yml vendored Normal file
View file

@ -0,0 +1,49 @@
# 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

View file

@ -2,9 +2,3 @@
"name": "Element_ynh"
, "files": [ { "git": 1 } ]
}

124
README.md
View file

@ -1,86 +1,44 @@
Element For yunohost
=================
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
-->
# Element for YunoHost
[![Integration level](https://dash.yunohost.org/integration/element.svg)](https://dash.yunohost.org/appci/app/element) ![](https://ci-apps.yunohost.org/ci/badges/element.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/element.maintain.svg)
[![Install Element with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=element)
> *This package allow you to install Element quickly and simply on a YunoHost server.
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
*[Lire ce readme en français.](./README_fr.md)*
Overview
--------
> *This package allows you to install Element quickly and simply on a YunoHost server.
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
It's a webclient for matrix. For a matrix server you can install synapse on your server : https://github.com/YunoHost-Apps/synapse_ynh
## Overview
Yunohost chattroom with matrix : [https://app.element.io/#/room/#yunohost:matrix.org](https://app.element.io/#/room/#yunohost:matrix.org)
Element is a new type of messaging app. You choose where your messages are stored, putting you in control of your data. It gives you access to the Matrix open network, so you can talk to anyone. Element provides a new level of security, adding cross-signed device verification to default end-to-end encryption.
**Shipped version:** 1.8.5
**Shipped version:** 1.9.8~ynh1
Screenshots
-----------
**Demo:** https://app.element.io/
#### Own your conversations
## Screenshots
All-in-one secure chat app for teams, friends and organisations. Keeps conversations in your control, safe from data-mining and ads. Talk to everyone through the open global Matrix network, protected by proper end-to-end encryption.
![](./doc/screenshots/homepage-all-platforms-1_1.png)
![](https://element.io/images/homepage-all-platforms-1-p-800.png)
![](https://element.io/images/ios-room-chat-012x-p-500.png)
![](https://element.io/images/pixel4-rooms-light-012x-p-500.png)
## Disclaimers / important information
**Element gives you the privacy you expect from a conversation in your own home, but with everyone across the globe.**
##### Keep it personal
Group chat, video calls and sharing to stay in touch and coordinate with family and friends.
![](https://element.io/images/for-personal.png)
##### Revolutionise the workplace
Highly effective teamwork within a company, across a business ecosystem or an entire government.
![](https://element.io/images/temp-img-pro-use-01.png)
##### Host your community
From clubs to social movements, keep everyone together with a platform everyone can use.
![](https://element.io/images/temp-community-image-02.png)
Demo
----
* [Official demo](https://app.element.io/)
Documentation
-------------
* Official documentation: https://element.io/help
* YunoHost documentation: There no other documentations, feel free to contribute.
YunoHost specific features
--------------------------
## YunoHost specific features
### Multi-users support
Now this application support the sso. If you want to use the sso you need to define the path to the default homeserver as your homeserver witch is installed on your yunohost instance.
Now this application support the SSO. If you want to use the sso you need to define the path to the default homeserver as your homeserver witch is installed on your YunoHost instance.
### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/element%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/element/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/element%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/element/)
<!--## Limitations
* Any known limitations.-->
Additional informations
-----------------------
## Additional informations
### Important Security Note
We do not recommend running Element from the same domain name as your Matrix
homeserver (synapse). The reason is the risk of XSS (cross-site-scripting)
homeserver (Synapse). The reason is the risk of XSS (cross-site-scripting)
vulnerabilities that could occur if someone caused Element to load and render
malicious user generated content from a Matrix API which then had trusted
access to Element (or other apps) due to sharing the same domain.
@ -99,33 +57,17 @@ So the process to migrate to element is the following:
2. Remove Riot: `yunohost app remove riot`
3. Install Element: `yunohost app install element`
Links
-----
## Documentation and resources
* Report a bug: https://github.com/YunoHost-Apps/element_ynh/issues
* App website: https://element.io/
* YunoHost website: https://yunohost.org/
* Official app website: https://element.io
* Official admin documentation: https://element.io/help
* Upstream app code repository: https://github.com/vector-im/element-web/
* YunoHost documentation for this app: https://yunohost.org/app_element
* Report a bug: https://github.com/YunoHost-Apps/element_ynh/issues
---
## Developer info
Install
-------
From command line:
`sudo yunohost app install -l element https://github.com/YunoHost-Apps/element_ynh`
Upgrade
-------
From command line:
`sudo yunohost app upgrade element -u https://github.com/YunoHost-Apps/element_ynh`
Developers infos
----------------
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/element_ynh/tree/testing).
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/element_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
@ -134,12 +76,4 @@ or
sudo yunohost app upgrade element -u https://github.com/YunoHost-Apps/element_ynh/tree/testing --debug
```
License
-------
Element-Web is published under the Apache License : https://github.com/vector-im/riot-web/blob/master/LICENSE
Todo for official App
---------------------
- Improve documentation
**More info regarding app packaging:** https://yunohost.org/packaging_apps

75
README_fr.md Normal file
View file

@ -0,0 +1,75 @@
# Element pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/element.svg)](https://dash.yunohost.org/appci/app/element) ![](https://ci-apps.yunohost.org/ci/badges/element.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/element.maintain.svg)
[![Installer Element avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=element)
*[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer Element rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
## Vue d'ensemble
Element est un nouveau type d'application de messagerie. Vous choisissez où vos messages sont stockés, ce qui vous donne le contrôle de vos données. Il vous donne accès au réseau ouvert Matrix, vous pouvez donc parler à n'importe qui. Element offre un nouveau niveau de sécurité, en ajoutant la vérification des appareils par signature croisée au chiffrement de bout en bout par défaut.
**Version incluse :** 1.9.8~ynh1
**Démo :** https://app.element.io/
## Captures d'écran
![](./doc/screenshots/homepage-all-platforms-1_1.png)
## Avertissements / informations importantes
## Fonctionnalités spécifiques à YunoHost
### Prise en charge multi-utilisateurs
Maintenant, cette application prend en charge le SSO. Si vous souhaitez utiliser le sso, vous devez définir le chemin d'accès au serveur domestique par défaut car votre serveur domestique est installé sur votre instance YunoHost.
## Informations supplémentaires
### Note de sécurité importante
Nous vous déconseillons d'exécuter Element à partir du même nom de domaine que votre Matrix
serveur domestique (Synapse). La raison en est le risque de XSS (cross-site-scripting)
vulnérabilités qui pourraient survenir si quelqu'un provoquait le chargement et le rendu d'Element
un utilisateur malveillant a généré du contenu à partir d'une API Matrix qui avait alors fait confiance
accès à Element (ou à d'autres applications) en raison du partage du même domaine.
Nous avons mis en place des mesures d'atténuation grossières pour essayer de nous protéger contre ce
situation, mais ce n'est toujours pas une bonne pratique de le faire en premier lieu. Voir
https://github.com/vector-im/riot-web/issues/1977 pour plus de détails.
### Migration à partir de l'ancien nom d'application "Riot"
Comme cette application ne contient aucune donnée côté serveur, aucune migration n'a été effectuée pour migrer de "Riot" vers "Element".
Il vous suffira donc de supprimer Riot et d'installer Element sur le même domaine (vous pouvez modifier le chemin) pour pouvoir conserver les données sur votre navigateur Web.
Ainsi, le processus de migration vers l'élément est le suivant :
1. Obtenez le domaine de "Riot": `yunohost app setting riot domain`
2. Supprimer Riot : `yunohost app remove riot`
3. Élément d'installation : `yunohost app install element`
## Documentations et ressources
* Site officiel de l'app : https://element.io
* Documentation officielle de l'admin : https://element.io/help
* Dépôt de code officiel de l'app : https://github.com/vector-im/element-web/
* Documentation YunoHost pour cette app : https://yunohost.org/app_element
* Signaler un bug : https://github.com/YunoHost-Apps/element_ynh/issues
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/element_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
```
sudo yunohost app install https://github.com/YunoHost-Apps/element_ynh/tree/testing --debug
ou
sudo yunohost app upgrade element -u https://github.com/YunoHost-Apps/element_ynh/tree/testing --debug
```
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps

View file

@ -1,11 +1,9 @@
;; General
auto_remove=1
# Commentaire ignoré
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
domain="domain.tld"
path="/path"
default_home_server="matrix.org"
is_public=1 (PUBLIC|public=1|private=0)
is_public=1
; Checks
pkg_linter=1
setup_sub_dir=1
@ -14,14 +12,15 @@
setup_private=1
setup_public=1
upgrade=1
upgrade=1 from_commit=34d457d13e526997fddb8348650674a7db2247be
backup_restore=1
multi_instance=1
wrong_user=0
wrong_path=1
incorrect_path=1
corrupt_source=1
fail_download_source=1
port_already_use=0 (XXXX)
final_path_already_use=1
port_already_use=0
change_url=1
;;; Upgrade options
;;; Upgrade options
; commit=Sep 13, 2021
name=34d457d13e526997fddb8348650674a7db2247be
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&

View file

@ -1,11 +1,5 @@
SOURCE_URL=https://github.com/vector-im/element-web/releases/download/v1.8.5/element-v1.8.5.tar.gz
SOURCE_SUM=1371fa8970518b89a786ed26bbdea5cbd7fc0183a23057fdcd37298c399f1f2e
# (Optional) Program to check the integrity (sha256sum, md5sum...)
# default: sha256
SOURCE_URL=https://github.com/vector-im/element-web/releases/download/v1.9.8/element-v1.9.8.tar.gz
SOURCE_SUM=585283f72925628374748beec3768fcee24d337715312f92a99c9646e0c62e90
SOURCE_SUM_PRG=sha256sum
# (Optional) Archive format
# default: tar.gz
SOURCE_FORMAT=tar.gz
# (Optional) Put false if sources are directly in the archive root
# default: true
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +1,5 @@
{
"default_hs_url": "https://__DEFAULT_SERVER__",
"default_hs_url": "https://__DEFAULT_HOME_SERVER__",
"default_is_url": "https://vector.im",
"brand": "Element",
"integrations_ui_url": "https://scalar.vector.im/",

View file

@ -1,10 +1,8 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
alias __FINALPATH__/;
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
alias __FINALPATH__/;
index index.html;
# Include SSOWAT user panel.

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
Element is a new type of messaging app. You choose where your messages are stored, putting you in control of your data. It gives you access to the Matrix open network, so you can talk to anyone. Element provides a new level of security, adding cross-signed device verification to default end-to-end encryption.

1
doc/DESCRIPTION_fr.md Normal file
View file

@ -0,0 +1 @@
Element est un nouveau type d'application de messagerie. Vous choisissez où vos messages sont stockés, ce qui vous donne le contrôle de vos données. Il vous donne accès au réseau ouvert Matrix, vous pouvez donc parler à n'importe qui. Element offre un nouveau niveau de sécurité, en ajoutant la vérification des appareils par signature croisée au chiffrement de bout en bout par défaut.

29
doc/DISCLAIMER.md Normal file
View file

@ -0,0 +1,29 @@
## YunoHost specific features
### Multi-users support
Now this application support the SSO. If you want to use the sso you need to define the path to the default homeserver as your homeserver witch is installed on your YunoHost instance.
## Additional informations
### Important Security Note
We do not recommend running Element from the same domain name as your Matrix
homeserver (Synapse). The reason is the risk of XSS (cross-site-scripting)
vulnerabilities that could occur if someone caused Element to load and render
malicious user generated content from a Matrix API which then had trusted
access to Element (or other apps) due to sharing the same domain.
We have put some coarse mitigations into place to try to protect against this
situation, but it's still not good practice to do it in the first place. See
https://github.com/vector-im/riot-web/issues/1977 for more details.
### Migration from old app name "Riot"
As this app don't contains any data on the server side no migration was made to migrate from "Riot" to "Element".
So you just will need to remove Riot and install Element on the same domain (you can change the path) to be able to keep the data on your web browser.
So the process to migrate to element is the following:
1. Get the domain of "Riot": `yunohost app setting riot domain`
2. Remove Riot: `yunohost app remove riot`
3. Install Element: `yunohost app install element`

29
doc/DISCLAIMER_fr.md Normal file
View file

@ -0,0 +1,29 @@
## Fonctionnalités spécifiques à YunoHost
### Prise en charge multi-utilisateurs
Maintenant, cette application prend en charge le SSO. Si vous souhaitez utiliser le sso, vous devez définir le chemin d'accès au serveur domestique par défaut car votre serveur domestique est installé sur votre instance YunoHost.
## Informations supplémentaires
### Note de sécurité importante
Nous vous déconseillons d'exécuter Element à partir du même nom de domaine que votre Matrix
serveur domestique (Synapse). La raison en est le risque de XSS (cross-site-scripting)
vulnérabilités qui pourraient survenir si quelqu'un provoquait le chargement et le rendu d'Element
un utilisateur malveillant a généré du contenu à partir d'une API Matrix qui avait alors fait confiance
accès à Element (ou à d'autres applications) en raison du partage du même domaine.
Nous avons mis en place des mesures d'atténuation grossières pour essayer de nous protéger contre ce
situation, mais ce n'est toujours pas une bonne pratique de le faire en premier lieu. Voir
https://github.com/vector-im/riot-web/issues/1977 pour plus de détails.
### Migration à partir de l'ancien nom d'application "Riot"
Comme cette application ne contient aucune donnée côté serveur, aucune migration n'a été effectuée pour migrer de "Riot" vers "Element".
Il vous suffira donc de supprimer Riot et d'installer Element sur le même domaine (vous pouvez modifier le chemin) pour pouvoir conserver les données sur votre navigateur Web.
Ainsi, le processus de migration vers l'élément est le suivant :
1. Obtenez le domaine de "Riot": `yunohost app setting riot domain`
2. Supprimer Riot : `yunohost app remove riot`
3. Élément d'installation : `yunohost app install element`

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

View file

@ -2,20 +2,27 @@
"name": "Element",
"id": "element",
"packaging_format": 1,
"requirements": {
"yunohost": ">= 4.2.6.1"
},
"description": {
"en": "A web client for matrix",
"fr": "Un client web pour matrix"
"en": "Web client for Matrix",
"fr": "Client web pour Matrix"
},
"version": "1.8.5~ynh1",
"version": "1.9.8~ynh1",
"url": "https://element.io",
"upstream": {
"license": "Apache-2.0",
"website": "https://element.io",
"demo": "https://app.element.io/",
"admindoc": "https://element.io/help",
"code": "https://github.com/vector-im/element-web/"
},
"license": "Apache-2.0",
"maintainer": {
"name": "Josué Tille",
"email": "josue@tille.ch"
},
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": true,
"services": [
"nginx"
@ -24,20 +31,11 @@
"install" : [
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain for Element",
"fr": "Choisissez un domaine pour Element"
},
"example": "domain.org"
"type": "domain"
},
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for Element",
"fr": "Choisissez un chemin pour Element"
},
"example": "/element",
"default": "/element"
},
@ -54,10 +52,6 @@
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public application?",
"fr": "Est-ce une application publique ?"
},
"help": {
"en": "A public application means that anyone can access it. Note that this application provides just files (html, javascript, images, etc.)",
"fr": "Une application publique signifie que n'importe qui peut y accéder. Notez que cette application ne fournit que des fichiers (html, javascript, images, etc.)"

View file

@ -1,26 +1,17 @@
#!/bin/bash
#=================================================
# SET ALL CONSTANTS
# COMMON VARIABLES
#=================================================
app=$YNH_APP_INSTANCE_NAME
final_path="/var/www/$app"
#=================================================
# DEFINE ALL COMMON FONCTIONS
# PERSONAL HELPERS
#=================================================
config_element() {
cp ../conf/config.json $final_path/config.json
ynh_replace_string --match_string __DEFAULT_SERVER__ --replace_string $default_home_server --target_file $final_path/config.json
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
install_source() {
ynh_setup_source --dest_dir $final_path/
}
set_permission() {
chown www-data:root -R $final_path
chmod u=rX,g=rX,o= -R $final_path
}
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -3,32 +3,49 @@
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Import common cmd
source ../settings/scripts/experimental_helper.sh
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Stop script if errors
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD BACKUP STEPS
# 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)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
# Retrieve arguments
ynh_print_info --message="Loading installation settings..."
domain=$(ynh_app_setting_get --app $app --key domain)
ynh_backup --src_path="$final_path"
ynh_print_info --message="Backing configuration..."
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
# Copy Nginx config
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 element files
ynh_print_info --message="Backing up the main app directory..."
ynh_backup --src_path "/var/www/$app"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,42 +1,104 @@
#!/bin/bash
#=================================================
# GENERIC START
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Source YunoHost helpers
source _common.sh
source /usr/share/yunohost/helpers
# Stop script if errors
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Retrive arguments
ynh_script_progression --message="Loading installation settings..."
old_domain=$YNH_APP_OLD_DOMAIN
path_url=$(ynh_normalize_url_path --path_url ${YNH_APP_NEW_PATH:-'/'})
domain=$YNH_APP_NEW_DOMAIN
#=================================================
# STANDARD MODIFICATIONS
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
ynh_script_progression --message="Updating configuration..."
# Update nginx config
if [ "$old_domain" != "$domain" ]
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file "/etc/nginx/conf.d/$old_domain.d/$app.conf"
mv "/etc/nginx/conf.d/$old_domain.d/$app.conf" "/etc/nginx/conf.d/$domain.d/$app.conf"
# Store file checksum for the new config file location
ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf"
change_domain=1
fi
ynh_add_nginx_config
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -3,18 +3,22 @@
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Source YunoHost helpers
source _common.sh
source /usr/share/yunohost/helpers
# Stop script if errors
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
ynh_script_progression --message="Validating installation parameters..."
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN
@ -22,47 +26,83 @@ path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
default_home_server=$YNH_APP_ARG_DEFAULT_HOME_SERVER
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
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
# Check Final Path availability
test ! -e "$final_path" || ynh_die --message "This path already contains a folder"
# Enregistre les infos dans la config YunoHost
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app $app --key is_public --value $is_public
ynh_app_setting_set --app $app --key default_home_server --value $default_home_server
ynh_app_setting_set --app $app --key final_path --value $final_path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STANDARD MODIFICATIONS
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
# Get source and install in source dir
ynh_script_progression --message="Installing sources files..." --weight=10
install_source
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=default_home_server --value=$default_home_server
# Update Element config
config_element
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Config nginx
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=4
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# GENERIC FINALIZATION
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
# Set final permission
ynh_script_progression --message="Protecting directory"
set_permission
ynh_add_config --template="../conf/config.json" --destination="$final_path/config.json"
ynh_script_progression --message="Configuring permissions"
if [ "$is_public" == '1' ];
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary
if [ $is_public -eq 1 ]
then
ynh_permission_update --permission "main" --add "visitors"
ynh_permission_update --permission="main" --add="visitors"
fi
# Recharge la configuration Nginx
systemctl reload nginx.service
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -3,28 +3,50 @@
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Source YunoHost helpers
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD REMOVE
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# Retrieve arguments
ynh_script_progression --message="Loading installation settings..."
domain=$(ynh_app_setting_get --app $app --key domain)
app=$YNH_APP_INSTANCE_NAME
# Remove all files
ynh_script_progression --message="Removing app main directory..." --weight=4
ynh_secure_remove --file="/var/www/$app"
domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Suppression de la configuration nginx
ynh_script_progression --message="Removing configuration..."
#=================================================
# 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 NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# 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
#=================================================
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -3,47 +3,76 @@
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Import common cmd
source ../settings/scripts/experimental_helper.sh
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
# Source YunoHost helpers
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Stop script if errors
ynh_abort_if_errors
# Retrieve arguments
ynh_script_progression --message="Loading settings..."
domain=$(ynh_app_setting_get --app $app --key domain)
path_url=$(ynh_app_setting_get --app $app --key path)
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# Check domain/path availability
ynh_webpath_available --domain $domain --path_url $path_url || ynh_die --message "$domain/$path_url is not available, please use an other domain or path."
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)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
# Create a system user
ynh_script_progression --message="Recreating the dedicated system user..."
ynh_system_user_create --username $app
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
# Restore all config and data
ynh_script_progression --message="Restoring files..." --weight=10
ynh_restore
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
# Set final permission
ynh_script_progression --message="Protecting directory..."
set_permission
ynh_systemd_action --service_name=nginx --action=reload
# Reload nginx
ynh_script_progression --message="Reloading services..."
systemctl reload nginx.service
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -3,58 +3,91 @@
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Source YunoHost helpers
source _common.sh
source /usr/share/yunohost/helpers
# Stop script if errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
default_home_server=$(ynh_app_setting_get --app=$app --key=default_home_server)
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Retrieve arguments
ynh_script_progression --message="Loading installation settings..."
domain=$(ynh_app_setting_get --app $app --key domain)
path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path))
is_public=$(ynh_app_setting_get --app $app --key is_public)
final_path=$(ynh_app_setting_get --app $app --key final_path)
default_home_server=$(ynh_app_setting_get --app $app --key default_home_server)
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# STANDARD UPGRADE STEPS
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
# Get source and install in source dir
ynh_script_progression --message="Upgrading source files..." --weight=6
ynh_secure_remove --file=$final_path
install_source
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=1
ynh_script_progression --message="Configuring application..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
fi
# Update Element config
config_element
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
# Remove the dedicated php-fpm config
ynh_remove_fpm_config
ynh_add_config --template="../conf/config.json" --destination="$final_path/config.json"
# Delete a system user
ynh_script_progression --message="Removing apps user..."
ynh_system_user_delete --username $app
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
# Update nginx config
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# GENERIC FINALIZATION
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
# Set final permission
ynh_script_progression --message="Protecting directory..."
set_permission
# Recharge la configuration Nginx
systemctl reload nginx.service
ynh_script_progression --message="Upgrade of $app completed" --last