1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/paheko_ynh.git synced 2024-09-03 19:56:22 +02:00

Merge pull request #3 from YunoHost-Apps/testing

fix upgrade script, url to match VERSION, sqlite does not have a db n…
This commit is contained in:
Robles Rodolphe 2023-02-14 21:02:20 +01:00 committed by GitHub
commit ef6390a4b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 180 additions and 85 deletions

View file

@ -33,7 +33,7 @@ You can now upgrade Garradin with Paheko !
![Logo Paheko](https://master.garradin.eu/garradin-devient-paheko/logo_v3_small-fs8.png) ![Logo Paheko](https://master.garradin.eu/garradin-devient-paheko/logo_v3_small-fs8.png)
**Shipped version:** 1.2.4~ynh1 **Shipped version:** 1.2.6~ynh1
**Demo:** https://paheko.cloud/essai/ **Demo:** https://paheko.cloud/essai/
@ -41,6 +41,20 @@ You can now upgrade Garradin with Paheko !
![Screenshot of Paheko](./doc/screenshots/screenshot.png) ![Screenshot of Paheko](./doc/screenshots/screenshot.png)
## Disclaimers / important information
### Migrate from Garradin
This package handle the migration from Garradin to Paheko. For that, you will have to upgrade your Garradin application with this repository. This can only be done from the command-line interface - e.g. through SSH. Once you're connected, you simply have to execute the following:
```bash
sudo yunohost app upgrade garradin -u https://github.com/YunoHost-Apps/paheko_ynh --debug
```
The --debug option will let you see the full output. If you encounter any issue, please report it aand paste the logs.
**Important**: After the migration, you'll have to wait a couple of minutes (at most 3 minutes) before you can start using Paheko.
## Documentation and resources ## Documentation and resources
* Official app website: <https://paheko.cloud> * Official app website: <https://paheko.cloud>

View file

@ -5,15 +5,15 @@ It shall NOT be edited by hand.
# Paheko pour YunoHost # Paheko pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/paheko.svg)](https://dash.yunohost.org/appci/app/paheko) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/paheko.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/paheko.maintain.svg) [![Niveau dintégration](https://dash.yunohost.org/integration/paheko.svg)](https://dash.yunohost.org/appci/app/paheko) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/paheko.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/paheko.maintain.svg)
[![Installer Paheko avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=paheko) [![Installer Paheko avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=paheko)
*[Read this readme in english.](./README.md)* *[Read this readme in english.](./README.md)*
> *Ce package vous permet d'installer Paheko rapidement et simplement sur un serveur YunoHost. > *Ce package vous permet dinstaller Paheko 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.* Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment linstaller et en profiter.*
## Vue d'ensemble ## Vue densemble
Paheko (Nous avons choisi le nom Paheko, un mot de la langue Māori qui signifie « coopérer », illustrant le but du logiciel : améliorer ensemble le quotidien de la gestion d'une association) est un logiciel de gestion associative. Il est l'outil de prédilection pour gérer une association, un club sportif, une ONG, etc. Il est conçu pour répondre aux besoins d'une structure de petite à moyenne taille : gestion des adhérents, comptabilité, site web, prise de notes en réunion, archivage et partage des documents de fonctionnement de l'association, discussion entre adhérents, etc etc. Paheko (Nous avons choisi le nom Paheko, un mot de la langue Māori qui signifie « coopérer », illustrant le but du logiciel : améliorer ensemble le quotidien de la gestion d'une association) est un logiciel de gestion associative. Il est l'outil de prédilection pour gérer une association, un club sportif, une ONG, etc. Il est conçu pour répondre aux besoins d'une structure de petite à moyenne taille : gestion des adhérents, comptabilité, site web, prise de notes en réunion, archivage et partage des documents de fonctionnement de l'association, discussion entre adhérents, etc etc.
@ -29,19 +29,33 @@ Paheko (Nous avons choisi le nom Paheko, un mot de la langue Māori qui signifie
![Logo Paheko](https://master.garradin.eu/garradin-devient-paheko/logo_v3_small-fs8.png) ![Logo Paheko](https://master.garradin.eu/garradin-devient-paheko/logo_v3_small-fs8.png)
**Version incluse :** 1.2.4~ynh1 **Version incluse :** 1.2.6~ynh1
**Démo :** https://paheko.cloud/essai/ **Démo :** https://paheko.cloud/essai/
## Captures d'écran ## Captures décran
![Capture d'écran de Paheko](./doc/screenshots/screenshot.png) ![Capture décran de Paheko](./doc/screenshots/screenshot.png)
## Avertissements / informations importantes
### Migrer depuis Garradin
Ce paquet supporte la migration de Garradin vers Paheko. Pour ce faire, vous allez devoir mettre à jour l'application Garradin à l'aide de ce dépôt. Cette opération ne peut se faire seulement depuis une interface en ligne de commande, autrement dit en SSH. Une fois connecté/e, vous devez simplement lancer la commande suivante :
```bash
sudo yunohost app upgrade garradin -u https://github.com/YunoHost-Apps/paheko_ynh --debug
```
L'option debug vous permet de voir l'entièreté du journal d'installation. Si vous rencontrez des difficultés, merci de créer un ticket en collant le journal d'erreur.
**Important** : Après la migration, veuillez attendre quelques instants (maximum 3 minutes) avant de commencer à utiliser Paheko.
## Documentations et ressources ## Documentations et ressources
* Site officiel de l'app : <https://paheko.cloud> * Site officiel de lapp : <https://paheko.cloud>
* Documentation officielle de l'admin : <https://fossil.kd2.org/paheko/wiki?name=Documentation> * Documentation officielle de ladmin : <https://fossil.kd2.org/paheko/wiki?name=Documentation>
* Dépôt de code officiel de l'app : <https://fossil.kd2.org/paheko/dir?ci=tip> * Dépôt de code officiel de lapp : <https://fossil.kd2.org/paheko/dir?ci=tip>
* Documentation YunoHost pour cette app : <https://yunohost.org/app_paheko> * Documentation YunoHost pour cette app : <https://yunohost.org/app_paheko>
* Signaler un bug : <https://github.com/YunoHost-Apps/paheko_ynh/issues> * Signaler un bug : <https://github.com/YunoHost-Apps/paheko_ynh/issues>
@ -57,4 +71,4 @@ ou
sudo yunohost app upgrade paheko -u https://github.com/YunoHost-Apps/paheko_ynh/tree/testing --debug sudo yunohost app upgrade paheko -u https://github.com/YunoHost-Apps/paheko_ynh/tree/testing --debug
``` ```
**Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps> **Plus dinfos sur le packaging dapplications :** <https://yunohost.org/packaging_apps>

View file

@ -11,6 +11,7 @@
setup_private=1 setup_private=1
setup_public=1 setup_public=1
upgrade=1 upgrade=1
upgrade=1 from_commit=6e100378cfac2b3b13d83bd8d7d6d402e36b8bcb
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
change_url=1 change_url=1
@ -21,3 +22,5 @@ Notification=none
; commit=7205455e0a806a49c48c6d2f005d80d1b74a3355 ; commit=7205455e0a806a49c48c6d2f005d80d1b74a3355
name=Previous version name=Previous version
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://fossil.kd2.org/paheko/uv/paheko-1.2.4.tar.gz SOURCE_URL=https://fossil.kd2.org/paheko/uv/paheko-1.2.6.tar.gz
SOURCE_SUM=50f0bfe9c05d2ee1664cbb0440602bdca576f23144e85fa5f9e27feeff36494c SOURCE_SUM=bb1475aac6c41c8aedaa7191ec5df5f0a0516e3a93680fadcd45663545ec8b1f
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true

7
conf/garradin_migrations Normal file
View file

@ -0,0 +1,7 @@
# App main directory
/var/www/$app
# NGINX web server configuration
/etc/nginx/conf.d/$domain.d/$app.conf
/etc/php/8.0/fpm/pool.d/$app.conf

View file

@ -18,13 +18,27 @@ old_app="__OLD_APP__"
new_app="__NEW_APP__" new_app="__NEW_APP__"
script_name="$0" script_name="$0"
#=================================================
# DELETE OLD APP'S SESSIONS
#=================================================
[ -n "$old_app" ] && find /var/lib/php/sessions/ -user "$old_app" -delete
#================================================= #=================================================
# DELETE OLD APP'S SETTINGS # DELETE OLD APP'S SETTINGS
#================================================= #=================================================
ynh_secure_remove --file="/etc/yunohost/apps/$old_app" # `app=""` Circumvents this issue: https://github.com/YunoHost/issues/issues/2138
app="" ynh_secure_remove --file="/etc/yunohost/apps/$old_app"
yunohost app ssowatconf yunohost app ssowatconf
#=================================================
# REMOVE THE OLD USER
#=================================================
ynh_user_exists --username=$old_app && ynh_system_user_delete $old_app
#================================================= #=================================================
# DELETE THIS SCRIPT # DELETE THIS SCRIPT
#================================================= #=================================================

View file

@ -0,0 +1,11 @@
### Migrate from Garradin
This package handle the migration from Garradin to Paheko. For that, you will have to upgrade your Garradin application with this repository. This can only be done from the command-line interface - e.g. through SSH. Once you're connected, you simply have to execute the following:
```bash
sudo yunohost app upgrade garradin -u https://github.com/YunoHost-Apps/paheko_ynh --debug
```
The --debug option will let you see the full output. If you encounter any issue, please report it aand paste the logs.
**Important**: After the migration, you'll have to wait a couple of minutes (at most 3 minutes) before you can start using Paheko.

View file

@ -0,0 +1,11 @@
### Migrer depuis Garradin
Ce paquet supporte la migration de Garradin vers Paheko. Pour ce faire, vous allez devoir mettre à jour l'application Garradin à l'aide de ce dépôt. Cette opération ne peut se faire seulement depuis une interface en ligne de commande, autrement dit en SSH. Une fois connecté/e, vous devez simplement lancer la commande suivante :
```bash
sudo yunohost app upgrade garradin -u https://github.com/YunoHost-Apps/paheko_ynh --debug
```
L'option debug vous permet de voir l'entièreté du journal d'installation. Si vous rencontrez des difficultés, merci de créer un ticket en collant le journal d'erreur.
**Important** : Après la migration, veuillez attendre quelques instants (maximum 3 minutes) avant de commencer à utiliser Paheko.

View file

@ -6,7 +6,7 @@
"en": "Software to manage association", "en": "Software to manage association",
"fr": "Logiciel libre de gestion d'association" "fr": "Logiciel libre de gestion d'association"
}, },
"version": "1.2.4~ynh1", "version": "1.2.6~ynh1",
"url": "https://paheko.cloud", "url": "https://paheko.cloud",
"upstream": { "upstream": {
"license": "GPL-3.0-or-later", "license": "GPL-3.0-or-later",

View file

@ -1,15 +1,4 @@
# Execute a command as another user #!/bin/bash
# usage: exec_as USER COMMAND [ARG ...]
exec_as() {
local USER=$1
shift 1
if [[ $USER = $(whoami) ]]; then
eval "$@"
else
sudo -u "$USER" "$@"
fi
}
# Need also the helper https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_handle_getopts_args/ynh_handle_getopts_args # Need also the helper https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_handle_getopts_args/ynh_handle_getopts_args
@ -102,10 +91,10 @@ ynh_handle_app_migration () {
if [ "$old_app_id" != "$migration_id" ] if [ "$old_app_id" != "$migration_id" ]
then then
# If the new app is not the authorized id, fail. # If the new app is not the authorized id, fail.
ynh_die --message "Incompatible application for migration from $old_app_id to $new_app_id" ynh_die --message="Incompatible application for migration from $old_app_id to $new_app_id"
fi fi
echo "Migrate from $old_app_id to $new_app_id" >&2 ynh_print_info --message="Migrate from $old_app_id to $new_app_id" >&2
#================================================= #=================================================
# CHECK IF THE MIGRATION CAN BE DONE # CHECK IF THE MIGRATION CAN BE DONE
@ -113,8 +102,8 @@ ynh_handle_app_migration () {
# TODO Handle multi instance apps... # TODO Handle multi instance apps...
# Check that there is not already an app installed for this id. # Check that there is not already an app installed for this id.
(yunohost app list --installed -f "$new_app" | grep -q id) \ (yunohost app list | grep -q -w "id: $new_app") \
&& ynh_die "$new_app is already installed" && ynh_die --message="$new_app is already installed"
#================================================= #=================================================
# CHECK THE LIST OF FILES TO MOVE # CHECK THE LIST OF FILES TO MOVE
@ -131,7 +120,7 @@ ynh_handle_app_migration () {
do do
# Replace all occurences of $app by $new_app in each file to move. # Replace all occurences of $app by $new_app in each file to move.
local move_to_destination="${file_to_move//\$app/$new_app}" local move_to_destination="${file_to_move//\$app/$new_app}"
test -e "$move_to_destination" && ynh_die "A file named $move_to_destination already exists." test -e "$move_to_destination" && ynh_die --message="A file named $move_to_destination already exists."
done < "$temp_migration_list" done < "$temp_migration_list"
#================================================= #=================================================
@ -140,10 +129,10 @@ ynh_handle_app_migration () {
local settings_dir="/etc/yunohost/apps" local settings_dir="/etc/yunohost/apps"
cp -a "$settings_dir/$old_app" "$settings_dir/$new_app" cp -a "$settings_dir/$old_app" "$settings_dir/$new_app"
cp -a ../{scripts,conf} "$settings_dir/$new_app" cp -a ../{scripts,conf,manifest.json} "$settings_dir/$new_app"
# Replace the old id by the new one # Replace the old id by the new one
ynh_replace_string "\(^id: .*\)$old_app" "\1$new_app" "$settings_dir/$new_app/settings.yml" ynh_replace_string --match_string="\(^id: .*\)$old_app" --replace_string="\1$new_app" --target_file="$settings_dir/$new_app/settings.yml"
# INFO: There a special behavior with yunohost app setting: # INFO: There a special behavior with yunohost app setting:
# if the id given in argument does not match with the id # if the id given in argument does not match with the id
# stored in the config file, the config file will be purged. # stored in the config file, the config file will be purged.
@ -151,16 +140,21 @@ ynh_handle_app_migration () {
# https://github.com/YunoHost/yunohost/blob/c6b5284be8da39cf2da4e1036a730eb5e0515096/src/yunohost/app.py#L1316-L1321 # https://github.com/YunoHost/yunohost/blob/c6b5284be8da39cf2da4e1036a730eb5e0515096/src/yunohost/app.py#L1316-L1321
# Change the label if it's simply the name of the app # Change the label if it's simply the name of the app
old_label=$(ynh_app_setting_get $new_app label) old_label=$(ynh_app_setting_get --app=$new_app --key=label)
if [ "${old_label,,}" == "$old_app_id" ] if [ "${old_label,,}" == "$old_app_id" ]
then then
# Build the new label from the id of the app. With the first character as upper case # Build the new label from the id of the app. With the first character as upper case
new_label=$(echo $new_app_id | cut -c1 | tr [:lower:] [:upper:])$(echo $new_app_id | cut -c2-) new_label=$(echo $new_app_id | cut -c1 | tr [:lower:] [:upper:])$(echo $new_app_id | cut -c2-)
ynh_app_setting_set $new_app label $new_label ynh_app_setting_set --app=$new_app --key=label --value=$new_label
fi fi
yunohost tools shell -c "from yunohost.permission import permission_delete; permission_delete('$old_app.main', force=True, sync_perm=False)" permissions_name=$(yunohost user permission list $old_app --short --output-as plain)
yunohost tools shell -c "from yunohost.permission import permission_create; permission_create('$new_app.main', url='/' , sync_perm=True)" for permission_name in $permissions_name
do
yunohost tools shell -c "from yunohost.permission import permission_delete; permission_delete('$permission_name', force=True, sync_perm=False)"
done
yunohost tools shell -c "from yunohost.permission import permission_create; permission_create('$new_app.main', url='/' , show_tile=True , sync_perm=True)"
#================================================= #=================================================
# MOVE FILES TO THE NEW DESTINATION # MOVE FILES TO THE NEW DESTINATION
@ -171,7 +165,7 @@ ynh_handle_app_migration () {
# Replace all occurence of $app by $new_app in each file to move. # Replace all occurence of $app by $new_app in each file to move.
move_to_destination="$(eval echo "${file_to_move//\$app/$new_app}")" move_to_destination="$(eval echo "${file_to_move//\$app/$new_app}")"
local real_file_to_move="$(eval echo "${file_to_move//\$app/$old_app}")" local real_file_to_move="$(eval echo "${file_to_move//\$app/$old_app}")"
echo "Move file $real_file_to_move to $move_to_destination" >&2 ynh_print_info --message="Move file $real_file_to_move to $move_to_destination" >&2
mv "$real_file_to_move" "$move_to_destination" mv "$real_file_to_move" "$move_to_destination"
done < "$temp_migration_list" done < "$temp_migration_list"
@ -180,46 +174,60 @@ ynh_handle_app_migration () {
#================================================= #=================================================
# Replace nginx checksum # Replace nginx checksum
ynh_replace_string "\(^checksum__etc_nginx.*\)_$old_app" "\1_$new_app/" "$settings_dir/$new_app/settings.yml" ynh_replace_string --match_string="\(^checksum__etc_nginx.*\)_$old_app" --replace_string="\1_$new_app" --target_file="$settings_dir/$new_app/settings.yml"
# Replace php5-fpm checksums # Replace php-fpm checksums
ynh_replace_string "\(^checksum__etc_php5.*[-_]\)$old_app" "\1$new_app/" "$settings_dir/$new_app/settings.yml" ynh_replace_string --match_string="\(^checksum__etc_php.*[-_]\)$old_app" --replace_string="\1$new_app" --target_file="$settings_dir/$new_app/settings.yml"
# Replace final_path # Replace final_path
ynh_replace_string "\(^final_path: .*\)$old_app" "\1$new_app" "$settings_dir/$new_app/settings.yml" ynh_replace_string --match_string="\(^final_path: .*\)$old_app" --replace_string="\1$new_app" --target_file="$settings_dir/$new_app/settings.yml"
# Replace fail2ban_filter
ynh_replace_string --match_string="\(^checksum__etc_fail2ban_filter.*\)_$old_app" --replace_string="\1_$new_app" --target_file="$settings_dir/$new_app/settings.yml"
# Replace fail2ban_jail
ynh_replace_string --match_string="\(^checksum__etc_fail2ban_jail.*\)_$old_app" --replace_string="\1_$new_app" --target_file="$settings_dir/$new_app/settings.yml"
# Replace systemd
ynh_replace_string --match_string="\(^checksum__etc_systemd_system.*\)_$old_app" --replace_string="\1_$new_app" --target_file="$settings_dir/$new_app/settings.yml"
#================================================= #=================================================
# MOVE THE DATABASE # MOVE THE MYSQL DATABASE
#================================================= #=================================================
db_pwd=$(ynh_app_setting_get $old_app mysqlpwd) old_db_name=$(ynh_app_setting_get --app=$old_app --key=db_name)
db_name=$dbname
# Check if a database exists before trying to move it # Check if a database exists before trying to move it
local mysql_root_password=$(cat $MYSQL_ROOT_PWD_FILE) if [ -n "$old_db_name" ] && mysqlshow | grep -q "^| $old_db_name"
if [ -n "$db_name" ] && mysqlshow -u root -p$mysql_root_password | grep -q "^| $db_name"
then then
new_db_name=$(ynh_sanitize_dbid $new_app) old_db_user=$old_db_name
echo "Rename the database $db_name to $new_db_name" >&2 db_pwd=$(ynh_app_setting_get --app=$old_app --key=mysqlpwd)
new_db_name=$(ynh_sanitize_dbid --db_name=$new_app)
new_db_user=$new_db_name
ynh_print_info --message="Rename the database $db_name to $new_db_name" >&2
local sql_dump="/tmp/${db_name}-$(date '+%s').sql" local sql_dump="/tmp/${db_name}-$(date '+%s').sql"
# Dump the old database # Dump the old database
ynh_mysql_dump_db "$db_name" > "$sql_dump" ynh_mysql_dump_db --database="$old_db_name" > "$sql_dump"
# Create a new database # Create a new database
ynh_mysql_setup_db $new_db_name $new_db_name $db_pwd ynh_mysql_setup_db --db_user=$new_db_user --db_name=$new_db_name --db_pwd=$db_pwd
# Then restore the old one into the new one # Then restore the old one into the new one
ynh_mysql_connect_as $new_db_name $db_pwd $new_db_name < "$sql_dump" ynh_mysql_connect_as --user=$new_db_user --password=$db_pwd --database=$new_db_name < "$sql_dump"
# Remove the old database # Remove the old database
ynh_mysql_remove_db $db_name $db_name ynh_mysql_remove_db --db_user=$old_db_user --db_name=$old_db_name
# And the dump # And the dump
ynh_secure_remove --file="$sql_dump" ynh_secure_remove --file="$sql_dump"
# Update the value of $db_name # Update the value of $db_name
db_name=$new_db_name db_name=$new_db_name
ynh_app_setting_set $new_app db_name $db_name db_user=$new_db_user
ynh_app_setting_set --app=$new_app --key=db_name --value=$db_name
fi fi
#================================================= #=================================================
@ -234,7 +242,7 @@ ynh_handle_app_migration () {
local old_package_name="${old_app//_/-}-ynh-deps" local old_package_name="${old_app//_/-}-ynh-deps"
local new_package_name="${new_app//_/-}-ynh-deps" local new_package_name="${new_app//_/-}-ynh-deps"
if ynh_package_is_installed "$old_package_name" if ynh_package_is_installed --package="$old_package_name"
then then
# Install a new fake package # Install a new fake package
app=$new_app app=$new_app

View file

@ -100,6 +100,7 @@ ynh_script_progression --message="Adding a configuration file..." --weight=5
# create a key for the secret key CSFR: # create a key for the secret key CSFR:
secret_key=$(ynh_string_random --length=50) secret_key=$(ynh_string_random --length=50)
ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key
# Install configuration files # Install configuration files
ynh_add_config --template="config.local.php" --destination="$final_path/config.local.php" ynh_add_config --template="config.local.php" --destination="$final_path/config.local.php"

View file

@ -39,9 +39,18 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup_migration() {
yunohost app remove $app
app=garradin ynh_restore_upgradebackup
}
ynh_clean_setup () { ynh_clean_setup () {
# Restore it if the upgrade fails # Restore it if the upgrade fails
if [[ $migration_process -eq 1 ]]; then
ynh_clean_setup_migration
else
ynh_restore_upgradebackup ynh_restore_upgradebackup
fi
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -59,6 +68,13 @@ if [ -z "$final_path" ]; then
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi fi
# If secret_key doesn't exist, create it
if [[ -z "$secret_key" ]]; then
secret_key=$(ynh_string_random --length=50)
ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key
fi
# Cleaning legacy permissions # Cleaning legacy permissions
if ynh_legacy_permissions_exists; then if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all ynh_legacy_permissions_delete_all
@ -71,20 +87,16 @@ fi
#================================================= #=================================================
[[ $YNH_APP_ID == "garradin" ]] \ [[ $YNH_APP_ID == "garradin" ]] \
&& [[ "$(cat "/opt/$app/templates/.VERSION")" != 1.2.2 ]] \ && [[ "$(cat "$final_path/VERSION")" != 1.2.2 ]] \
&& ynh_die --message "It look like that you have an old Garradin install. You need first upgrade Garradin instance (id: $garradin_migrate_id) and after migrate to Paheko." && ynh_die --message "It looks like that you have an old Garradin installed. You need to first upgrade your Garradin instance (id: $garradin_migrate_id) and after to migrate to Paheko."
ynh_handle_app_migration --migration_id=garradin --migration_list=garradin_migrations ynh_handle_app_migration --migration_id=garradin --migration_list=garradin_migrations
if [[ $migration_process -eq 1 ]]; then if [[ $migration_process -eq 1 ]]; then
# Reload variables final_path=$(ynh_app_setting_get --app=$app --key=final_path)
dbname=$app ynh_permission_update --permission="main" --add="all_users"
db_user=$app ynh_permission_update --permission="main" --add="visitors"
fi
# Replace the user
ynh_system_user_delete --username="$old_app"
test getent passwd "$app" &>/dev/null || \
useradd -d "$datadir" --system --user-group "$app" --shell /bin/bash || \
ynh_die --message "Unable to create $app system account"
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS