From e03cc8c117a8e6213064aaf26a566e0ed5774191 Mon Sep 17 00:00:00 2001
From: dr41nU <50152843+dr41nU@users.noreply.github.com>
Date: Sun, 12 Apr 2020 15:23:40 +0200
Subject: [PATCH 01/10] Missing var for php version
---
scripts/install | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/install b/scripts/install
index 2a98bc5..cf31f87 100755
--- a/scripts/install
+++ b/scripts/install
@@ -215,7 +215,7 @@ ynh_use_logrotate
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
-ynh_systemd_action --service_name=php7.3-fpm --action=reload
+ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
From b6761491df86f4064c1f004054015b81265a3015 Mon Sep 17 00:00:00 2001
From: dr41nU <50152843+dr41nU@users.noreply.github.com>
Date: Sun, 12 Apr 2020 15:26:28 +0200
Subject: [PATCH 02/10] Missing version var for call to php
---
scripts/restore | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/scripts/restore b/scripts/restore
index d330801..ca24598 100755
--- a/scripts/restore
+++ b/scripts/restore
@@ -80,7 +80,7 @@ chown -R $app: $final_path
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
-ynh_restore_file --origin_path="/etc/php/7.2/fpm/pool.d/$app.conf"
+ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# SPECIFIC RESTORATION
@@ -117,11 +117,11 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
# SPECIFIC UPGRADE
#=================================================
init_composer $final_path
-cd $final_path && sudo /usr/bin/php7.2 artisan migrate --env=production --force
-cd $final_path && sudo /usr/bin/php7.2 artisan cache:clear
-cd $final_path && sudo /usr/bin/php7.2 artisan firefly:upgrade-database
-cd $final_path && sudo /usr/bin/php7.2 artisan firefly:verify
-cd $final_path && sudo /usr/bin/php7.2 artisan passport:install
+cd $final_path && sudo /usr/bin/$phpversion artisan migrate --env=production --force
+cd $final_path && sudo /usr/bin/$phpversion artisan cache:clear
+cd $final_path && sudo /usr/bin/$phpversion firefly:upgrade-database
+cd $final_path && sudo /usr/bin/$phpversion firefly:verify
+cd $final_path && sudo /usr/bin/$phpversion passport:install
#=================================================
# GENERIC FINALIZATION
@@ -130,7 +130,7 @@ cd $final_path && sudo /usr/bin/php7.2 artisan passport:install
#=================================================
ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
-ynh_systemd_action --service_name=php7.2-fpm --action=reload
+ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
From 913bc219e55544abb1977128cf9ea03a84274593 Mon Sep 17 00:00:00 2001
From: dr41nU <50152843+dr41nU@users.noreply.github.com>
Date: Sun, 12 Apr 2020 15:28:36 +0200
Subject: [PATCH 03/10] Version update
---
conf/app.src | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/conf/app.src b/conf/app.src
index 50df31d..79e2204 100644
--- a/conf/app.src
+++ b/conf/app.src
@@ -1,6 +1,6 @@
-SOURCE_URL=https://github.com/firefly-iii/firefly-iii/archive/5.1.0.tar.gz
-SOURCE_SUM=3e20da603780f218fbd0b1354ad975fb2f7af37b216a015b1c3a4a1783a06233
+SOURCE_URL=https://github.com/firefly-iii/firefly-iii/archive/5.2.0.tar.gz
+SOURCE_SUM=136ddb92167a63e0eeafc91c18d12285e28533f18441b80a683d69cb1ea05115
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
-SOURCE_FILENAME=firefly-iii-5.1.0.tar.gz
+SOURCE_FILENAME=firefly-iii-5.2.0.tar.gz
From 8eac138ecec3b610971f746d0354c890b86181e3 Mon Sep 17 00:00:00 2001
From: dr41nU <50152843+dr41nU@users.noreply.github.com>
Date: Sun, 12 Apr 2020 15:33:21 +0200
Subject: [PATCH 04/10] Upgrade version
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 1a98f32..cecbc34 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@

