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:
commit
ef6390a4b5
12 changed files with 180 additions and 85 deletions
18
README.md
18
README.md
|
@ -5,7 +5,7 @@ It shall NOT be edited by hand.
|
|||
|
||||
# Paheko for YunoHost
|
||||
|
||||
[](https://dash.yunohost.org/appci/app/paheko)  
|
||||
[](https://dash.yunohost.org/appci/app/paheko)  
|
||||
[](https://install-app.yunohost.org/?app=paheko)
|
||||
|
||||
*[Lire ce readme en français.](./README_fr.md)*
|
||||
|
@ -33,7 +33,7 @@ You can now upgrade Garradin with Paheko !
|
|||

|
||||
|
||||
|
||||
**Shipped version:** 1.2.4~ynh1
|
||||
**Shipped version:** 1.2.6~ynh1
|
||||
|
||||
**Demo:** https://paheko.cloud/essai/
|
||||
|
||||
|
@ -41,6 +41,20 @@ You can now upgrade Garradin with Paheko !
|
|||
|
||||

|
||||
|
||||
## 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
|
||||
|
||||
* Official app website: <https://paheko.cloud>
|
||||
|
|
36
README_fr.md
36
README_fr.md
|
@ -5,15 +5,15 @@ It shall NOT be edited by hand.
|
|||
|
||||
# Paheko pour YunoHost
|
||||
|
||||
[](https://dash.yunohost.org/appci/app/paheko)  
|
||||
[](https://dash.yunohost.org/appci/app/paheko)  
|
||||
[](https://install-app.yunohost.org/?app=paheko)
|
||||
|
||||
*[Read this readme in english.](./README.md)*
|
||||
|
||||
> *Ce package vous permet d'installer 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.*
|
||||
> *Ce package vous permet d’installer 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.*
|
||||
|
||||
## Vue d'ensemble
|
||||
## Vue d’ensemble
|
||||
|
||||
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
|
|||

|
||||
|
||||
|
||||
**Version incluse :** 1.2.4~ynh1
|
||||
**Version incluse :** 1.2.6~ynh1
|
||||
|
||||
**Démo :** https://paheko.cloud/essai/
|
||||
|
||||
## Captures d'écran
|
||||
## Captures d’écran
|
||||
|
||||

|
||||

|
||||
|
||||
## 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
|
||||
|
||||
* Site officiel de l'app : <https://paheko.cloud>
|
||||
* Documentation officielle de l'admin : <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>
|
||||
* Site officiel de l’app : <https://paheko.cloud>
|
||||
* Documentation officielle de l’admin : <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>
|
||||
* Documentation YunoHost pour cette app : <https://yunohost.org/app_paheko>
|
||||
* 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
|
||||
```
|
||||
|
||||
**Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>
|
||||
**Plus d’infos sur le packaging d’applications :** <https://yunohost.org/packaging_apps>
|
|
@ -11,6 +11,7 @@
|
|||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=6e100378cfac2b3b13d83bd8d7d6d402e36b8bcb
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
change_url=1
|
||||
|
@ -21,3 +22,5 @@ Notification=none
|
|||
; commit=7205455e0a806a49c48c6d2f005d80d1b74a3355
|
||||
name=Previous version
|
||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_URL=https://fossil.kd2.org/paheko/uv/paheko-1.2.4.tar.gz
|
||||
SOURCE_SUM=50f0bfe9c05d2ee1664cbb0440602bdca576f23144e85fa5f9e27feeff36494c
|
||||
SOURCE_URL=https://fossil.kd2.org/paheko/uv/paheko-1.2.6.tar.gz
|
||||
SOURCE_SUM=bb1475aac6c41c8aedaa7191ec5df5f0a0516e3a93680fadcd45663545ec8b1f
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
|
|
7
conf/garradin_migrations
Normal file
7
conf/garradin_migrations
Normal 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
|
|
@ -18,15 +18,29 @@ old_app="__OLD_APP__"
|
|||
new_app="__NEW_APP__"
|
||||
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
|
||||
#=================================================
|
||||
|
||||
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
|
||||
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE OLD USER
|
||||
#=================================================
|
||||
ynh_user_exists --username=$old_app && ynh_system_user_delete $old_app
|
||||
|
||||
#=================================================
|
||||
# DELETE THIS SCRIPT
|
||||
#=================================================
|
||||
|
||||
echo "rm $script_name" | at now + 1 minutes
|
||||
echo "rm $script_name" | at now + 1 minutes
|
||||
|
|
|
@ -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.
|
|
@ -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.
|
|
@ -6,7 +6,7 @@
|
|||
"en": "Software to manage association",
|
||||
"fr": "Logiciel libre de gestion d'association"
|
||||
},
|
||||
"version": "1.2.4~ynh1",
|
||||
"version": "1.2.6~ynh1",
|
||||
"url": "https://paheko.cloud",
|
||||
"upstream": {
|
||||
"license": "GPL-3.0-or-later",
|
||||
|
|
|
@ -1,15 +1,4 @@
|
|||
# Execute a command as another user
|
||||
# usage: exec_as USER COMMAND [ARG ...]
|
||||
exec_as() {
|
||||
local USER=$1
|
||||
shift 1
|
||||
|
||||
if [[ $USER = $(whoami) ]]; then
|
||||
eval "$@"
|
||||
else
|
||||
sudo -u "$USER" "$@"
|
||||
fi
|
||||
}
|
||||
#!/bin/bash
|
||||
|
||||
# Need also the helper https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_handle_getopts_args/ynh_handle_getopts_args
|
||||
|
||||
|
@ -87,7 +76,7 @@ ynh_handle_app_migration () {
|
|||
fi
|
||||
|
||||
#=================================================
|
||||
# CHECK IF IT HAS TO MIGRATE
|
||||
# CHECK IF IT HAS TO MIGRATE
|
||||
#=================================================
|
||||
|
||||
migration_process=0
|
||||
|
@ -102,10 +91,10 @@ ynh_handle_app_migration () {
|
|||
if [ "$old_app_id" != "$migration_id" ]
|
||||
then
|
||||
# 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
|
||||
|
||||
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
|
||||
|
@ -113,8 +102,8 @@ ynh_handle_app_migration () {
|
|||
|
||||
# TODO Handle multi instance apps...
|
||||
# Check that there is not already an app installed for this id.
|
||||
(yunohost app list --installed -f "$new_app" | grep -q id) \
|
||||
&& ynh_die "$new_app is already installed"
|
||||
(yunohost app list | grep -q -w "id: $new_app") \
|
||||
&& ynh_die --message="$new_app is already installed"
|
||||
|
||||
#=================================================
|
||||
# CHECK THE LIST OF FILES TO MOVE
|
||||
|
@ -131,7 +120,7 @@ ynh_handle_app_migration () {
|
|||
do
|
||||
# Replace all occurences of $app by $new_app in each file to move.
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
|
@ -140,10 +129,10 @@ ynh_handle_app_migration () {
|
|||
|
||||
local settings_dir="/etc/yunohost/apps"
|
||||
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
|
||||
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:
|
||||
# if the id given in argument does not match with the id
|
||||
# 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
|
||||
|
||||
# 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" ]
|
||||
then
|
||||
# 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-)
|
||||
ynh_app_setting_set $new_app label $new_label
|
||||
ynh_app_setting_set --app=$new_app --key=label --value=$new_label
|
||||
fi
|
||||
|
||||
yunohost tools shell -c "from yunohost.permission import permission_delete; permission_delete('$old_app.main', force=True, sync_perm=False)"
|
||||
yunohost tools shell -c "from yunohost.permission import permission_create; permission_create('$new_app.main', url='/' , sync_perm=True)"
|
||||
permissions_name=$(yunohost user permission list $old_app --short --output-as plain)
|
||||
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
|
||||
|
@ -171,7 +165,7 @@ ynh_handle_app_migration () {
|
|||
# Replace all occurence of $app by $new_app in each file to move.
|
||||
move_to_destination="$(eval echo "${file_to_move//\$app/$new_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"
|
||||
done < "$temp_migration_list"
|
||||
|
||||
|
@ -180,46 +174,60 @@ ynh_handle_app_migration () {
|
|||
#=================================================
|
||||
|
||||
# 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
|
||||
ynh_replace_string "\(^checksum__etc_php5.*[-_]\)$old_app" "\1$new_app/" "$settings_dir/$new_app/settings.yml"
|
||||
# Replace php-fpm checksums
|
||||
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
|
||||
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)
|
||||
db_name=$dbname
|
||||
old_db_name=$(ynh_app_setting_get --app=$old_app --key=db_name)
|
||||
|
||||
# Check if a database exists before trying to move it
|
||||
local mysql_root_password=$(cat $MYSQL_ROOT_PWD_FILE)
|
||||
if [ -n "$db_name" ] && mysqlshow -u root -p$mysql_root_password | grep -q "^| $db_name"
|
||||
if [ -n "$old_db_name" ] && mysqlshow | grep -q "^| $old_db_name"
|
||||
then
|
||||
new_db_name=$(ynh_sanitize_dbid $new_app)
|
||||
echo "Rename the database $db_name to $new_db_name" >&2
|
||||
old_db_user=$old_db_name
|
||||
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"
|
||||
|
||||
# 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
|
||||
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
|
||||
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
|
||||
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
|
||||
ynh_secure_remove --file="$sql_dump"
|
||||
|
||||
# Update the value of $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
|
||||
|
||||
#=================================================
|
||||
|
@ -234,7 +242,7 @@ ynh_handle_app_migration () {
|
|||
local old_package_name="${old_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
|
||||
# Install a new fake package
|
||||
app=$new_app
|
||||
|
@ -254,4 +262,4 @@ ynh_handle_app_migration () {
|
|||
# Set migration_process to 1 to inform that an upgrade has been made
|
||||
migration_process=1
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,6 +100,7 @@ ynh_script_progression --message="Adding a configuration file..." --weight=5
|
|||
|
||||
# create a key for the secret key CSFR:
|
||||
secret_key=$(ynh_string_random --length=50)
|
||||
ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key
|
||||
|
||||
# Install configuration files
|
||||
ynh_add_config --template="config.local.php" --destination="$final_path/config.local.php"
|
||||
|
|
|
@ -39,9 +39,18 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
|
|||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup_migration() {
|
||||
yunohost app remove $app
|
||||
app=garradin ynh_restore_upgradebackup
|
||||
}
|
||||
|
||||
ynh_clean_setup () {
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
if [[ $migration_process -eq 1 ]]; then
|
||||
ynh_clean_setup_migration
|
||||
else
|
||||
ynh_restore_upgradebackup
|
||||
fi
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
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
|
||||
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
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
@ -71,20 +87,16 @@ fi
|
|||
#=================================================
|
||||
|
||||
[[ $YNH_APP_ID == "garradin" ]] \
|
||||
&& [[ "$(cat "/opt/$app/templates/.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."
|
||||
&& [[ "$(cat "$final_path/VERSION")" != 1.2.2 ]] \
|
||||
&& 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
|
||||
|
||||
if [[ $migration_process -eq 1 ]]; then
|
||||
# Reload variables
|
||||
dbname=$app
|
||||
db_user=$app
|
||||
|
||||
# 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"
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
ynh_permission_update --permission="main" --add="all_users"
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
|
@ -186,19 +198,19 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
#=================================================
|
||||
|
||||
if [[ $migration_process -eq 1 ]]; then
|
||||
echo "Garradin has been successfully migrated to Paheko! \
|
||||
A last scheduled operation will run in a couple of minutes to finish the \
|
||||
migration in YunoHost side. Do not proceed any application operation while \
|
||||
you don't see Garradin as installed." >&2
|
||||
echo "Garradin has been successfully migrated to Paheko! \
|
||||
A last scheduled operation will run in a couple of minutes to finish the \
|
||||
migration in YunoHost side. Do not proceed any application operation while \
|
||||
you don't see Garradin as installed." >&2
|
||||
|
||||
# Execute a post migration script after the end of this upgrade.
|
||||
# Mainly for some cleaning
|
||||
script_post_migration=garradin_post_migration.sh
|
||||
ynh_replace_string --match_string __OLD_APP__ --replace_string "$old_app" --target_file ../conf/$script_post_migration
|
||||
ynh_replace_string --match_string __NEW_APP__ --replace_string "$app" --target_file ../conf/$script_post_migration
|
||||
cp ../conf/$script_post_migration /tmp
|
||||
chmod +x /tmp/$script_post_migration
|
||||
(cd /tmp; echo "/tmp/$script_post_migration > /tmp/$script_post_migration.log 2>&1" | at now + 2 minutes)
|
||||
# Execute a post migration script after the end of this upgrade.
|
||||
# Mainly for some cleaning
|
||||
script_post_migration=garradin_post_migration.sh
|
||||
ynh_replace_string --match_string __OLD_APP__ --replace_string "$old_app" --target_file ../conf/$script_post_migration
|
||||
ynh_replace_string --match_string __NEW_APP__ --replace_string "$app" --target_file ../conf/$script_post_migration
|
||||
cp ../conf/$script_post_migration /tmp
|
||||
chmod +x /tmp/$script_post_migration
|
||||
(cd /tmp; echo "/tmp/$script_post_migration > /tmp/$script_post_migration.log 2>&1" | at now + 2 minutes)
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue