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

Merge pull request #114 from YunoHost-Apps/testing

Upgrade to 5.00
This commit is contained in:
yalh76 2021-03-03 02:29:44 +01:00 committed by GitHub
commit 29f415ca12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 120 additions and 228 deletions

View file

@ -1,7 +1,7 @@
# Wekan for YunoHost # Wekan for YunoHost
[![Integration level](https://dash.yunohost.org/integration/wekan.svg)](https://dash.yunohost.org/appci/app/wekan) ![](https://ci-apps.yunohost.org/ci/badges/wekan.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/wekan.maintain.svg) [![Integration level](https://dash.yunohost.org/integration/wekan.svg)](https://dash.yunohost.org/appci/app/wekan) ![](https://ci-apps.yunohost.org/ci/badges/wekan.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/wekan.maintain.svg)
[![Install Wekan with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=wekan) [![Install Wekan with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=wekan)
> *This package allows you to install Wekan quickly and simply on a YunoHost server. > *This package allows you to install Wekan 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.* If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
@ -9,7 +9,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview ## Overview
Wekan is an open-source kanban board (task manager and organizer) Wekan is an open-source kanban board (task manager and organizer)
**Shipped version:** 4.64 **Shipped version:** 5.00
## Screenshots ## Screenshots
@ -65,7 +65,7 @@ LDAP is supported but HTTP auth is still not supported
--- ---
Developer info ## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/wekan_ynh/tree/testing). Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/wekan_ynh/tree/testing).

View file

@ -24,15 +24,12 @@
upgrade=1 from_commit=2cf63bd4d660eae4526221c1a68efede499e3ee6 upgrade=1 from_commit=2cf63bd4d660eae4526221c1a68efede499e3ee6
# 4.64~ynh1 # 4.64~ynh1
upgrade=1 from_commit=32fe3a7c342e5f29d7a7534125151723f916de46 upgrade=1 from_commit=32fe3a7c342e5f29d7a7534125151723f916de46
# 4.64~ynh2
upgrade=1 from_commit=9e698d094c29fc6ab12ac60cd1d0e68b56bfc953
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
# incorrect_path=1
port_already_use=0 port_already_use=0
change_url=1 change_url=1
;;; Levels
# If the level 5 (Package linter) is forced to 1. Please add justifications here.
Level 5=auto
;;; Options ;;; Options
Email=ljf+ynh-wekan@reflexlibre.net Email=ljf+ynh-wekan@reflexlibre.net
Notification=down Notification=down
@ -49,3 +46,5 @@ Notification=down
name=4.43~ynh1 name=4.43~ynh1
; commit=32fe3a7c342e5f29d7a7534125151723f916de46 ; commit=32fe3a7c342e5f29d7a7534125151723f916de46
name=4.64~ynh1 name=4.64~ynh1
; commit=9e698d094c29fc6ab12ac60cd1d0e68b56bfc953
name=4.64~ynh2

View file

@ -10,13 +10,13 @@ __YNH_NODE_LOAD_PATH__
#DEBUG=true #DEBUG=true
#--------------------------------------------- #---------------------------------------------
# URL of the mongodb # URL of the mongodb
MONGO_URL=mongodb://127.0.0.1:27017/__DB_NAME__ MONGO_URL='mongodb://127.0.0.1:27017/__DB_NAME__'
#--------------------------------------------- #---------------------------------------------
# ROOT_URL EXAMPLES FOR WEBSERVERS: https://github.com/wekan/wekan/wiki/Settings # ROOT_URL EXAMPLES FOR WEBSERVERS: https://github.com/wekan/wekan/wiki/Settings
# Production: https://example.com/wekan # Production: https://example.com/wekan
# Local: http://localhost:2000 # Local: http://localhost:2000
# ipaddress=$(ifdata -pa eth0) # ipaddress=$(ifdata -pa eth0)
ROOT_URL=https://__DOMAIN____PATH__ ROOT_URL='https://__DOMAIN____PATH__'
#--------------------------------------------- #---------------------------------------------
# Working email IS NOT REQUIRED to use Wekan. # Working email IS NOT REQUIRED to use Wekan.
# https://github.com/wekan/wekan/wiki/Adding-users # https://github.com/wekan/wekan/wiki/Adding-users
@ -48,11 +48,6 @@ WITH_API='true'
# https://github.com/wekan/wekan/pull/2560 # https://github.com/wekan/wekan/pull/2560
RICHER_CARD_COMMENT_EDITOR=true RICHER_CARD_COMMENT_EDITOR=true
#--------------------------------------------------------------- #---------------------------------------------------------------
# ==== MOUSE SCROLL ====
# https://github.com/wekan/wekan/issues/2949
SCROLLINERTIA=0
SCROLLAMOUNT=auto
#---------------------------------------------------------------
# ==== CARD OPENED, SEND WEBHOOK MESSAGE ==== # ==== CARD OPENED, SEND WEBHOOK MESSAGE ====
CARD_OPENED_WEBHOOK_ENABLED=false CARD_OPENED_WEBHOOK_ENABLED=false
#--------------------------------------------------------------- #---------------------------------------------------------------
@ -132,6 +127,9 @@ TRUSTED_URL=''
# Example: WEBHOOKS_ATTRIBUTES=cardId,listId,oldListId,boardId,comment,user,card,commentId # Example: WEBHOOKS_ATTRIBUTES=cardId,listId,oldListId,boardId,comment,user,card,commentId
WEBHOOKS_ATTRIBUTES='' WEBHOOKS_ATTRIBUTES=''
#--------------------------------------------- #---------------------------------------------
# OAUTH2 ORACLE on premise identity manager OIM
#ORACLE_OIM_ENABLED=true
#---------------------------------------------
# ==== OAUTH2 AZURE ==== # ==== OAUTH2 AZURE ====
# https://github.com/wekan/wekan/wiki/Azure # https://github.com/wekan/wekan/wiki/Azure
# 1) Register the application with Azure. Make sure you capture # 1) Register the application with Azure. Make sure you capture
@ -139,6 +137,10 @@ WEBHOOKS_ATTRIBUTES=''
# 2) Configure the environment variables. This differs slightly # 2) Configure the environment variables. This differs slightly
# by installation type, but make sure you have the following: # by installation type, but make sure you have the following:
#OAUTH2_ENABLED=true #OAUTH2_ENABLED=true
# Optional OAuth2 CA Cert, see https://github.com/wekan/wekan/issues/3299
#OAUTH2_CA_CERT=ABCD1234
# Use OAuth2 ADFS additional changes. Also needs OAUTH2_ENABLED=true setting.
#OAUTH2_ADFS_ENABLED=false
# OAuth2 docs: https://github.com/wekan/wekan/wiki/OAuth2 # OAuth2 docs: https://github.com/wekan/wekan/wiki/OAuth2
# OAuth2 login style: popup or redirect. # OAuth2 login style: popup or redirect.
#OAUTH2_LOGIN_STYLE=redirect #OAUTH2_LOGIN_STYLE=redirect
@ -411,3 +413,21 @@ LDAP_SYNC_ADMIN_GROUPS=__APP__.admin
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# PASSWORD_LOGIN_ENABLED : Enable or not the password login form. # PASSWORD_LOGIN_ENABLED : Enable or not the password login form.
#PASSWORD_LOGIN_ENABLED=true #PASSWORD_LOGIN_ENABLED=true
#---------------------------------------------------------------------
#CAS_ENABLED=true
#CAS_BASE_URL=https://cas.example.com/cas
#CAS_LOGIN_URL=https://cas.example.com/login
#CAS_VALIDATE_URL=https://cas.example.com/cas/p3/serviceValidate
#---------------------------------------------------------------------
#SAML_ENABLED=true
#SAML_PROVIDER=
#SAML_ENTRYPOINT=
#SAML_ISSUER=
#SAML_CERT=
#SAML_IDPSLO_REDIRECTURL=
#SAML_PRIVATE_KEYFILE=
#SAML_PUBLIC_CERTFILE=
#SAML_IDENTIFIER_FORMAT=
#SAML_LOCAL_PROFILE_MATCH_ATTRIBUTE=
#SAML_ATTRIBUTES=
#---------------------------------------------------------------------

View file

@ -1,9 +1,9 @@
# This is on YunoHost server just to avoid the file from disappearing # This is on YunoHost server just to avoid the file from disappearing
# Original source is https://releases.wekan.team/raspi3/wekan-4.64-arm64.zip # Original source is https://releases.wekan.team/raspi3/wekan-5.00-arm64.zip
# YunoHost source is https://build.yunohost.org/apps/wekan-4.64-arm64.zip # YunoHost source is https://build.yunohost.org/apps/wekan-5.00-arm64.zip
SOURCE_URL=https://build.yunohost.org/apps/wekan-4.64-arm64.zip SOURCE_URL=https://build.yunohost.org/apps/wekan-5.00-arm64.zip
SOURCE_SUM=220fc943263a8e025d420b29f8fbcaf1839b34ad5ff0440d2f629d004f9c642f SOURCE_SUM=156b9578766d4f133c8078bec1433fe5147e7fc594f0fbb8bdb000df2a269c89
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=wekan-4.64-arm64.zip SOURCE_FILENAME=wekan-5.00-arm64.zip

View file

@ -1,5 +1,6 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ { location __PATH__/ {
# Force usage of https
if ($scheme = http) { if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
} }

View file

@ -1,9 +1,9 @@
# This is on YunoHost server just to avoid the file from disappearing # This is on YunoHost server just to avoid the file from disappearing
# Original source is https://releases.wekan.team/wekan-4.64.zip # Original source is https://releases.wekan.team/wekan-5.00.zip
# YunoHost source is https://build.yunohost.org/apps/wekan-4.64.zip # YunoHost source is https://build.yunohost.org/apps/wekan-5.00.zip
SOURCE_URL=https://build.yunohost.org/apps/wekan-4.64.zip SOURCE_URL=https://build.yunohost.org/apps/wekan-5.00.zip
SOURCE_SUM=2a7f4486c4356ba8beb704e99c999a1ef05b06953eedff516733bc34c1e1063e SOURCE_SUM=815a6893185c4f063582afe13a63b78f3bfd5bd8bfe290ba002117657426b5cf
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=wekan-4.64.zip SOURCE_FILENAME=wekan-5.00.zip

View file

@ -1,32 +1,34 @@
--- ---
name: Bug report name: Bug report
about: Create a report to help us debug, it would be nice to fill the template as much as you can to help us, help you and help us all. about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.
--- ---
**How to post a meaningful bug report** **How to post a meaningful bug report**
1. *Read this whole template first.* 1. *Read this whole template first.*
2. *Determine if you are on the right place:* 2. *Determine if you are on the right place:*
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!* - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
- *Otherwise, the issue may be due to Wekan itself. Refer to its documentation or repository for help.* - *Otherwise, the issue may be due to Wekan itself. Refer to its documentation or repository for help.*
- *If you have a doubt, post here, we will figure it out together.* - *When in doubt, post here and we will figure it out together.*
3. *Delete the italic comments as you write over them below, and remove this guide.* 3. *Delete the italic comments as you write over them below, and remove this guide.*
--- ---
**Describe the bug** ### Describe the bug
*A clear and concise description of what the bug is.* *A clear and concise description of what the bug is.*
**Versions** ### Context
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* - Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
- YunoHost version: x.x.x - YunoHost version: x.x.x
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* - I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?: *no / yes* - Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes*
- If yes, please explain: - If yes, please explain:
- Using, or trying to install package version/branch: - Using, or trying to install package version/branch:
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* - If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
**To Reproduce** ### Steps to reproduce
*Steps to reproduce the behavior.*
- *If you performed a command from the CLI, the command itself is enough. For example:* - *If you performed a command from the CLI, the command itself is enough. For example:*
```sh ```sh
sudo yunohost app install wekan sudo yunohost app install wekan
@ -34,13 +36,20 @@ about: Create a report to help us debug, it would be nice to fill the template a
- *If you used the webadmin, please perform the equivalent command from the CLI first.* - *If you used the webadmin, please perform the equivalent command from the CLI first.*
- *If the error occurs in your browser, explain what you did:* - *If the error occurs in your browser, explain what you did:*
1. *Go to '...'* 1. *Go to '...'*
2. *Click on '....'* 2. *Click on '...'*
3. *Scroll down to '....'* 3. *Scroll down to '...'*
4. *See error* 4. *See error*
**Expected behavior** ### Expected behavior
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* *A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
**Logs** ### Logs
*After a failed command, YunoHost makes the log available to you, but also to others, thanks to `yunohost log display [log name] --share`. The actual command, with the correct log name, is displayed at the end of the failed attempt in the CLI. Execute it and copy here the share link it outputs.*
*When an operation fails, YunoHost provides a simple way to share the logs.*
- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*
- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*
*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*
*If applicable and useful, add screenshots to help explain your problem.* *If applicable and useful, add screenshots to help explain your problem.*

View file

@ -6,7 +6,7 @@
"en": "Trello-like kanban", "en": "Trello-like kanban",
"fr": "Un kanban similaire à Trello" "fr": "Un kanban similaire à Trello"
}, },
"version": "4.64~ynh2", "version": "5.00~ynh1",
"url": "https://wekan.io", "url": "https://wekan.io",
"license": "MIT", "license": "MIT",
"maintainer": [ "maintainer": [
@ -19,7 +19,7 @@
"name": "ljf" "name": "ljf"
}], }],
"requirements": { "requirements": {
"yunohost": ">= 3.8.1" "yunohost": ">= 4.1.3"
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [
@ -51,7 +51,7 @@
"type": "user", "type": "user",
"ask": { "ask": {
"en": "Choose an admin user", "en": "Choose an admin user",
"fr": "Choisissez ladministrateur" "fr": "Choisissez l'administrateur"
}, },
"example": "johndoe" "example": "johndoe"
}, },

View file

@ -13,6 +13,4 @@
## Package_check results ## Package_check results
--- ---
*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* * An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"*
[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/wekan_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/wekan_ynh%20PR-NUM-%20(USERNAME)/)

View file

@ -8,7 +8,6 @@
source _common.sh source _common.sh
source ynh_detect_arch__2 source ynh_detect_arch__2
source ynh_add_config
source ynh_mongo_db source ynh_mongo_db
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -58,7 +57,6 @@ ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain 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=path --value=$path_url
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
@ -152,7 +150,7 @@ find "$final_path" -type d -print0 | xargs -0 chmod 750
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description "Wekan daemon" yunohost service add $app --description="Wekan daemon"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -169,14 +167,16 @@ fi
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring SSOwat..." ynh_script_progression --message="Configuring permissions..."
ynh_permission_create --permission="admin" --allowed "$admin" ynh_permission_create --permission="admin" --allowed "$admin"
# Make app public if necessary # Make app public if necessary
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
then then
ynh_permission_update --permission "main" --add "visitors" # Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi fi
#================================================= #=================================================

View file

@ -32,7 +32,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) # Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null if ynh_exec_warn_less yunohost service status $app >/dev/null
then then
ynh_script_progression --message="Removing $app service..." ynh_script_progression --message="Removing $app service integration..."
yunohost service remove $app yunohost service remove $app
fi fi

View file

@ -113,7 +113,7 @@ systemctl enable $app.service --quiet
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description "Wekan daemon" yunohost service add $app --description="Wekan daemon"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE

View file

@ -9,7 +9,6 @@
source _common.sh source _common.sh
source ynh_package_version source ynh_package_version
source ynh_detect_arch__2 source ynh_detect_arch__2
source ynh_add_config
source ynh_mongo_db source ynh_mongo_db
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -38,10 +37,16 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." ynh_script_progression --message="Ensuring downward compatibility..."
# If db_name doesn't exist, create it # Cleaning legacy permissions
if [ -z "$db_name" ]; then if ynh_legacy_permissions_exists; then
db_name=$(ynh_sanitize_dbid --db_name=$app) ynh_legacy_permissions_delete_all
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_app_setting_delete --app=$app --key=is_public
fi
if ! ynh_permission_exists --permission="admin"; then
# Create the required permissions
ynh_permission_create --permission="admin" --allowed "$admin"
fi fi
#================================================= #=================================================
@ -215,7 +220,7 @@ find "$final_path" -type d -print0 | xargs -0 chmod 750
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description "Wekan daemon" yunohost service add $app --description="Wekan daemon"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE

View file

@ -1,140 +0,0 @@
#!/bin/bash
# Create a dedicated config file from a template
#
# examples:
# ynh_add_config --template=".env" --destination="$final_path/.env"
# ynh_add_config --template="../conf/.env" --destination="$final_path/.env"
# ynh_add_config --template="/etc/nginx/sites-available/default" --destination="etc/nginx/sites-available/mydomain.conf"
#
# usage: ynh_add_config --template="template" --destination="destination"
# | arg: -t, --template= - Template config file to use
# | arg: -d, --destination= - Destination of the config file
#
# The template can be by default the name of a file in the conf directory
# of a YunoHost Package, a relative path or an absolute path
# The helper will use the template $template to generate a config file
# $destination by replacing the following keywords with global variables
# that should be defined before calling this helper :
# __PATH__ by $path_url
# __NAME__ by $app
# __NAMETOCHANGE__ by $app
# __USER__ by $app
# __FINALPATH__ by $final_path
# __PHPVERSION__ by $YNH_PHP_VERSION
#
# And any dynamic variables that should be defined before calling this helper like:
# __DOMAIN__ by $domain
# __APP__ by $app
# __VAR_1__ by $var_1
# __VAR_2__ by $var_2
#
# The helper will verify the checksum and backup the destination file
# if it's different before applying the new template.
# And it will calculate and store the destination file checksum
# into the app settings when configuration is done.
#
#
ynh_add_config () {
# Declare an array to define the options of this helper.
local legacy_args=tdv
local -A args_array=( [t]=template= [d]=destination= )
local template
local destination
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
local template_path
if [ -f "../conf/$template" ]; then
template_path="../conf/$template"
elif [ -f "../settings/conf/$template" ]; then
template_path="../settings/conf/$template"
elif [ -f "$template" ]; then
template_path=$template
else
ynh_die --message="The provided template $template doesn't exist"
fi
ynh_backup_if_checksum_is_different --file="$destination"
cp "$template_path" "$destination"
ynh_replace_vars --file="$destination"
ynh_store_file_checksum --file="$destination"
}
# Replace variables in a file
#
# usage: ynh_replace_vars --file="file"
# | arg: -f, --file= - File where to replace variables
#
# The helper will replace the following keywords with global variables
# that should be defined before calling this helper :
# __PATH__ by $path_url
# __NAME__ by $app
# __NAMETOCHANGE__ by $app
# __USER__ by $app
# __FINALPATH__ by $final_path
# __PHPVERSION__ by $YNH_PHP_VERSION
#
# And any dynamic variables that should be defined before calling this helper like:
# __DOMAIN__ by $domain
# __APP__ by $app
# __VAR_1__ by $var_1
# __VAR_2__ by $var_2
#
#
ynh_replace_vars () {
# Declare an array to define the options of this helper.
local legacy_args=f
local -A args_array=( [f]=file= )
local file
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
# Replace specific YunoHost variables
if test -n "${path_url:-}"
then
# path_url_slash_less is path_url, or a blank value if path_url is only '/'
local path_url_slash_less=${path_url%/}
ynh_replace_string --match_string="__PATH__/" --replace_string="$path_url_slash_less/" --target_file="$file"
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$file"
fi
if test -n "${app:-}"; then
ynh_replace_string --match_string="__NAME__" --replace_string="$app" --target_file="$file"
ynh_replace_string --match_string="__NAMETOCHANGE__" --replace_string="$app" --target_file="$file"
ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="$file"
fi
if test -n "${final_path:-}"; then
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$file"
fi
if test -n "${YNH_PHP_VERSION:-}"; then
ynh_replace_string --match_string="__PHPVERSION__" --replace_string="$YNH_PHP_VERSION" --target_file="$file"
fi
if test -n "${ynh_node_load_PATH:-}"; then
ynh_replace_string --match_string="__YNH_NODE_LOAD_PATH__" --replace_string="$ynh_node_load_PATH" --target_file="$file"
fi
# Replace others variables
# List other unique (__ __) variables in $file
local uniques_vars=( $(grep -o '__[A-Z0-9_]*__' $file | sort --unique | sed "s@__\([^.]*\)__@\L\1@g" ))
# Do the replacement
local delimit=@
for one_var in "${uniques_vars[@]}"
do
# Validate that one_var is indeed defined
test -n "${!one_var:-}" || ynh_die --message="\$$one_var wasn't initialized when trying to replace __${one_var^^}__ in $file"
# Escape delimiter in match/replace string
match_string="__${one_var^^}__"
match_string=${match_string//${delimit}/"\\${delimit}"}
replace_string="${!one_var}"
replace_string=${replace_string//${delimit}/"\\${delimit}"}
# Actually replace (sed is used instead of ynh_replace_string to avoid triggering an epic amount of debug logs)
sed --in-place "s${delimit}${match_string}${delimit}${replace_string}${delimit}g" "$file"
done
}