-# Firefly III v5.1.0 for YunoHost
+# Firefly III v5.2.0 for YunoHost
[](https://ci-apps.yunohost.org/jenkins/job/firefly-iii%20%28Community%29/lastBuild/consoleFull)
From 3ca8ddc29b6e182b6660bed99fe3bdcd9745822c Mon Sep 17 00:00:00 2001
From: dr41nU <50152843+dr41nU@users.noreply.github.com>
Date: Sun, 12 Apr 2020 15:33:48 +0200
Subject: [PATCH 05/10] Upgrade version
---
manifest.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/manifest.json b/manifest.json
index c7f61f1..7b3df92 100644
--- a/manifest.json
+++ b/manifest.json
@@ -6,7 +6,7 @@
"en": "Firefly III is a self-hosted financial manager.",
"fr": "Firefly III est un gestionnaire de finances personnelles."
},
- "version": "5.1.0",
+ "version": "5.2.0",
"url": "https://firefly-iii.org/",
"license": "GPL v3",
"maintainer": {
From afc6e45719dbef8b7f3f8f5eaebabcb073764233 Mon Sep 17 00:00:00 2001
From: root
Date: Sat, 9 May 2020 16:27:05 +0200
Subject: [PATCH 06/10] Merge Kay0u updates
---
scripts/restore | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/scripts/restore b/scripts/restore
index ca24598..d8aafe4 100755
--- a/scripts/restore
+++ b/scripts/restore
@@ -117,11 +117,11 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
# SPECIFIC UPGRADE
#=================================================
init_composer $final_path
-cd $final_path && sudo /usr/bin/$phpversion artisan migrate --env=production --force
-cd $final_path && sudo /usr/bin/$phpversion artisan cache:clear
-cd $final_path && sudo /usr/bin/$phpversion firefly:upgrade-database
-cd $final_path && sudo /usr/bin/$phpversion firefly:verify
-cd $final_path && sudo /usr/bin/$phpversion passport:install
+cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force
+cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear
+cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database
+cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify
+cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install
#=================================================
# GENERIC FINALIZATION
@@ -130,7 +130,7 @@ cd $final_path && sudo /usr/bin/$phpversion passport:install
#=================================================
ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --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
#=================================================
From 44257785f34e5bfdfad4801f6ffc373467909d11 Mon Sep 17 00:00:00 2001
From: dr41nU <50152843+dr41nU@users.noreply.github.com>
Date: Sat, 9 May 2020 16:55:48 +0200
Subject: [PATCH 07/10] Fix php version
---
scripts/upgrade | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/scripts/upgrade b/scripts/upgrade
index dc1ef09..7d7fb3b 100755
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -152,7 +152,7 @@ ynh_system_user_create --username=$app
ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1
# Create a dedicated php-fpm config
-ynh_add_fpm_config --phpversion=7.2
+ynh_add_fpm_config --phpversion=$phpversion
#=================================================
# STORE THE CONFIG FILE CHECKSUM
@@ -191,11 +191,11 @@ ynh_replace_string --match_string"yunomail" --replace_string="$email" --f
ynh_replace_string --match_string"yunodomain" --replace_string="$domain" --file="$final_path/.env"
init_composer $final_path
-cd $final_path && sudo /usr/bin/php7.2 artisan migrate --env=production --force
-cd $final_path && sudo /usr/bin/php7.2 artisan cache:clear
-cd $final_path && sudo /usr/bin/php7.2 artisan firefly:upgrade-database
-cd $final_path && sudo /usr/bin/php7.2 artisan firefly:verify
-cd $final_path && sudo /usr/bin/php7.2 artisan passport:install
+cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force
+cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear
+cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database
+cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify
+cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different --file="$final_path/.env"
@@ -229,7 +229,7 @@ fi
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
ynh_systemd_action --service_name=nginx --action=reload
-ynh_systemd_action --service_name=php7.2-fpm --action=reload
+ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
#=================================================
# END OF SCRIPT
From af0886c7f4841fc7b74fa56e7a0d09a448dfe286 Mon Sep 17 00:00:00 2001
From: root
Date: Sat, 9 May 2020 20:48:44 +0200
Subject: [PATCH 08/10] Fix upgrade script
---
scripts/restore.orig | 152 +++++++++++++++++++++++++++++++++++++++++++
scripts/restore~ | 152 +++++++++++++++++++++++++++++++++++++++++++
scripts/upgrade | 21 +++---
3 files changed, 317 insertions(+), 8 deletions(-)
create mode 100755 scripts/restore.orig
create mode 100755 scripts/restore~
diff --git a/scripts/restore.orig b/scripts/restore.orig
new file mode 100755
index 0000000..3a978b5
--- /dev/null
+++ b/scripts/restore.orig
@@ -0,0 +1,152 @@
+#!/bin/bash
+
+#=================================================
+# GENERIC START
+#=================================================
+# IMPORT GENERIC HELPERS
+#=================================================
+
+if [ ! -e _common.sh ]; then
+ # Get the _common.sh file if it's not in the current directory
+ cp ../settings/scripts/_common.sh ./_common.sh
+ chmod a+rx _common.sh
+fi
+
+source _common.sh
+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 settings..." --time --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)
+db_name=$(ynh_app_setting_get --app=$app --key=db_name)
+db_user=$db_name
+
+#=================================================
+# CHECK IF THE APP CAN BE RESTORED
+#=================================================
+ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
+
+ynh_webpath_available --domain=$domain --path_url=$path_url \
+|| ynh_die --message="Path not available: ${domain}${path_url}"
+test ! -d $final_path \
+|| ynh_die --message="There is already a directory: $final_path "s
+
+#=================================================
+# STANDARD RESTORATION STEPS
+#=================================================
+# RESTORE THE NGINX CONFIGURATION
+#=================================================
+
+ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
+
+#=================================================
+# RESTORE THE APP MAIN DIR
+#=================================================
+
+ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
+
+ynh_restore_file --origin_path="$final_path"
+
+#=================================================
+# RECREATE THE DEDICATED USER
+#=================================================
+ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
+
+# Create the dedicated user (if not existing)
+ynh_system_user_create --username=$app
+
+#=================================================
+# RESTORE USER RIGHTS
+#=================================================
+
+# Restore permissions on app files
+chown -R $app: $final_path
+
+#=================================================
+# RESTORE THE PHP-FPM CONFIGURATION
+#=================================================
+
+ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
+
+#=================================================
+# SPECIFIC RESTORATION
+#=================================================
+# REINSTALL DEPENDENCIES
+#=================================================
+ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1
+
+# Define and install dependencies
+ynh_install_app_dependencies $pkg_dependencies
+
+#=================================================
+# RESTORE THE MYSQL DATABASE
+#=================================================
+ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1
+
+db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
+ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
+ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
+
+#=================================================
+# ADVERTISE SERVICE IN ADMIN PANEL
+#=================================================
+
+yunohost service add $app --log "/var/log/$app/$app.log"
+
+#=================================================
+# RESTORE THE LOGROTATE CONFIGURATION
+#=================================================
+
+ynh_restore_file --origin_path="/etc/logrotate.d/$app"
+
+#=================================================
+# SPECIFIC UPGRADE
+#=================================================
+init_composer $final_path
+<<<<<<< HEAD
+cd $final_path && sudo /usr/bin/$phpversion artisan migrate --env=production --force
+cd $final_path && sudo /usr/bin/$phpversion artisan cache:clear
+cd $final_path && sudo /usr/bin/$phpversion firefly:upgrade-database
+cd $final_path && sudo /usr/bin/$phpversion firefly:verify
+cd $final_path && sudo /usr/bin/$phpversion passport:install
+=======
+cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force
+cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear
+cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database
+cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify
+cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install
+>>>>>>> 87fccba099c4ee4e22f4988fd409a8b760b3bfaf
+
+#=================================================
+# GENERIC FINALIZATION
+#=================================================
+# RELOAD NGINX AND PHP-FPM
+#=================================================
+ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
+
+<<<<<<< HEAD
+ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload
+=======
+ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
+>>>>>>> 87fccba099c4ee4e22f4988fd409a8b760b3bfaf
+ynh_systemd_action --service_name=nginx --action=reload
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Restoration completed for $app" --time --last
diff --git a/scripts/restore~ b/scripts/restore~
new file mode 100755
index 0000000..3a978b5
--- /dev/null
+++ b/scripts/restore~
@@ -0,0 +1,152 @@
+#!/bin/bash
+
+#=================================================
+# GENERIC START
+#=================================================
+# IMPORT GENERIC HELPERS
+#=================================================
+
+if [ ! -e _common.sh ]; then
+ # Get the _common.sh file if it's not in the current directory
+ cp ../settings/scripts/_common.sh ./_common.sh
+ chmod a+rx _common.sh
+fi
+
+source _common.sh
+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 settings..." --time --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)
+db_name=$(ynh_app_setting_get --app=$app --key=db_name)
+db_user=$db_name
+
+#=================================================
+# CHECK IF THE APP CAN BE RESTORED
+#=================================================
+ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
+
+ynh_webpath_available --domain=$domain --path_url=$path_url \
+|| ynh_die --message="Path not available: ${domain}${path_url}"
+test ! -d $final_path \
+|| ynh_die --message="There is already a directory: $final_path "s
+
+#=================================================
+# STANDARD RESTORATION STEPS
+#=================================================
+# RESTORE THE NGINX CONFIGURATION
+#=================================================
+
+ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
+
+#=================================================
+# RESTORE THE APP MAIN DIR
+#=================================================
+
+ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
+
+ynh_restore_file --origin_path="$final_path"
+
+#=================================================
+# RECREATE THE DEDICATED USER
+#=================================================
+ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
+
+# Create the dedicated user (if not existing)
+ynh_system_user_create --username=$app
+
+#=================================================
+# RESTORE USER RIGHTS
+#=================================================
+
+# Restore permissions on app files
+chown -R $app: $final_path
+
+#=================================================
+# RESTORE THE PHP-FPM CONFIGURATION
+#=================================================
+
+ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
+
+#=================================================
+# SPECIFIC RESTORATION
+#=================================================
+# REINSTALL DEPENDENCIES
+#=================================================
+ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1
+
+# Define and install dependencies
+ynh_install_app_dependencies $pkg_dependencies
+
+#=================================================
+# RESTORE THE MYSQL DATABASE
+#=================================================
+ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1
+
+db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
+ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
+ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
+
+#=================================================
+# ADVERTISE SERVICE IN ADMIN PANEL
+#=================================================
+
+yunohost service add $app --log "/var/log/$app/$app.log"
+
+#=================================================
+# RESTORE THE LOGROTATE CONFIGURATION
+#=================================================
+
+ynh_restore_file --origin_path="/etc/logrotate.d/$app"
+
+#=================================================
+# SPECIFIC UPGRADE
+#=================================================
+init_composer $final_path
+<<<<<<< HEAD
+cd $final_path && sudo /usr/bin/$phpversion artisan migrate --env=production --force
+cd $final_path && sudo /usr/bin/$phpversion artisan cache:clear
+cd $final_path && sudo /usr/bin/$phpversion firefly:upgrade-database
+cd $final_path && sudo /usr/bin/$phpversion firefly:verify
+cd $final_path && sudo /usr/bin/$phpversion passport:install
+=======
+cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force
+cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear
+cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database
+cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify
+cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install
+>>>>>>> 87fccba099c4ee4e22f4988fd409a8b760b3bfaf
+
+#=================================================
+# GENERIC FINALIZATION
+#=================================================
+# RELOAD NGINX AND PHP-FPM
+#=================================================
+ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
+
+<<<<<<< HEAD
+ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload
+=======
+ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
+>>>>>>> 87fccba099c4ee4e22f4988fd409a8b760b3bfaf
+ynh_systemd_action --service_name=nginx --action=reload
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Restoration completed for $app" --time --last
diff --git a/scripts/upgrade b/scripts/upgrade
index dc1ef09..f16bc97 100755
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -152,7 +152,7 @@ ynh_system_user_create --username=$app
ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1
# Create a dedicated php-fpm config
-ynh_add_fpm_config --phpversion=7.2
+ynh_add_fpm_config --phpversion="$phpversion"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
@@ -175,6 +175,9 @@ ynh_use_logrotate --non-append
#=================================================
# SPECIFIC UPGRADE
#=================================================
+# Install via composer
+ynh_install_composer --phpversion="$phpversion"
+
# Get the admin email
email=$(ynh_user_get_info --username=$admin --key='mail')
@@ -190,12 +193,13 @@ ynh_replace_string --match_string"yunobase" --replace_string="$db_name" --f
ynh_replace_string --match_string"yunomail" --replace_string="$email" --file="$final_path/.env"
ynh_replace_string --match_string"yunodomain" --replace_string="$domain" --file="$final_path/.env"
-init_composer $final_path
-cd $final_path && sudo /usr/bin/php7.2 artisan migrate --env=production --force
-cd $final_path && sudo /usr/bin/php7.2 artisan cache:clear
-cd $final_path && sudo /usr/bin/php7.2 artisan firefly:upgrade-database
-cd $final_path && sudo /usr/bin/php7.2 artisan firefly:verify
-cd $final_path && sudo /usr/bin/php7.2 artisan passport:install
+#init_composer $final_path
+
+cd $final_path && php$phpversion artisan migrate --env=production --force
+cd $final_path && php$phpversion artisan cache:clear
+cd $final_path && php$phpversion artisan firefly:upgrade-database
+cd $final_path && php$phpversion artisan firefly:verify
+cd $final_path && php$phpversion artisan passport:install
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different --file="$final_path/.env"
@@ -210,6 +214,7 @@ ynh_store_file_checksum --file="$final_path/.env"
# Set right permissions
chown -R $app: $final_path
+chmod -R 775 ${final_path}/storage
#=================================================
# SETUP SSOWAT
@@ -228,8 +233,8 @@ fi
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
+ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
-ynh_systemd_action --service_name=php7.2-fpm --action=reload
#=================================================
# END OF SCRIPT
From 8d3a467dd1619fb714eabaee65c2f3842fa95476 Mon Sep 17 00:00:00 2001
From: root
Date: Sat, 9 May 2020 21:17:00 +0200
Subject: [PATCH 09/10] Command order correction
---
scripts/restore.orig | 152 ------------------------
scripts/restore~ | 152 ------------------------
scripts/upgrade.orig | 271 -------------------------------------------
scripts/upgrade~ | 271 -------------------------------------------
4 files changed, 846 deletions(-)
delete mode 100755 scripts/restore.orig
delete mode 100755 scripts/restore~
delete mode 100755 scripts/upgrade.orig
delete mode 100755 scripts/upgrade~
diff --git a/scripts/restore.orig b/scripts/restore.orig
deleted file mode 100755
index 3a978b5..0000000
--- a/scripts/restore.orig
+++ /dev/null
@@ -1,152 +0,0 @@
-#!/bin/bash
-
-#=================================================
-# GENERIC START
-#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-
-if [ ! -e _common.sh ]; then
- # Get the _common.sh file if it's not in the current directory
- cp ../settings/scripts/_common.sh ./_common.sh
- chmod a+rx _common.sh
-fi
-
-source _common.sh
-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 settings..." --time --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)
-db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_user=$db_name
-
-#=================================================
-# CHECK IF THE APP CAN BE RESTORED
-#=================================================
-ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
-
-ynh_webpath_available --domain=$domain --path_url=$path_url \
-|| ynh_die --message="Path not available: ${domain}${path_url}"
-test ! -d $final_path \
-|| ynh_die --message="There is already a directory: $final_path "s
-
-#=================================================
-# STANDARD RESTORATION STEPS
-#=================================================
-# RESTORE THE NGINX CONFIGURATION
-#=================================================
-
-ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
-
-#=================================================
-# RESTORE THE APP MAIN DIR
-#=================================================
-
-ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
-
-ynh_restore_file --origin_path="$final_path"
-
-#=================================================
-# RECREATE THE DEDICATED USER
-#=================================================
-ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
-
-# Create the dedicated user (if not existing)
-ynh_system_user_create --username=$app
-
-#=================================================
-# RESTORE USER RIGHTS
-#=================================================
-
-# Restore permissions on app files
-chown -R $app: $final_path
-
-#=================================================
-# RESTORE THE PHP-FPM CONFIGURATION
-#=================================================
-
-ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
-
-#=================================================
-# SPECIFIC RESTORATION
-#=================================================
-# REINSTALL DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1
-
-# Define and install dependencies
-ynh_install_app_dependencies $pkg_dependencies
-
-#=================================================
-# RESTORE THE MYSQL DATABASE
-#=================================================
-ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1
-
-db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
-ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
-ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
-
-#=================================================
-# ADVERTISE SERVICE IN ADMIN PANEL
-#=================================================
-
-yunohost service add $app --log "/var/log/$app/$app.log"
-
-#=================================================
-# RESTORE THE LOGROTATE CONFIGURATION
-#=================================================
-
-ynh_restore_file --origin_path="/etc/logrotate.d/$app"
-
-#=================================================
-# SPECIFIC UPGRADE
-#=================================================
-init_composer $final_path
-<<<<<<< HEAD
-cd $final_path && sudo /usr/bin/$phpversion artisan migrate --env=production --force
-cd $final_path && sudo /usr/bin/$phpversion artisan cache:clear
-cd $final_path && sudo /usr/bin/$phpversion firefly:upgrade-database
-cd $final_path && sudo /usr/bin/$phpversion firefly:verify
-cd $final_path && sudo /usr/bin/$phpversion passport:install
-=======
-cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force
-cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear
-cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database
-cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify
-cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install
->>>>>>> 87fccba099c4ee4e22f4988fd409a8b760b3bfaf
-
-#=================================================
-# GENERIC FINALIZATION
-#=================================================
-# RELOAD NGINX AND PHP-FPM
-#=================================================
-ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
-
-<<<<<<< HEAD
-ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload
-=======
-ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
->>>>>>> 87fccba099c4ee4e22f4988fd409a8b760b3bfaf
-ynh_systemd_action --service_name=nginx --action=reload
-
-#=================================================
-# END OF SCRIPT
-#=================================================
-
-ynh_script_progression --message="Restoration completed for $app" --time --last
diff --git a/scripts/restore~ b/scripts/restore~
deleted file mode 100755
index 3a978b5..0000000
--- a/scripts/restore~
+++ /dev/null
@@ -1,152 +0,0 @@
-#!/bin/bash
-
-#=================================================
-# GENERIC START
-#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-
-if [ ! -e _common.sh ]; then
- # Get the _common.sh file if it's not in the current directory
- cp ../settings/scripts/_common.sh ./_common.sh
- chmod a+rx _common.sh
-fi
-
-source _common.sh
-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 settings..." --time --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)
-db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_user=$db_name
-
-#=================================================
-# CHECK IF THE APP CAN BE RESTORED
-#=================================================
-ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
-
-ynh_webpath_available --domain=$domain --path_url=$path_url \
-|| ynh_die --message="Path not available: ${domain}${path_url}"
-test ! -d $final_path \
-|| ynh_die --message="There is already a directory: $final_path "s
-
-#=================================================
-# STANDARD RESTORATION STEPS
-#=================================================
-# RESTORE THE NGINX CONFIGURATION
-#=================================================
-
-ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
-
-#=================================================
-# RESTORE THE APP MAIN DIR
-#=================================================
-
-ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
-
-ynh_restore_file --origin_path="$final_path"
-
-#=================================================
-# RECREATE THE DEDICATED USER
-#=================================================
-ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
-
-# Create the dedicated user (if not existing)
-ynh_system_user_create --username=$app
-
-#=================================================
-# RESTORE USER RIGHTS
-#=================================================
-
-# Restore permissions on app files
-chown -R $app: $final_path
-
-#=================================================
-# RESTORE THE PHP-FPM CONFIGURATION
-#=================================================
-
-ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
-
-#=================================================
-# SPECIFIC RESTORATION
-#=================================================
-# REINSTALL DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1
-
-# Define and install dependencies
-ynh_install_app_dependencies $pkg_dependencies
-
-#=================================================
-# RESTORE THE MYSQL DATABASE
-#=================================================
-ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1
-
-db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
-ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
-ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
-
-#=================================================
-# ADVERTISE SERVICE IN ADMIN PANEL
-#=================================================
-
-yunohost service add $app --log "/var/log/$app/$app.log"
-
-#=================================================
-# RESTORE THE LOGROTATE CONFIGURATION
-#=================================================
-
-ynh_restore_file --origin_path="/etc/logrotate.d/$app"
-
-#=================================================
-# SPECIFIC UPGRADE
-#=================================================
-init_composer $final_path
-<<<<<<< HEAD
-cd $final_path && sudo /usr/bin/$phpversion artisan migrate --env=production --force
-cd $final_path && sudo /usr/bin/$phpversion artisan cache:clear
-cd $final_path && sudo /usr/bin/$phpversion firefly:upgrade-database
-cd $final_path && sudo /usr/bin/$phpversion firefly:verify
-cd $final_path && sudo /usr/bin/$phpversion passport:install
-=======
-cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force
-cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear
-cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database
-cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify
-cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install
->>>>>>> 87fccba099c4ee4e22f4988fd409a8b760b3bfaf
-
-#=================================================
-# GENERIC FINALIZATION
-#=================================================
-# RELOAD NGINX AND PHP-FPM
-#=================================================
-ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
-
-<<<<<<< HEAD
-ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload
-=======
-ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
->>>>>>> 87fccba099c4ee4e22f4988fd409a8b760b3bfaf
-ynh_systemd_action --service_name=nginx --action=reload
-
-#=================================================
-# END OF SCRIPT
-#=================================================
-
-ynh_script_progression --message="Restoration completed for $app" --time --last
diff --git a/scripts/upgrade.orig b/scripts/upgrade.orig
deleted file mode 100755
index 98cde32..0000000
--- a/scripts/upgrade.orig
+++ /dev/null
@@ -1,271 +0,0 @@
-#!/bin/bash
-
-#=================================================
-# GENERIC START
-#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-
-source _common.sh
-source ynh_add_extra_apt_repos__3
-source ynh_install_php__3
-source ynh_composer
-source /usr/share/yunohost/helpers
-
-#=================================================
-# LOAD SETTINGS
-#=================================================
-ynh_script_progression --message="Loading installation settings..." --time --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)
-admin=$(ynh_app_setting_get --app=$app --key=admin)
-is_public=$(ynh_app_setting_get --app=$app --key=is_public)
-final_path=$(ynh_app_setting_get --app=$app --key=final_path)
-db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
-random_key=$(ynh_app_setting_get --app=$app --key=random_key)
-
-#=================================================
-# CHECK VERSION
-#=================================================
-
-upgrade_type=$(ynh_check_app_version_changed)
-
-#=================================================
-# ENSURE DOWNWARD COMPATIBILITY
-#=================================================
-ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
-
-# Fix is_public as a boolean value
-if [ "$is_public" = "Yes" ]; then
- ynh_app_setting_set --app=$app --key=is_public --value=1
- is_public=1
- elif [ "$is_public" = "No" ]; then
- ynh_app_setting_set --app=$app --key=is_public --value=0
- is_public=0
-fi
-
-# If db_name doesn't exist, create it
-if [ -z $db_name ]; then
- db_name=$(ynh_sanitize_dbid --db_name=$app)
- ynh_app_setting_set --app=$app --key=db_name --value=$db_name
-fi
-
-# If final_path doesn't exist, create it
-if [ -z "$final_path" ]; then
- final_path=/var/www/$app
- ynh_app_setting_set --app=$app --key=final_path --value=$final_path
-fi
-
-#=================================================
-# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
-#=================================================
-ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --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
-
-#=================================================
-# CHECK THE PATH
-#=================================================
-
-# Normalize the URL path syntax
-path_url=$(ynh_normalize_url_path --path_url=$path_url)
-
-#=================================================
-# DOWNLOAD, CHECK AND UNPACK SOURCE
-#=================================================
-ynh_script_progression --message="Upgrading source files..." --time --weight=1
-
-# Create a temporary directory
-tmpdir="$(mktemp -d)"
-# Backup the config file in the temp dir
-mkdir -p "$tmpdir/storage/upload"
-mkdir -p "$tmpdir/storage/export"
-mkdir -p "$final_path/storage/upload/"
-mkdir -p "$final_path/storage/export/"
-cp -a "$final_path/storage/upload/" "$tmpdir/storage/upload/"
-cp -a "$final_path/storage/export/" "$tmpdir/storage/export/"
-rm -Rf "$final_path"
-
-# Download, check integrity, uncompress and patch the source from app.src
-ynh_setup_source --dest_dir="$final_path"
-ynh_install_composer --phpversion="$phpversion"
-cd $final_path && php$phpversion artisan migrate:refresh --seed
-cd $final_path && php$phpversion artisan firefly-iii:upgrade-database
-cd $final_path && php$phpversion artisan passport:install
-
-
-rm -rf "$final_path/bootstrap/cache/*"
-
-cd $final_path && php$phpversion artisan cache:clear
-cd $final_path && php$phpversion artisan migrate --seed
-cd $final_path && php$phpversion artisan firefly-iii:upgrade-database
-cd $final_path && php$phpversion artisan passport:install
-cd $final_path && php$phpversion artisan cache:clear
-
-cp -a "$tmpdir/storage/upload/" "$final_path/storage/upload/"
-cp -a "$tmpdir/storage/export/" "$final_path/storage/export/"
-
-# Set right permissions
-chown -R $app:$app $final_path
-chmod -R 775 ${final_path}/storage
-
-#remove tmp dir
-sudo rm -Rf "$tmpdir"
-
-#=================================================
-# NGINX CONFIGURATION
-#=================================================
-ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1
-
-# Create a dedicated nginx config
-ynh_add_nginx_config
-
-#=================================================
-# UPGRADE DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
-
-ynh_install_app_dependencies $pkg_dependencies
-
-#=================================================
-# CREATE DEDICATED USER
-#=================================================
-ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
-
-# Create a dedicated user (if not existing)
-ynh_system_user_create --username=$app
-
-#=================================================
-# PHP-FPM CONFIGURATION
-#=================================================
-ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1
-
-# Create a dedicated php-fpm config
-<<<<<<< HEAD
-ynh_add_fpm_config --phpversion="$phpversion"
-||||||| merged common ancestors
-ynh_add_fpm_config --phpversion=7.2
-=======
-ynh_add_fpm_config --phpversion=$phpversion
->>>>>>> 44257785f34e5bfdfad4801f6ffc373467909d11
-
-#=================================================
-# STORE THE CONFIG FILE CHECKSUM
-#=================================================
-
-### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
-### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
-ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE"
-# Recalculate and store the checksum of the file for the next upgrade.
-ynh_store_file_checksum --file="$final_path/CONFIG_FILE"
-
-#=================================================
-# SETUP LOGROTATE
-#=================================================
-ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1
-
-# Use logrotate to manage app-specific logfile(s)
-ynh_use_logrotate --non-append
-
-#=================================================
-# SPECIFIC UPGRADE
-#=================================================
-# Install via composer
-ynh_install_composer --phpversion="$phpversion"
-
-# Get the admin email
-email=$(ynh_user_get_info --username=$admin --key='mail')
-
-# setup application config
-sudo cp ../conf/.env $final_path/.env
-#=================================================
-# MODIFY A CONFIG FILE
-#=================================================
-ynh_replace_string --match_string"random_key" --replace_string="$random_key" --file="$final_path/.env"
-ynh_replace_string --match_string"yunouser" --replace_string="$db_name" --file="$final_path/.env"
-ynh_replace_string --match_string"yunopass" --replace_string="$db_pwd" --file="$final_path/.env"
-ynh_replace_string --match_string"yunobase" --replace_string="$db_name" --file="$final_path/.env"
-ynh_replace_string --match_string"yunomail" --replace_string="$email" --file="$final_path/.env"
-ynh_replace_string --match_string"yunodomain" --replace_string="$domain" --file="$final_path/.env"
-
-<<<<<<< HEAD
-#init_composer $final_path
-
-cd $final_path && php$phpversion artisan migrate --env=production --force
-cd $final_path && php$phpversion artisan cache:clear
-cd $final_path && php$phpversion artisan firefly:upgrade-database
-cd $final_path && php$phpversion artisan firefly:verify
-cd $final_path && php$phpversion artisan passport:install
-||||||| merged common ancestors
-init_composer $final_path
-cd $final_path && sudo /usr/bin/php7.2 artisan migrate --env=production --force
-cd $final_path && sudo /usr/bin/php7.2 artisan cache:clear
-cd $final_path && sudo /usr/bin/php7.2 artisan firefly:upgrade-database
-cd $final_path && sudo /usr/bin/php7.2 artisan firefly:verify
-cd $final_path && sudo /usr/bin/php7.2 artisan passport:install
-=======
-init_composer $final_path
-cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force
-cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear
-cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database
-cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify
-cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install
->>>>>>> 44257785f34e5bfdfad4801f6ffc373467909d11
-
-# Verify the checksum and backup the file if it's different
-ynh_backup_if_checksum_is_different --file="$final_path/.env"
-# Recalculate and store the config file checksum into the app settings
-ynh_store_file_checksum --file="$final_path/.env"
-
-#=================================================
-# GENERIC FINALIZATION
-#=================================================
-# SECURE FILES AND DIRECTORIES
-#=================================================
-
-# Set right permissions
-chown -R $app: $final_path
-chmod -R 775 ${final_path}/storage
-
-#=================================================
-# SETUP SSOWAT
-#=================================================
-ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1
-
-# Make app public if necessary
-if [ $is_public -eq 1 ]
-then
- # unprotected_uris allows SSO credentials to be passed anyway
- ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
-fi
-
-#=================================================
-# RELOAD NGINX
-#=================================================
-ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
-
-ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload
-ynh_systemd_action --service_name=nginx --action=reload
-<<<<<<< HEAD
-||||||| merged common ancestors
-ynh_systemd_action --service_name=php7.2-fpm --action=reload
-=======
-ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
->>>>>>> 44257785f34e5bfdfad4801f6ffc373467909d11
-
-#=================================================
-# END OF SCRIPT
-#=================================================
-
-ynh_script_progression --message="Upgrade of $app completed" --time --last
diff --git a/scripts/upgrade~ b/scripts/upgrade~
deleted file mode 100755
index 98cde32..0000000
--- a/scripts/upgrade~
+++ /dev/null
@@ -1,271 +0,0 @@
-#!/bin/bash
-
-#=================================================
-# GENERIC START
-#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-
-source _common.sh
-source ynh_add_extra_apt_repos__3
-source ynh_install_php__3
-source ynh_composer
-source /usr/share/yunohost/helpers
-
-#=================================================
-# LOAD SETTINGS
-#=================================================
-ynh_script_progression --message="Loading installation settings..." --time --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)
-admin=$(ynh_app_setting_get --app=$app --key=admin)
-is_public=$(ynh_app_setting_get --app=$app --key=is_public)
-final_path=$(ynh_app_setting_get --app=$app --key=final_path)
-db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
-random_key=$(ynh_app_setting_get --app=$app --key=random_key)
-
-#=================================================
-# CHECK VERSION
-#=================================================
-
-upgrade_type=$(ynh_check_app_version_changed)
-
-#=================================================
-# ENSURE DOWNWARD COMPATIBILITY
-#=================================================
-ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
-
-# Fix is_public as a boolean value
-if [ "$is_public" = "Yes" ]; then
- ynh_app_setting_set --app=$app --key=is_public --value=1
- is_public=1
- elif [ "$is_public" = "No" ]; then
- ynh_app_setting_set --app=$app --key=is_public --value=0
- is_public=0
-fi
-
-# If db_name doesn't exist, create it
-if [ -z $db_name ]; then
- db_name=$(ynh_sanitize_dbid --db_name=$app)
- ynh_app_setting_set --app=$app --key=db_name --value=$db_name
-fi
-
-# If final_path doesn't exist, create it
-if [ -z "$final_path" ]; then
- final_path=/var/www/$app
- ynh_app_setting_set --app=$app --key=final_path --value=$final_path
-fi
-
-#=================================================
-# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
-#=================================================
-ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --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
-
-#=================================================
-# CHECK THE PATH
-#=================================================
-
-# Normalize the URL path syntax
-path_url=$(ynh_normalize_url_path --path_url=$path_url)
-
-#=================================================
-# DOWNLOAD, CHECK AND UNPACK SOURCE
-#=================================================
-ynh_script_progression --message="Upgrading source files..." --time --weight=1
-
-# Create a temporary directory
-tmpdir="$(mktemp -d)"
-# Backup the config file in the temp dir
-mkdir -p "$tmpdir/storage/upload"
-mkdir -p "$tmpdir/storage/export"
-mkdir -p "$final_path/storage/upload/"
-mkdir -p "$final_path/storage/export/"
-cp -a "$final_path/storage/upload/" "$tmpdir/storage/upload/"
-cp -a "$final_path/storage/export/" "$tmpdir/storage/export/"
-rm -Rf "$final_path"
-
-# Download, check integrity, uncompress and patch the source from app.src
-ynh_setup_source --dest_dir="$final_path"
-ynh_install_composer --phpversion="$phpversion"
-cd $final_path && php$phpversion artisan migrate:refresh --seed
-cd $final_path && php$phpversion artisan firefly-iii:upgrade-database
-cd $final_path && php$phpversion artisan passport:install
-
-
-rm -rf "$final_path/bootstrap/cache/*"
-
-cd $final_path && php$phpversion artisan cache:clear
-cd $final_path && php$phpversion artisan migrate --seed
-cd $final_path && php$phpversion artisan firefly-iii:upgrade-database
-cd $final_path && php$phpversion artisan passport:install
-cd $final_path && php$phpversion artisan cache:clear
-
-cp -a "$tmpdir/storage/upload/" "$final_path/storage/upload/"
-cp -a "$tmpdir/storage/export/" "$final_path/storage/export/"
-
-# Set right permissions
-chown -R $app:$app $final_path
-chmod -R 775 ${final_path}/storage
-
-#remove tmp dir
-sudo rm -Rf "$tmpdir"
-
-#=================================================
-# NGINX CONFIGURATION
-#=================================================
-ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1
-
-# Create a dedicated nginx config
-ynh_add_nginx_config
-
-#=================================================
-# UPGRADE DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
-
-ynh_install_app_dependencies $pkg_dependencies
-
-#=================================================
-# CREATE DEDICATED USER
-#=================================================
-ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
-
-# Create a dedicated user (if not existing)
-ynh_system_user_create --username=$app
-
-#=================================================
-# PHP-FPM CONFIGURATION
-#=================================================
-ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1
-
-# Create a dedicated php-fpm config
-<<<<<<< HEAD
-ynh_add_fpm_config --phpversion="$phpversion"
-||||||| merged common ancestors
-ynh_add_fpm_config --phpversion=7.2
-=======
-ynh_add_fpm_config --phpversion=$phpversion
->>>>>>> 44257785f34e5bfdfad4801f6ffc373467909d11
-
-#=================================================
-# STORE THE CONFIG FILE CHECKSUM
-#=================================================
-
-### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
-### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
-ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE"
-# Recalculate and store the checksum of the file for the next upgrade.
-ynh_store_file_checksum --file="$final_path/CONFIG_FILE"
-
-#=================================================
-# SETUP LOGROTATE
-#=================================================
-ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1
-
-# Use logrotate to manage app-specific logfile(s)
-ynh_use_logrotate --non-append
-
-#=================================================
-# SPECIFIC UPGRADE
-#=================================================
-# Install via composer
-ynh_install_composer --phpversion="$phpversion"
-
-# Get the admin email
-email=$(ynh_user_get_info --username=$admin --key='mail')
-
-# setup application config
-sudo cp ../conf/.env $final_path/.env
-#=================================================
-# MODIFY A CONFIG FILE
-#=================================================
-ynh_replace_string --match_string"random_key" --replace_string="$random_key" --file="$final_path/.env"
-ynh_replace_string --match_string"yunouser" --replace_string="$db_name" --file="$final_path/.env"
-ynh_replace_string --match_string"yunopass" --replace_string="$db_pwd" --file="$final_path/.env"
-ynh_replace_string --match_string"yunobase" --replace_string="$db_name" --file="$final_path/.env"
-ynh_replace_string --match_string"yunomail" --replace_string="$email" --file="$final_path/.env"
-ynh_replace_string --match_string"yunodomain" --replace_string="$domain" --file="$final_path/.env"
-
-<<<<<<< HEAD
-#init_composer $final_path
-
-cd $final_path && php$phpversion artisan migrate --env=production --force
-cd $final_path && php$phpversion artisan cache:clear
-cd $final_path && php$phpversion artisan firefly:upgrade-database
-cd $final_path && php$phpversion artisan firefly:verify
-cd $final_path && php$phpversion artisan passport:install
-||||||| merged common ancestors
-init_composer $final_path
-cd $final_path && sudo /usr/bin/php7.2 artisan migrate --env=production --force
-cd $final_path && sudo /usr/bin/php7.2 artisan cache:clear
-cd $final_path && sudo /usr/bin/php7.2 artisan firefly:upgrade-database
-cd $final_path && sudo /usr/bin/php7.2 artisan firefly:verify
-cd $final_path && sudo /usr/bin/php7.2 artisan passport:install
-=======
-init_composer $final_path
-cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force
-cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear
-cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database
-cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify
-cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install
->>>>>>> 44257785f34e5bfdfad4801f6ffc373467909d11
-
-# Verify the checksum and backup the file if it's different
-ynh_backup_if_checksum_is_different --file="$final_path/.env"
-# Recalculate and store the config file checksum into the app settings
-ynh_store_file_checksum --file="$final_path/.env"
-
-#=================================================
-# GENERIC FINALIZATION
-#=================================================
-# SECURE FILES AND DIRECTORIES
-#=================================================
-
-# Set right permissions
-chown -R $app: $final_path
-chmod -R 775 ${final_path}/storage
-
-#=================================================
-# SETUP SSOWAT
-#=================================================
-ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1
-
-# Make app public if necessary
-if [ $is_public -eq 1 ]
-then
- # unprotected_uris allows SSO credentials to be passed anyway
- ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
-fi
-
-#=================================================
-# RELOAD NGINX
-#=================================================
-ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
-
-ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload
-ynh_systemd_action --service_name=nginx --action=reload
-<<<<<<< HEAD
-||||||| merged common ancestors
-ynh_systemd_action --service_name=php7.2-fpm --action=reload
-=======
-ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
->>>>>>> 44257785f34e5bfdfad4801f6ffc373467909d11
-
-#=================================================
-# END OF SCRIPT
-#=================================================
-
-ynh_script_progression --message="Upgrade of $app completed" --time --last
From c5850cc394c10c073cd64eb2489068354b4e9120 Mon Sep 17 00:00:00 2001
From: root
Date: Sun, 10 May 2020 00:40:14 +0200
Subject: [PATCH 10/10] Fix for upgrade and restore (missing working directory
return after making artisan stuff)
---
scripts/_common.sh | 28 -----------
scripts/backup | 5 ++
scripts/install | 7 ++-
scripts/restore | 31 +++++++++---
scripts/upgrade | 114 +++++++++++++++++++++------------------------
5 files changed, 86 insertions(+), 99 deletions(-)
diff --git a/scripts/_common.sh b/scripts/_common.sh
index a1c1d9e..24fbe97 100644
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -38,34 +38,6 @@ exec_as() {
# Composer helpers
#
-# Execute a composer command from a given directory
-# usage: composer_exec AS_USER WORKDIR COMMAND [ARG ...]
-exec_composer() {
- local WORKDIR=$1
- shift 1
-
- COMPOSER_HOME="${WORKDIR}/.composer" \
- # sudo /usr/bin/php7.2 "${WORKDIR}/composer.phar" $@ \
- /usr/bin/php7.2 "${WORKDIR}/composer.phar" $@ \
- -d "${WORKDIR}" --no-interaction
-}
-
-# Install and initialize Composer in the given directory
-# usage: init_composer DESTDIR [AS_USER]
-init_composer() {
- local DESTDIR=$1
- local AS_USER=${2:-admin}
-
- # install composer
- curl -sS https://getcomposer.org/installer \
- | COMPOSER_HOME="${DESTDIR}/.composer" \
- sudo /usr/bin/php7.2 -- --quiet --install-dir="$DESTDIR" \
- || ynh_die "Unable to install Composer"
-
- # update dependencies to create composer.lock
- exec_composer "$DESTDIR" install --no-dev --prefer-dist --no-scripts \
- || ynh_die "Unable to update firefly-iii core dependencies"
-}
sudo_path () {
sudo env "PATH=$PATH" $@
diff --git a/scripts/backup b/scripts/backup
index 69c295a..5eda3df 100755
--- a/scripts/backup
+++ b/scripts/backup
@@ -11,9 +11,14 @@ if [ ! -e _common.sh ]; then
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
+
source _common.sh
+source ynh_add_extra_apt_repos__3
+source ynh_install_php__3
+source ynh_composer
source /usr/share/yunohost/helpers
+
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
diff --git a/scripts/install b/scripts/install
index cf31f87..80c5dfa 100755
--- a/scripts/install
+++ b/scripts/install
@@ -48,7 +48,6 @@ ynh_script_progression --message="Validating installation parameters..." --time
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
-#mkdir $final_path
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
@@ -143,9 +142,9 @@ ynh_replace_string "yunoappurl" "$domain$path_url" "$final_path/.env"
#init_composer $final_path $app
-cd $final_path && php$phpversion artisan migrate:refresh --seed
-cd $final_path && php$phpversion artisan firefly-iii:upgrade-database
-cd $final_path && php$phpversion artisan passport:install
+cd $final_path && php$phpversion artisan migrate:refresh --seed && cd $YNH_CWD
+cd $final_path && php$phpversion artisan firefly-iii:upgrade-database && cd $YNH_CWD
+cd $final_path && php$phpversion artisan passport:install && cd $YNH_CWD
#=================================================
diff --git a/scripts/restore b/scripts/restore
index d8aafe4..7055b3a 100755
--- a/scripts/restore
+++ b/scripts/restore
@@ -13,8 +13,12 @@ if [ ! -e _common.sh ]; then
fi
source _common.sh
+source ynh_add_extra_apt_repos__3
+source ynh_install_php__3
+source ynh_composer
source /usr/share/yunohost/helpers
+
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
@@ -116,12 +120,27 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# SPECIFIC UPGRADE
#=================================================
-init_composer $final_path
-cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force
-cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear
-cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database
-cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify
-cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install
+
+# Install via composer
+ynh_install_composer --phpversion="$phpversion"
+
+#cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force
+#cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear
+#cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database
+#cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify
+#cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install
+
+cd $final_path && php$phpversion artisan migrate:refresh --seed && cd $YNH_CWD
+cd $final_path && php$phpversion artisan firefly-iii:upgrade-database && cd $YNH_CWD
+cd $final_path && php$phpversion artisan passport:install && cd $YNH_CWD
+
+#=================================================
+# SETUP APPLICATION PERMISSIONS
+#=================================================
+
+# Set right permissions
+chown -R $app:$app $final_path
+chmod -R 775 ${final_path}/storage
#=================================================
# GENERIC FINALIZATION
diff --git a/scripts/upgrade b/scripts/upgrade
index f16bc97..916782b 100755
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -81,6 +81,13 @@ ynh_abort_if_errors
# Normalize the URL path syntax
path_url=$(ynh_normalize_url_path --path_url=$path_url)
+#=================================================
+# INSTALL DEPENDENCIES
+#=================================================
+
+ynh_script_progression --message="Installing dependencies..." --time --weight=1
+ynh_install_php --phpversion="$phpversion" --package="$pkg_dependencies"
+
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@@ -99,25 +106,61 @@ rm -Rf "$final_path"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
+
+#=================================================
+# SPECIFIC SETUP
+#=================================================
+
+# Install via composer
ynh_install_composer --phpversion="$phpversion"
-cd $final_path && php$phpversion artisan migrate:refresh --seed
-cd $final_path && php$phpversion artisan firefly-iii:upgrade-database
-cd $final_path && php$phpversion artisan passport:install
+# create a user
+email=$(ynh_user_get_info $admin 'mail')
-rm -rf "$final_path/bootstrap/cache/*"
+# setup application config
+sudo cp ../conf/.env $final_path/.env
-cd $final_path && php$phpversion artisan cache:clear
-cd $final_path && php$phpversion artisan migrate --seed
-cd $final_path && php$phpversion artisan firefly-iii:upgrade-database
-cd $final_path && php$phpversion artisan passport:install
-cd $final_path && php$phpversion artisan cache:clear
+#=================================================
+# MODIFY A CONFIG FILE
+#=================================================
+ynh_replace_string "random_key" "$random_key" "$final_path/.env"
+ynh_replace_string "yunouser" "$db_name" "$final_path/.env"
+ynh_replace_string "yunopass" "$db_pwd" "$final_path/.env"
+ynh_replace_string "yunobase" "$db_name" "$final_path/.env"
+ynh_replace_string "yunomail" "$email" "$final_path/.env"
+ynh_replace_string "yunodomain" "$domain" "$final_path/.env"
+ynh_replace_string "yunoappurl" "$domain$path_url" "$final_path/.env"
+
+#Run artisan stuff
+
+cd $final_path && php$phpversion artisan migrate:refresh --seed && cd $YNH_CWD
+cd $final_path && php$phpversion artisan firefly-iii:upgrade-database && cd $YNH_CWD
+cd $final_path && php$phpversion artisan passport:install && cd $YNH_CWD
+
+#rm -rf "$final_path/bootstrap/cache/*"
+
+#cd $final_path && php$phpversion artisan cache:clear
+#cd $final_path && php$phpversion artisan migrate --seed
+#cd $final_path && php$phpversion artisan firefly-iii:upgrade-database
+#cd $final_path && php$phpversion artisan passport:install
+#cd $final_path && php$phpversion artisan cache:clear
+
+# Verify the checksum and backup the file if it's different
+ynh_backup_if_checksum_is_different --file="$final_path/.env"
+# Recalculate and store the config file checksum into the app settings
+ynh_store_file_checksum --file="$final_path/.env"
cp -a "$tmpdir/storage/upload/" "$final_path/storage/upload/"
cp -a "$tmpdir/storage/export/" "$final_path/storage/export/"
+#=================================================
+# GENERIC FINALIZATION
+#=================================================
+# SECURE FILES AND DIRECTORIES
+#=================================================
+
# Set right permissions
-chown -R $app:$app $final_path
+chown -R $app: $final_path
chmod -R 775 ${final_path}/storage
#remove tmp dir
@@ -131,13 +174,6 @@ ynh_script_progression --message="Upgrading nginx web server configuration..." -
# Create a dedicated nginx config
ynh_add_nginx_config
-#=================================================
-# UPGRADE DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
-
-ynh_install_app_dependencies $pkg_dependencies
-
#=================================================
# CREATE DEDICATED USER
#=================================================
@@ -172,50 +208,6 @@ ynh_script_progression --message="Upgrading logrotate configuration..." --time -
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
-#=================================================
-# SPECIFIC UPGRADE
-#=================================================
-# Install via composer
-ynh_install_composer --phpversion="$phpversion"
-
-# Get the admin email
-email=$(ynh_user_get_info --username=$admin --key='mail')
-
-# setup application config
-sudo cp ../conf/.env $final_path/.env
-#=================================================
-# MODIFY A CONFIG FILE
-#=================================================
-ynh_replace_string --match_string"random_key" --replace_string="$random_key" --file="$final_path/.env"
-ynh_replace_string --match_string"yunouser" --replace_string="$db_name" --file="$final_path/.env"
-ynh_replace_string --match_string"yunopass" --replace_string="$db_pwd" --file="$final_path/.env"
-ynh_replace_string --match_string"yunobase" --replace_string="$db_name" --file="$final_path/.env"
-ynh_replace_string --match_string"yunomail" --replace_string="$email" --file="$final_path/.env"
-ynh_replace_string --match_string"yunodomain" --replace_string="$domain" --file="$final_path/.env"
-
-#init_composer $final_path
-
-cd $final_path && php$phpversion artisan migrate --env=production --force
-cd $final_path && php$phpversion artisan cache:clear
-cd $final_path && php$phpversion artisan firefly:upgrade-database
-cd $final_path && php$phpversion artisan firefly:verify
-cd $final_path && php$phpversion artisan passport:install
-
-# Verify the checksum and backup the file if it's different
-ynh_backup_if_checksum_is_different --file="$final_path/.env"
-# Recalculate and store the config file checksum into the app settings
-ynh_store_file_checksum --file="$final_path/.env"
-
-#=================================================
-# GENERIC FINALIZATION
-#=================================================
-# SECURE FILES AND DIRECTORIES
-#=================================================
-
-# Set right permissions
-chown -R $app: $final_path
-chmod -R 775 ${final_path}/storage
-
#=================================================
# SETUP SSOWAT
#=================================================