diff --git a/README.md b/README.md
index 22798c1..c35ee4d 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ It shall NOT be edited by hand.
# OpenSondage for YunoHost
-[](https://dash.yunohost.org/appci/app/opensondage)  
+[](https://dash.yunohost.org/appci/app/opensondage)  
[](https://install-app.yunohost.org/?app=opensondage)
*[Lire ce readme en français.](./README_fr.md)*
@@ -17,13 +17,13 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
OpenSondage is an online service for planning an appointment or making a decision quickly and easily. No registration is required.
-**Shipped version:** 1.1.17~ynh1
+**Shipped version:** 1.1.17~ynh2
**Demo:** https://framadate.org/
## Screenshots
-
+
## Disclaimers / important information
@@ -38,21 +38,22 @@ OpenSondage is an online service for planning an appointment or making a decisio
## Documentation and resources
-* Official app website: https://framadate.org/
-* Official admin documentation: https://framagit.org/framasoft/framadate/framadate/wikis/home
-* Upstream app code repository: https://git.framasoft.org/framasoft/framadate
-* YunoHost documentation for this app: https://yunohost.org/app_opensondage
-* Report a bug: https://github.com/YunoHost-Apps/opensondage_ynh/issues
+* Official app website:
+* Official admin documentation:
+* Upstream app code repository:
+* YunoHost documentation for this app:
+* Report a bug:
## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/opensondage_ynh/tree/testing).
To try the testing branch, please proceed like that.
-```
+
+``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/opensondage_ynh/tree/testing --debug
or
sudo yunohost app upgrade opensondage -u https://github.com/YunoHost-Apps/opensondage_ynh/tree/testing --debug
```
-**More info regarding app packaging:** https://yunohost.org/packaging_apps
\ No newline at end of file
+**More info regarding app packaging:**
diff --git a/README_fr.md b/README_fr.md
index b7c02d9..d75de4d 100644
--- a/README_fr.md
+++ b/README_fr.md
@@ -1,10 +1,14 @@
+
+
# OpenSondage pour YunoHost
-[](https://dash.yunohost.org/appci/app/opensondage)  
+[](https://dash.yunohost.org/appci/app/opensondage)  
[](https://install-app.yunohost.org/?app=opensondage)
*[Read this readme in english.](./README.md)*
-*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer OpenSondage 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.*
@@ -13,13 +17,13 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
OpenSondage est un service en ligne permettant de planifier un rendez-vous ou prendre des décisions rapidement et simplement. Aucune inscription préalable n’est nécessaire.
-**Version incluse :** 1.1.17~ynh1
+**Version incluse :** 1.1.17~ynh2
**Démo :** https://framadate.org/
## Captures d'écran
-
+
## Avertissements / informations importantes
@@ -34,21 +38,22 @@ OpenSondage est un service en ligne permettant de planifier un rendez-vous ou pr
## Documentations et ressources
-* Site officiel de l'app : https://framadate.org/
-* Documentation officielle de l'admin : https://framagit.org/framasoft/framadate/framadate/wikis/home
-* Dépôt de code officiel de l'app : https://git.framasoft.org/framasoft/framadate
-* Documentation YunoHost pour cette app : https://yunohost.org/app_opensondage
-* Signaler un bug : https://github.com/YunoHost-Apps/opensondage_ynh/issues
+* Site officiel de l'app :
+* Documentation officielle de l'admin :
+* Dépôt de code officiel de l'app :
+* Documentation YunoHost pour cette app :
+* Signaler un bug :
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/opensondage_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
-```
+
+``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/opensondage_ynh/tree/testing --debug
ou
sudo yunohost app upgrade opensondage -u https://github.com/YunoHost-Apps/opensondage_ynh/tree/testing --debug
```
-**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps
\ No newline at end of file
+**Plus d'infos sur le packaging d'applications :**
diff --git a/check_process b/check_process
index cca0046..24935ab 100644
--- a/check_process
+++ b/check_process
@@ -2,9 +2,9 @@
; Manifest
domain="domain.tld"
path="/path"
- admin="john"
- language="fr"
is_public=1
+ language="fr"
+ admin="john"
; Checks
pkg_linter=1
setup_sub_dir=1
@@ -16,7 +16,11 @@
upgrade=1 from_commit=61398d8e49d4de8e7425c4ccd8098d5a4c55994b
backup_restore=1
multi_instance=1
+ port_already_use=0
change_url=1
+;;; Options
+Email=
+Notification=none
;;; Upgrade options
; commit=61398d8e49d4de8e7425c4ccd8098d5a4c55994b
name=Merge pull request #77 from YunoHost-Apps/testing
diff --git a/conf/nginx.conf b/conf/nginx.conf
index b102748..dfdd5b8 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -1,32 +1,34 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
- # Path to source
- alias __FINALPATH__/;
+ # Path to source
+ alias __FINALPATH__/;
- rewrite "^__PATH__/([a-zA-Z0-9-]+)$" "__PATH__/studs.php?poll=$1";
- rewrite "^__PATH__/([a-zA-Z0-9-]+)/action/([a-zA-Z_-]+)/(.+)$" "__PATH__/studs.php?poll=$1&$2=$3";
- rewrite "^__PATH__/([a-zA-Z0-9-]+)/vote/([a-zA-Z0-9]{16})$" "__PATH__/studs.php?poll=$1&vote=$2";
+ rewrite "^__PATH__/([a-zA-Z0-9-]+)$" "__PATH__/studs.php?poll=$1";
+ rewrite "^__PATH__/([a-zA-Z0-9-]+)/action/([a-zA-Z_-]+)/(.+)$" "__PATH__/studs.php?poll=$1&$2=$3";
+ rewrite "^__PATH__/([a-zA-Z0-9-]+)/vote/([a-zA-Z0-9]{16})$" "__PATH__/studs.php?poll=$1&vote=$2";
- # Admin requires the private poll ID, 24-char long
- rewrite "^__PATH__/([a-zA-Z0-9-]{24})/admin$" "__PATH__/adminstuds.php?poll=$1";
- rewrite "^__PATH__/([a-zA-Z0-9-]{24})/admin/vote/([a-zA-Z0-9]{16})$" "__PATH__/adminstuds.php?poll=$1&vote=$2";
- rewrite "^__PATH__/([a-zA-Z0-9-]{24})/admin/action/([a-zA-Z_-]+)(/(.+))?$" "__PATH__/adminstuds.php?poll=$1&$2=$4";
+ # Admin requires the private poll ID, 24-char long
+ rewrite "^__PATH__/([a-zA-Z0-9-]{24})/admin$" "__PATH__/adminstuds.php?poll=$1";
+ rewrite "^__PATH__/([a-zA-Z0-9-]{24})/admin/vote/([a-zA-Z0-9]{16})$" "__PATH__/adminstuds.php?poll=$1&vote=$2";
+ rewrite "^__PATH__/([a-zA-Z0-9-]{24})/admin/action/([a-zA-Z_-]+)(/(.+))?$" "__PATH__/adminstuds.php?poll=$1&$2=$4";
- index index.php;
- try_files $uri $uri/ /index.php;
- location ~ [^/]\.php(/|$) {
- fastcgi_split_path_info ^(.+?\.php)(/.*)$;
- fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
- include fastcgi_params;
- fastcgi_param REMOTE_USER $remote_user;
- fastcgi_param PATH_INFO $fastcgi_path_info;
- fastcgi_param SCRIPT_FILENAME $request_filename;
- fastcgi_param HTTPS on;
- }
+ index index.php;
- # Include SSOWAT user panel.
- include conf.d/yunohost_panel.conf.inc;
+ try_files $uri $uri/ /index.php;
+ location ~ [^/]\.php(/|$) {
+ fastcgi_split_path_info ^(.+?\.php)(/.*)$;
+ fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
+
+ include fastcgi_params;
+ fastcgi_param REMOTE_USER $remote_user;
+ fastcgi_param PATH_INFO $fastcgi_path_info;
+ fastcgi_param SCRIPT_FILENAME $request_filename;
+ fastcgi_param HTTPS on;
+ }
+
+ # Include SSOWAT user panel.
+ include conf.d/yunohost_panel.conf.inc;
}
location ~ ^__PATH__/(data|config|\.ht|db_structure\.xml|README) {
diff --git a/manifest.json b/manifest.json
index 90fdf69..6eaaeb7 100644
--- a/manifest.json
+++ b/manifest.json
@@ -7,7 +7,7 @@
"fr": "Service pour planifier un rendez-vous ou prendre une décision rapidement et facilement",
"de": "Service zur schnellen und einfachen Planung eines Termins oder zur Entscheidungsfindung"
},
- "version": "1.1.17~ynh1",
+ "version": "1.1.17~ynh2",
"url": "https://git.framasoft.org/framasoft/framadate",
"upstream": {
"license": "CECILL-B",
@@ -35,7 +35,7 @@
"mysql"
],
"arguments": {
- "install" : [
+ "install": [
{
"name": "domain",
"type": "domain"
@@ -47,8 +47,9 @@
"default": "/date"
},
{
- "name": "admin",
- "type": "user"
+ "name": "is_public",
+ "type": "boolean",
+ "default": true
},
{
"name": "language",
@@ -62,9 +63,8 @@
"default": "en"
},
{
- "name": "is_public",
- "type": "boolean",
- "default": true
+ "name": "admin",
+ "type": "user"
}
]
}
diff --git a/scripts/_common.sh b/scripts/_common.sh
index 6b3d3fe..be865a0 100644
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -14,9 +14,9 @@ pkg_dependencies="php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-intl php$
#=================================================
#=================================================
-# FUTURE OFFICIAL HELPERS
+# EXPERIMENTAL HELPERS
#=================================================
#=================================================
-# EXPERIMENTAL HELPERS
+# FUTURE OFFICIAL HELPERS
#=================================================
diff --git a/scripts/backup b/scripts/backup
index b8cb4b5..b93a5ca 100644
--- a/scripts/backup
+++ b/scripts/backup
@@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
+# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@@ -26,7 +27,7 @@ app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-phpversion=$(ynh_app_setting_get --app="$app" --key=phpversion)
+phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
@@ -54,6 +55,7 @@ ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
+ynh_print_info --message="Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
diff --git a/scripts/change_url b/scripts/change_url
index 1ddffb2..6ea44ae 100644
--- a/scripts/change_url
+++ b/scripts/change_url
@@ -8,7 +8,6 @@
source _common.sh
source /usr/share/yunohost/helpers
-ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
@@ -30,8 +29,27 @@ ynh_script_progression --message="Loading installation settings..."
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+# Add settings here as needed by your application
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
+#=================================================
+# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
+#=================================================
+ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
+
+# Backup the current version of the app
+ynh_backup_before_upgrade
+ynh_clean_setup () {
+ ynh_clean_check_starting
+ # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
+ ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
+
+ # Restore it if the upgrade fails
+ ynh_restore_upgradebackup
+}
+# Exit if an error occurs during the execution of the script
+ynh_abort_if_errors
+
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
@@ -57,19 +75,19 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
-# Change the path in the nginx config file
+# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
- # Make a backup of the original nginx config file if modified
+ # Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
- # Set global variables for nginx helper
+ # Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
- # Create a dedicated nginx config
+ # Create a dedicated NGINX config
ynh_add_nginx_config
fi
-# Change the domain for nginx
+# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
diff --git a/scripts/install b/scripts/install
index f14ca07..5a12244 100644
--- a/scripts/install
+++ b/scripts/install
@@ -21,15 +21,15 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
-admin=$YNH_APP_ARG_ADMIN
-language=$YNH_APP_ARG_LANGUAGE
is_public=$YNH_APP_ARG_IS_PUBLIC
-email=$(ynh_user_get_info --username=$admin --key=mail)
-timezone="$(cat /etc/timezone)"
-phpversion=$YNH_PHP_VERSION
+language=$YNH_APP_ARG_LANGUAGE
+admin=$YNH_APP_ARG_ADMIN
app=$YNH_APP_INSTANCE_NAME
+email=$(ynh_user_get_info --username=$admin --key=mail)
+timezone="$(cat /etc/timezone)"
+
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
@@ -48,10 +48,9 @@ ynh_script_progression --message="Storing installation settings..." --weight=2
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
-ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=language --value=$language
+ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=email --value=$email
-ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion
#=================================================
# INSTALL DEPENDENCIES
@@ -76,7 +75,7 @@ ynh_script_progression --message="Creating a MySQL database..." --weight=2
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
-ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name
+ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@@ -91,14 +90,6 @@ chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
-#=================================================
-# NGINX CONFIGURATION
-#=================================================
-ynh_script_progression --message="Configuring NGINX web server..." --weight=2
-
-# Create a dedicated nginx config
-ynh_add_nginx_config
-
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
@@ -106,13 +97,22 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
+phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
+
+#=================================================
+# NGINX CONFIGURATION
+#=================================================
+ynh_script_progression --message="Configuring NGINX web server..." --weight=2
+
+# Create a dedicated NGINX config
+ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
-# CREATE CONFIG.PHP
+# ADD A CONFIGURATION
#=================================================
-ynh_script_progression --message="Configuring $app..." --weight=2
+ynh_script_progression --message="Adding a configuration file..." --weight=2
ynh_add_config --template="../conf/config.php" --destination="$final_path/app/inc/config.php"
@@ -122,6 +122,7 @@ chown $app:$app "$final_path/app/inc/config.php"
#=================================================
# SETUP HOOKS FILE
#=================================================
+ynh_script_progression --message="Setuping hooks file..."
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_app_addaccess"
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_app_removeaccess"
@@ -148,14 +149,10 @@ ynh_install_composer
ynh_exec_warn_less php$phpversion "$final_path/admin/migration.php"
-#=================================================
-# GENERIC FINALIZATION
-#=================================================
-# SECURE FILES AND DIRECTORIES
-#=================================================
-
chown -R $app: "$final_path/"{tpl_c,admin/stdout.log}
+#=================================================
+# GENERIC FINALIZATION
#=================================================
# SETUP SSOWAT
#=================================================
@@ -164,6 +161,8 @@ ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary
if [ $is_public -eq 1 ]
then
+ # Everyone can access the app.
+ # The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi
diff --git a/scripts/remove b/scripts/remove
index c68f608..e8489de 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -18,28 +18,23 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
+db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+#=================================================
+# STANDARD REMOVE
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Removing the MySQL database..." --weight=5
# Remove a database if it exists, along with the associated user
-ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name
-
-#=================================================
-# REMOVE DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Removing dependencies..." --weight=1
-
-# Remove metapackage and its dependencies
-ynh_remove_app_dependencies
+ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
-ynh_script_progression --message="Removing $app main directory..." --weight=2
+ynh_script_progression --message="Removing app main directory..." --weight=2
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
@@ -49,7 +44,7 @@ ynh_secure_remove --file="$final_path"
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=3
-# Remove the dedicated nginx config
+# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
@@ -60,6 +55,14 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
+#=================================================
+# REMOVE DEPENDENCIES
+#=================================================
+ynh_script_progression --message="Removing dependencies..." --weight=1
+
+# Remove metapackage and its dependencies
+ynh_remove_app_dependencies
+
#=================================================
# GENERIC FINALIZATION
#=================================================
diff --git a/scripts/restore b/scripts/restore
index 262ba90..a13db74 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
+# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@@ -27,6 +28,7 @@ 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
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
timezone="$(cat /etc/timezone)"
@@ -35,17 +37,11 @@ timezone="$(cat /etc/timezone)"
#================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
-test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
+test ! -d $final_path \
+ || ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
-#=================================================
-# RESTORE THE NGINX CONFIGURATION
-#=================================================
-ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
-
-ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
-
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
@@ -65,20 +61,11 @@ chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
-#=================================================
-# RESTORE USER RIGHTS
-#=================================================
-
# Restore permissions on app files
chown -R $app: "$final_path/"{tpl_c,admin/stdout.log}
#=================================================
-# RESTORE THE PHP-FPM CONFIGURATION
-#=================================================
-ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=5
-
-ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
-
+# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
@@ -87,14 +74,28 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
+#=================================================
+# RESTORE THE PHP-FPM CONFIGURATION
+#=================================================
+ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=5
+
+ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
+
+#=================================================
+# RESTORE THE NGINX CONFIGURATION
+#=================================================
+ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
+
+ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
+
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=2
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
-ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd
-ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql
+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
#=================================================
# GENERIC FINALIZATION
diff --git a/scripts/upgrade b/scripts/upgrade
index dbfa210..387dd6c 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -18,9 +18,9 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
+language=$(ynh_app_setting_get --app=$app --key=language)
admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
-language=$(ynh_app_setting_get --app=$app --key=language)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
phpversion=$(ynh_app_setting_get --app="$app" --key=phpversion)
@@ -31,6 +31,7 @@ timezone="$(cat /etc/timezone)"
#=================================================
# CHECK VERSION
#=================================================
+ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
@@ -42,17 +43,31 @@ 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 () {
- # restore it if the upgrade fails
+ # Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
+#=================================================
+# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
+# Cleaning legacy permissions
+if ynh_legacy_permissions_exists; then
+ ynh_legacy_permissions_delete_all
+
+ ynh_app_setting_delete --app=$app --key=is_public
+fi
+
+if ! ynh_permission_exists --permission="admin"; then
+ # Create the required permissions
+ ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin
+fi
+
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app)
@@ -82,18 +97,6 @@ if [ -z "$path_url" ]; then
ynh_app_setting_delete --app=$app --key=path_url
fi
-# Cleaning legacy permissions
-if ynh_legacy_permissions_exists; then
- ynh_legacy_permissions_delete_all
-
- ynh_app_setting_delete --app=$app --key=is_public
-fi
-
-if ! ynh_permission_exists --permission="admin"; then
- # Create the required permissions
- ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin
-fi
-
#=================================================
# CREATE DEDICATED USER
#=================================================
@@ -102,8 +105,6 @@ ynh_script_progression --message="Making sure dedicated system user exists..." -
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
-#=================================================
-# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@@ -120,14 +121,6 @@ chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
-#=================================================
-# NGINX CONFIGURATION
-#=================================================
-ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
-
-# Create a dedicated nginx config
-ynh_add_nginx_config
-
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
@@ -142,18 +135,27 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=3
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
+phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
+
+#=================================================
+# NGINX CONFIGURATION
+#=================================================
+ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
+
+# Create a dedicated NGINX config
+ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
-# UPGRADE CONFIG.PHP
+# UPDATE A CONFIG FILE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
- ynh_script_progression --message="Reconfiguring $app..." --weight=2
+ ynh_script_progression --message="Updating a configuration file..." --weight=2
- ynh_add_config --template="../conf/config.php" --destination="$final_path/app/inc/config.php"
+ ynh_add_config --template="../conf/config.php" --destination="$final_path/app/inc/config.php"
chmod 400 "$final_path/app/inc/config.php"
chown $app:$app "$final_path/app/inc/config.php"
fi
@@ -191,14 +193,10 @@ then
ynh_exec_warn_less php$phpversion "$final_path/admin/migration.php"
fi
-#=================================================
-# GENERIC FINALIZATION
-#=================================================
-# SECURE FILES AND DIRECTORIES
-#=================================================
-
chown -R $app: "$final_path/"{tpl_c,admin/stdout.log}
+#=================================================
+# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================