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

Manifestv2

This commit is contained in:
Salamandar 2023-10-02 22:06:16 +02:00 committed by Félix Piédallu
parent 8fcf121332
commit c1a0cb2a6a
20 changed files with 126 additions and 515 deletions

View file

@ -16,7 +16,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview ## Overview
Simple, fast and flexible wiki ChuWiki is first and foremost a wiki. A wiki is a website whose pages can be edited by the visitor. However, a history system allows you to track modifications made to a page and restore an old version of the page if necessary.
**Shipped version:** 2.0~ynh2 **Shipped version:** 2.0~ynh2
@ -26,12 +26,6 @@ Simple, fast and flexible wiki
![Screenshot of ChuWiki](./doc/screenshots/screenshot.png) ![Screenshot of ChuWiki](./doc/screenshots/screenshot.png)
## Disclaimers / important information
## Configuration
How to configure this app: via the `/var/www/chuwiki/configuration.ini` file.
## :red_circle: Antifeatures ## :red_circle: Antifeatures
- **Upstream not maintained**: This software is not maintained anymore. Expect it to break down over time, be exposed to unfixed security breaches, etc. - **Upstream not maintained**: This software is not maintained anymore. Expect it to break down over time, be exposed to unfixed security breaches, etc.
@ -41,7 +35,6 @@ How to configure this app: via the `/var/www/chuwiki/configuration.ini` file.
* Official app website: <http://chuwiki.genezys.net/> * Official app website: <http://chuwiki.genezys.net/>
* Official admin documentation: <http://chuwiki.genezys.net/> * Official admin documentation: <http://chuwiki.genezys.net/>
* Upstream app code repository: <https://github.com/genezys/chuwiki> * Upstream app code repository: <https://github.com/genezys/chuwiki>
* YunoHost documentation for this app: <https://yunohost.org/app_chuwiki>
* Report a bug: <https://github.com/YunoHost-Apps/chuwiki_ynh/issues> * Report a bug: <https://github.com/YunoHost-Apps/chuwiki_ynh/issues>
## Developer info ## Developer info

View file

@ -16,7 +16,8 @@ Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
## Vue densemble ## Vue densemble
Wiki simple, rapide et flexible ChuWiki est tout d'abord un wiki. Un wiki est un site web dont les pages sont éditables par le visiteur. Un système d'historique permet toutefois de suivre les modifications effectuées sur une page et de restaurer une ancienne version de la page si besoin.
**Version incluse :** 2.0~ynh2 **Version incluse :** 2.0~ynh2
@ -26,12 +27,6 @@ Wiki simple, rapide et flexible
![Capture décran de ChuWiki](./doc/screenshots/screenshot.png) ![Capture décran de ChuWiki](./doc/screenshots/screenshot.png)
## Avertissements / informations importantes
## Configuration
Comment configurer cette application : via le fichier `/var/www/chuwiki/configuration.ini`.
## :red_circle: Fonctions indésirables ## :red_circle: Fonctions indésirables
- **Upstream not maintained**: This software is not maintained anymore. Expect it to break down over time, be exposed to unfixed security breaches, etc. - **Upstream not maintained**: This software is not maintained anymore. Expect it to break down over time, be exposed to unfixed security breaches, etc.
@ -41,7 +36,6 @@ Comment configurer cette application : via le fichier `/var/www/chuwiki/configur
* Site officiel de lapp : <http://chuwiki.genezys.net/> * Site officiel de lapp : <http://chuwiki.genezys.net/>
* Documentation officielle de ladmin : <http://chuwiki.genezys.net/> * Documentation officielle de ladmin : <http://chuwiki.genezys.net/>
* Dépôt de code officiel de lapp : <https://github.com/genezys/chuwiki> * Dépôt de code officiel de lapp : <https://github.com/genezys/chuwiki>
* Documentation YunoHost pour cette app : <https://yunohost.org/app_chuwiki>
* Signaler un bug : <https://github.com/YunoHost-Apps/chuwiki_ynh/issues> * Signaler un bug : <https://github.com/YunoHost-Apps/chuwiki_ynh/issues>
## Informations pour les développeurs ## Informations pour les développeurs

View file

@ -1,27 +0,0 @@
;; Test complet
; Manifest
domain="domain.tld"
path="/path"
title="ChuWiki"
language="en"
is_public=1
; Checks
pkg_linter=1
setup_sub_dir=1
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
change_url=1
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=CommitHash
name=Name and date of the commit.
manifest_arg=domain=DOMAIN&path=PATH&is_public=1&

View file

@ -1,7 +0,0 @@
SOURCE_URL=http://chuwiki.genezys.net/download/chuwiki-2.0.zip
SOURCE_SUM=d944241e87469417a55f91cb513628859f33364fe5a6e6d97ce933c4efcf8329
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=chuwiki-2.0.zip
SOURCE_EXTRACT=true

View file

@ -10,7 +10,7 @@ UsePathInfo = false
; Vous devez posséder le droit d'écriture sur ce répertoire ; Vous devez posséder le droit d'écriture sur ce répertoire
; S'il n'existe pas, il sera créé par ChuWiki mais devrez dans ce cas ; S'il n'existe pas, il sera créé par ChuWiki mais devrez dans ce cas
; avoir les droits d'écriture dans le répertoire ; avoir les droits d'écriture dans le répertoire
PagePath = __DATADIR__/pages PagePath = __DATA_DIR__/pages
; Noms des scripts ; Noms des scripts
; Vous devrez peut-être ajouter ".php" si votre serveur ne gère pas MultiViews ; Vous devrez peut-être ajouter ".php" si votre serveur ne gère pas MultiViews

View file

@ -2,7 +2,7 @@
location __PATH__/ { location __PATH__/ {
# Path to source # Path to source
alias __FINALPATH__/; alias __INSTALL_DIR__/;
index index.php; index index.php;
client_max_body_size 128M; client_max_body_size 128M;

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
ChuWiki is first and foremost a wiki. A wiki is a website whose pages can be edited by the visitor. However, a history system allows you to track modifications made to a page and restore an old version of the page if necessary.

1
doc/DESCRIPTION_fr.md Normal file
View file

@ -0,0 +1 @@
ChuWiki est tout d'abord un wiki. Un wiki est un site web dont les pages sont éditables par le visiteur. Un système d'historique permet toutefois de suivre les modifications effectuées sur une page et de restaurer une ancienne version de la page si besoin.

View file

@ -1,75 +0,0 @@
{
"name": "ChuWiki",
"id": "chuwiki",
"packaging_format": 1,
"description": {
"en": "Simple, fast and flexible wiki",
"fr": "Wiki simple, rapide et flexible"
},
"version": "2.0~ynh2",
"url": "http://chuwiki.genezys.net/",
"upstream": {
"license": "AGPL-3.0-only",
"website": "http://chuwiki.genezys.net/",
"demo": "http://chuwiki.genezys.net/wiki/Bac%20%C3%A0%20sable",
"admindoc": "http://chuwiki.genezys.net/",
"code": "https://github.com/genezys/chuwiki"
},
"license": "AGPL-3.0-only",
"maintainer": {
"name": "Stylix58",
"email": "lateman-jpeg@outlook.fr",
"url": "https://stylix58.netlify.app/"
},
"requirements": {
"yunohost": ">= 11.0.9"
},
"multi_instance": true,
"services": [
"nginx",
"php7.4-fpm"
],
"arguments": {
"install" : [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/chuwiki",
"default": "/chuwiki"
},
{
"name": "title",
"type": "string",
"ask": {
"en": "Choose a title for the wiki you want to create",
"fr": "Choisissez un titre pour le wiki que vous souhaitez créer"
},
"example": "ChuWiki",
"default": "ChuWiki"
},
{
"name": "language",
"type": "string",
"ask": {
"en": "Choose the application language",
"fr": "Choisissez la langue de l'application"
},
"choices": ["en", "es", "fr", "zh"],
"default": "en"
},
{
"name": "is_public",
"type": "boolean",
"help": {
"en": "If yes, this app will can be accessible by everyone.",
"fr": "Si oui, cette app pourra être accessible par tout le monde."
},
"default": true
}
]
}
}

77
manifest.toml Normal file
View file

@ -0,0 +1,77 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "chuwiki"
name = "ChuWiki"
description.en = "Simple, fast and flexible wiki"
description.fr = "Wiki simple, rapide et flexible"
version = "2.0~ynh2"
maintainers = ["Stylix58"]
[upstream]
license = "AGPL-3.0-only"
website = "http://chuwiki.genezys.net/"
demo = "http://chuwiki.genezys.net/wiki/Bac%20%C3%A0%20sable"
admindoc = "http://chuwiki.genezys.net/"
code = "https://github.com/genezys/chuwiki"
[integration]
yunohost = ">= 11.0.9"
architectures = "all"
multi_instance = true
ldap = false
sso = false
disk = "50M"
ram.build = "150M"
ram.runtime = "50M"
[install]
[install.domain]
type = "domain"
[install.path]
type = "path"
default = "/chuwiki"
[install.title]
ask.en = "Choose a title for the wiki you want to create"
ask.fr = "Choisissez un titre pour le wiki que vous souhaitez créer"
type = "string"
example = "ChuWiki"
default = "ChuWiki"
[install.language]
ask.en = "Choose the application language"
ask.fr = "Choisissez la langue de l'application"
type = "select"
choices = ["en", "es", "fr", "zh"]
default = "en"
[install.init_main_permission]
help.en = "If yes, this app will can be accessible by everyone."
help.fr = "Si oui, cette app pourra être accessible par tout le monde."
type = "group"
default = "visitors"
[resources]
[resources.sources.main]
url = "http://chuwiki.genezys.net/download/chuwiki-2.0.zip"
sha256 = "d944241e87469417a55f91cb513628859f33364fe5a6e6d97ce933c4efcf8329"
[resources.system_user]
[resources.install_dir]
[resources.data_dir]
[resources.permissions]
main.url = "/"
[resources.apt]
packages = [
"php7.4",
"php7.4-fpm",
]

View file

@ -4,8 +4,6 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
YNH_PHP_VERSION="7.4"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================

View file

@ -10,25 +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
#=================================================
# 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)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
@ -38,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 CONTENT DIR # BACKUP CONTENT DIR
#================================================= #=================================================
ynh_backup --src_path="$datadir" --is_big ynh_backup --src_path="$data_dir" --is_big
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -9,94 +9,12 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path=$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 UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
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
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -9,61 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
title=$YNH_APP_ARG_TITLE
language=$YNH_APP_ARG_LANGUAGE
app=$YNH_APP_INSTANCE_NAME
fpm_footprint="low"
fpm_free_footprint=0
fpm_usage="low"
#=================================================
# 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
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
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=title --value=$title
ynh_app_setting_set --app=$app --key=language --value=$language
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
@ -71,29 +16,24 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=1 ynh_script_progression --message="Setting up source files..." --weight=1
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_setup_source --dest_dir="$install_dir"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$final_path" chown -R "$app:www-data" "$install_dir"
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
# Create a dedicated PHP-FPM config ynh_add_fpm_config --usage="$fpm_usage" --footprint="$fpm_footprint"
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1 ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
@ -101,42 +41,19 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Creating a data directory..." --weight=1 ynh_script_progression --message="Creating a data directory..." --weight=1
datadir=/home/yunohost.app/$app chmod 750 "$data_dir"
ynh_app_setting_set --app=$app --key=datadir --value=$datadir chmod -R o-rwx "$data_dir"
chown -R "$app:www-data" "$data_dir"
mkdir -p $datadir
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/configuration.ini" --destination="$final_path/configuration.ini" ynh_add_config --template="../conf/configuration.ini" --destination="$install_dir/configuration.ini"
chmod 400 "$final_path/configuration.ini" chmod 400 "$install_dir/configuration.ini"
chown $app "$final_path/configuration.ini" chown "$app:$app" "$install_dir/configuration.ini"
#=================================================
# 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"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -9,43 +9,11 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# 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 the content directory securely
#ynh_secure_remove --file="/home/yunohost.app/$app"
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory..." --weight=1
ynh_secure_remove --file="$datadir"
fi
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#================================================= #=================================================
@ -53,19 +21,8 @@ ynh_remove_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1 ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config ynh_remove_fpm_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 # END OF SCRIPT
#================================================= #=================================================

View file

@ -10,37 +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
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=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)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
#=================================================
# 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 # STANDARD RESTORATION STEPS
#================================================= #=================================================
@ -49,38 +18,28 @@ test ! -d $final_path \
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..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$final_path" chown -R "$app:www-data" "$install_dir"
#================================================= #=================================================
# RESTORE THE DATA DIRECTORY # RESTORE THE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1 ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="$datadir" --not_mandatory ynh_restore_file --origin_path="$data_dir" --not_mandatory
mkdir -p $datadir
# this will be treated as a security issue. # this will be treated as a security issue.
chmod 750 "$datadir" chmod 750 "$data_dir"
chmod -R o-rwx "$datadir" chmod -R o-rwx "$data_dir"
chown -R $app:www-data "$datadir" chown -R "$app:www-data" "$data_dir"
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # RESTORE THE PHP-FPM CONFIGURATION
@ -90,7 +49,7 @@ ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weig
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
# Recreate a dedicated php-fpm config # Recreate a dedicated php-fpm config
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion ynh_add_fpm_config --usage="$fpm_usage" --footprint="$fpm_footprint" --phpversion="$phpversion"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -99,7 +58,7 @@ ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$p
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================

View file

@ -9,87 +9,17 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
phpversion=$YNH_PHP_VERSION
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint)
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
#================================================= #=================================================
# CHECK VERSION # CHECK 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)..." --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
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# If datadir doesn't exist, create it
if [ -z "$datadir" ]; then
datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
fi
# If fpm_footprint doesn't exist, create it
if [ -z "$fpm_footprint" ]; then
fpm_footprint=low
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
fi
# If fpm_free_footprint doesn't exist, create it
if [ -z "$fpm_free_footprint" ]; then
fpm_free_footprint=0
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
fi
# If fpm_usage doesn't exist, create it
if [ -z "$fpm_usage" ]; then
fpm_usage=low
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
fi
# 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..." --weight=1
# 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
#================================================= #=================================================
@ -100,46 +30,35 @@ then
# Create a temporary directory # Create a temporary directory
tmpdir="$(mktemp -d)" tmpdir="$(mktemp -d)"
cp -a "$final_path/configuration.ini" "$tmpdir/configuration.ini" cp -a "$install_dir/configuration.ini" "$tmpdir/configuration.ini"
ynh_secure_remove --file="$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="$install_dir" #--keep="configuration.ini"
ynh_setup_source --dest_dir="$final_path" #--keep="configuration.ini"
# Copy the admin saved settings from tmp directory to final config path # Copy the admin saved settings from tmp directory to final config path
cp -a "$tmpdir/configuration.ini" "$final_path/configuration.ini" cp -a "$tmpdir/configuration.ini" "$install_dir/configuration.ini"
# Remove the tmp directory securely # Remove the tmp directory securely
ynh_secure_remove --file="$tmpdir" ynh_secure_remove --file="$tmpdir"
fi fi
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$install_dir"
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

5
tests.toml Normal file
View file

@ -0,0 +1,5 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
test_format = 1.0
[default]