diff --git a/README.md b/README.md
index a325511..2e87dd7 100644
--- a/README.md
+++ b/README.md
@@ -1,26 +1,24 @@
# Tyto for YunoHost 
-[](https://dash.yunohost.org/appci/app/tyto)  
+[](https://dash.yunohost.org/appci/app/tyto)  
+[](https://install-app.yunohost.org/?app=tyto)
-[](https://install-app.yunohost.org/?app=tyto)
-=======
-
-**Shipped Version:3.0.4**
-
-- [Yunohost project](https://yunohost.org)
-- [Tyto source code at Github](https://github.com/jh3y/tyto)
-- [Demo](https://jh3y.github.io/tyto)
-
-### Why tyto? What's it for?
+> *This package allows you to install Tyto quickly and simply on a YunoHost server.
+If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
+## Overview
Tyto arose from the want for an electronic post-it board without the need for accounts. Something simple and intuitive that could be easily shared.
-
+**Shipped version:** 3.0.4
-### Who's it for?
-Developer and project managers were the original target audience. A means to share project progression on a more _personal_ level. As opposed to publicly through an internal system. Almost like a complimentary attachment to an email.
+## Screenshots
+
+
+
+## Demo
+
+* [Official demo](https://jh3y.github.io/tyto)
-Want to move to a different browser or machine though? Use the export utility to export a json file. Load this using the import utility.
### Features
* minimal UI
@@ -34,11 +32,29 @@ Want to move to a different browser or machine though? Use the export utility to
* Markdown support
* etc.
-### To-do
-- [x] Install
-- [x] Remove
-- [X] Upgrade
-- [X] Backup
-- [X] Restore
-- [X] Multi-instance
-- [X] Change-url
+## YunoHost specific features
+
+#### Supported architectures
+
+* x86-64 - [](https://ci-apps.yunohost.org/ci/apps/tyto/)
+* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/tyto/)
+
+## Links
+
+ * Report a bug: https://github.com/YunoHost-Apps/tyto_ynh/issues
+ * Upstream app repository: https://github.com/jh3y/tyto
+ * YunoHost website: https://yunohost.org/
+
+---
+
+Developer info
+----------------
+
+Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/tyto_ynh/tree/testing).
+
+To try the testing branch, please proceed like that.
+```
+sudo yunohost app install https://github.com/YunoHost-Apps/tyto_ynh/tree/testing --debug
+or
+sudo yunohost app upgrade tyto -u https://github.com/YunoHost-Apps/tyto_ynh/tree/testing --debug
+```
diff --git a/check_process b/check_process
index eeb8196..0b36e02 100644
--- a/check_process
+++ b/check_process
@@ -18,22 +18,13 @@
upgrade=1
backup_restore=1
multi_instance=1
- incorrect_path=1
+ # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
+ # incorrect_path=1
port_already_use=0
change_url=1
;;; Levels
- Level 1=auto
- Level 2=auto
- Level 3=auto
-# Level 4:
- Level 4=0
-# Level 5:
+ # If the level 5 (Package linter) is forced to 1. Please add justifications here.
Level 5=auto
- Level 6=auto
- Level 7=auto
- Level 8=0
- Level 9=0
- Level 10=0
;;; Options
Email=anmol@datamol.org
Notification=change
diff --git a/conf/nginx.conf b/conf/nginx.conf
index 3454094..d49da22 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -1,13 +1,14 @@
-location __PATH__ {
+#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
+location __PATH__/ {
# Path to source
alias __FINALPATH__/ ;
+ # Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
- # Example PHP configuration (remove if not used)
index index.php index.html;
# Common parameter to increase upload size limit in conjuction with dedicated php-fpm file
diff --git a/issue_template.md b/issue_template.md
new file mode 100644
index 0000000..56d382c
--- /dev/null
+++ b/issue_template.md
@@ -0,0 +1,46 @@
+---
+name: Bug report
+about: Create a report to help us debug, it would be nice to fill the template as much as you can to help us, help you and help us all.
+
+---
+
+**How to post a meaningful bug report**
+1. *Read this whole template first.*
+2. *Determine if you are on the right place:*
+ - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!*
+ - *Otherwise, the issue may be due to Tyto itself. Refer to its documentation or repository for help.*
+ - *If you have a doubt, post here, we will figure it out together.*
+3. *Delete the italic comments as you write over them below, and remove this guide.*
+---
+
+**Describe the bug**
+*A clear and concise description of what the bug is.*
+
+**Versions**
+- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
+- YunoHost version: x.x.x
+- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
+- Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?: *no / yes*
+ - If yes, please explain:
+- Using, or trying to install package version/branch:
+- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
+
+**To Reproduce**
+*Steps to reproduce the behavior.*
+- *If you performed a command from the CLI, the command itself is enough. For example:*
+ ```sh
+ sudo yunohost app install tyto
+ ```
+- *If you used the webadmin, please perform the equivalent command from the CLI first.*
+- *If the error occurs in your browser, explain what you did:*
+ 1. *Go to '...'*
+ 2. *Click on '....'*
+ 3. *Scroll down to '....'*
+ 4. *See error*
+
+**Expected behavior**
+*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
+
+**Logs**
+*After a failed command, YunoHost makes the log available to you, but also to others, thanks to `yunohost log display [log name] --share`. The actual command, with the correct log name, is displayed at the end of the failed attempt in the CLI. Execute it and copy here the share link it outputs.*
+*If applicable and useful, add screenshots to help explain your problem.*
diff --git a/manifest.json b/manifest.json
index 599a14c..c0379be 100644
--- a/manifest.json
+++ b/manifest.json
@@ -6,7 +6,7 @@
"en": "A simple, minimal electronic post-it board",
"fr": "Un tableau de post-it électroniques, simple et minimaliste"
},
- "version": "3.0.4",
+ "version": "3.0.4~ynh1",
"url": "https://github.com/jh3y/tyto",
"license": "MIT",
"maintainer": {
@@ -15,7 +15,7 @@
"url": "https://datamol.org"
},
"requirements": {
- "yunohost": ">= 2.7.2"
+ "yunohost": ">= 3.5"
},
"multi_instance": true,
"services": [
diff --git a/pull_request_template.md b/pull_request_template.md
new file mode 100644
index 0000000..4139384
--- /dev/null
+++ b/pull_request_template.md
@@ -0,0 +1,18 @@
+## Problem
+- *Description of why you made this PR*
+
+## Solution
+- *And how do you fix that problem*
+
+## PR Status
+- [ ] Code finished.
+- [ ] Tested with Package_check.
+- [ ] Fix or enhancement tested.
+- [ ] Upgrade from last version tested.
+- [ ] Can be reviewed and tested.
+
+## Package_check results
+---
+*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results*
+
+[/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/tyto_ynh%20PR-NUM-%20(USERNAME)/)
diff --git a/scripts/_common.sh b/scripts/_common.sh
index bb04a03..ecd263f 100644
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -1,13 +1,20 @@
#!/bin/bash
-# ============= FUTURE YUNOHOST HELPER =============
-# Delete a file checksum from the app settings
-#
-# $app should be defined when calling this helper
-#
-# usage: ynh_remove_file_checksum file
-# | arg: file - The file for which the checksum will be deleted
-ynh_delete_file_checksum () {
- local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
- ynh_app_setting_delete $app $checksum_setting_name
-}
\ No newline at end of file
+#=================================================
+# COMMON VARIABLES
+#=================================================
+
+# dependencies used by the app
+pkg_dependencies=""
+
+#=================================================
+# PERSONAL HELPERS
+#=================================================
+
+#=================================================
+# EXPERIMENTAL HELPERS
+#=================================================
+
+#=================================================
+# FUTURE OFFICIAL HELPERS
+#=================================================
diff --git a/scripts/backup b/scripts/backup
index d2c7b04..c3096ff 100755
--- a/scripts/backup
+++ b/scripts/backup
@@ -6,12 +6,8 @@
# 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
+#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
#=================================================
@@ -24,23 +20,33 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
+ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
-final_path=$(ynh_app_setting_get $app final_path)
-domain=$(ynh_app_setting_get $app domain)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+domain=$(ynh_app_setting_get --app=$app --key=domain)
#=================================================
-# STANDARD BACKUP STEPS
+# DECLARE DATA AND CONF FILES TO BACKUP
+#=================================================
+ynh_print_info --message="Declaring files to be backed up..."
+
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
-ynh_backup "$final_path"
+ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
-ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
+ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
diff --git a/scripts/change_url b/scripts/change_url
index d8b7b93..fdf22bd 100644
--- a/scripts/change_url
+++ b/scripts/change_url
@@ -22,13 +22,34 @@ new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#=================================================
-# CHECK THE SYNTAX OF THE PATHS
+# LOAD SETTINGS
#=================================================
+ynh_script_progression --message="Loading installation settings..."
-test -n "$old_path" || old_path="/"
-test -n "$new_path" || new_path="/"
-new_path=$(ynh_normalize_url_path $new_path)
-old_path=$(ynh_normalize_url_path $old_path)
+# 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
+#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
+#db_user=$db_name
+#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
+
+#=================================================
+# BACKUP BEFORE UPGRADE 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 () {
+ # 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
@@ -51,31 +72,41 @@ fi
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
+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
if [ $change_path -eq 1 ]
then
- # Make a backup of the original nginx config file if modified
- ynh_backup_if_checksum_is_different "$nginx_conf_path"
- # Replace locations starting with old_path
- # Look for every location possible patterns (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location)
- ynh_replace_string "location\( \(=\|~\|~\*\|\^~\)\)\? $old_path" "location\1 $new_path" "$nginx_conf_path"
- # Replace path in "return" directives
- ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path"
- # Calculate and store the nginx config file checksum
- ynh_store_file_checksum "$nginx_conf_path"
+ # 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
+ domain="$old_domain"
+ path_url="$new_path"
+ # Create a dedicated nginx config
+ ynh_add_nginx_config
fi
# Change the domain for nginx
if [ $change_domain -eq 1 ]
then
- # Delete file checksum for the old conf file location
- ynh_delete_file_checksum "$nginx_conf_path"
+ # Delete file checksum for the old conf file location
+ ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
- # Store file checksum for the new config file location
- ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
+ # Store file checksum for the new config file location
+ ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
-systemctl reload nginx
+#=================================================
+# RELOAD NGINX
+#=================================================
+ynh_script_progression --message="Reloading nginx web server..."
+
+ynh_systemd_action --service_name=nginx --action=reload
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Change of URL completed for $app"
diff --git a/scripts/install b/scripts/install
index 2e91dc6..2461006 100755
--- a/scripts/install
+++ b/scripts/install
@@ -24,52 +24,43 @@ domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
-# This is a multi-instance app, meaning it can be installed several times independently
-# The id of the app as stated in the manifest is available as $YNH_APP_ID
-# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
-# The app instance name is available as $YNH_APP_INSTANCE_NAME
-# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
-# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
-# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
-# The app instance name is probably what you are interested the most, since this is
-# guaranteed to be unique. This is a good unique identifier to define installation path,
-# db names, ...
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
+ynh_script_progression --message="Validating installation parameters..."
final_path=/var/www/$app
-test ! -e "$final_path" || ynh_die "This path already contains a folder"
+test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
-# Normalize the url path syntax
-path_url=$(ynh_normalize_url_path $path_url)
-
-# Check web path availability
-ynh_webpath_available $domain $path_url
# Register (book) web path
-ynh_webpath_register $app $domain $path_url
+ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
+ynh_script_progression --message="Storing installation settings..."
-ynh_app_setting_set $app domain $domain
-ynh_app_setting_set $app path $path_url
-ynh_app_setting_set $app is_public $is_public
+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=is_public --value=$is_public
+#=================================================
+# STANDARD MODIFICATIONS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
+ynh_script_progression --message="Setting up source files..."
-ynh_app_setting_set $app final_path $final_path
+ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
-ynh_setup_source "$final_path"
+ynh_setup_source --dest_dir="$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
+ynh_script_progression --message="Configuring nginx web server..."
# Create a dedicated nginx config
ynh_add_nginx_config
@@ -77,21 +68,25 @@ ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
+ynh_script_progression --message="Configuring system user..."
# Create a system user
-ynh_system_user_create $app
-
+ynh_system_user_create --username=$app
#=================================================
-# SETUP APPLICATION WITH CURL
+# GENERIC FINALIZATION
#=================================================
+# SECURE FILES AND DIRECTORIES
+#=================================================
+ynh_script_progression --message="Securing files and directories..."
-# Set right permissions for curl install
+# Set permissions to app files
chown -R $app: $final_path
#=================================================
# SETUP SSOWAT
#=================================================
+ynh_script_progression --message="Configuring SSOwat..."
if [ $is_public -eq 0 ]
then # Remove the public access
@@ -101,11 +96,18 @@ fi
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway.
- ynh_app_setting_set $app unprotected_uris "/"
+ ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
fi
#=================================================
# RELOAD NGINX
#=================================================
+ynh_script_progression --message="Reloading nginx web server..."
-systemctl reload nginx
+ynh_systemd_action --service_name=nginx --action=reload
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Installation of $app completed"
diff --git a/scripts/remove b/scripts/remove
index e78e30b..7c04ac9 100755
--- a/scripts/remove
+++ b/scripts/remove
@@ -12,24 +12,27 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
+ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
-domain=$(ynh_app_setting_get $app domain)
-final_path=$(ynh_app_setting_get $app final_path)
+domain=$(ynh_app_setting_get --app=$app --key=domain)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE APP MAIN DIR
#=================================================
+ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely
-ynh_secure_remove "$final_path"
+ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
+ynh_script_progression --message="Removing nginx web server configuration..."
# Remove the dedicated nginx config
ynh_remove_nginx_config
@@ -39,6 +42,13 @@ ynh_remove_nginx_config
#=================================================
# REMOVE DEDICATED USER
#=================================================
+ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user
-ynh_system_user_delete $app
+ynh_system_user_delete --username=$app
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Removal of $app completed"
diff --git a/scripts/restore b/scripts/restore
index 7d1ef97..7d286a9 100755
--- a/scripts/restore
+++ b/scripts/restore
@@ -6,12 +6,8 @@
# 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
+#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
#=================================================
@@ -24,55 +20,67 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
+ynh_script_progression --message="Loading settings..."
app=$YNH_APP_INSTANCE_NAME
-domain=$(ynh_app_setting_get $app domain)
-path_url=$(ynh_app_setting_get $app path)
-final_path=$(ynh_app_setting_get $app final_path)
+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)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
+ynh_script_progression --message="Validating restoration parameters..."
-ynh_webpath_available $domain $path_url \
- || ynh_die "Path not available: ${domain}${path_url}"
+ynh_webpath_available --domain=$domain --path_url=$path_url \
+ || ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d $final_path \
- || ynh_die "There is already a directory: $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..."
-ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
+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..."
-ynh_restore_file "$final_path"
-
+ynh_restore_file --origin_path="$final_path"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
+ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
-ynh_system_user_create $app
+ynh_system_user_create --username=$app
#=================================================
# RESTORE USER RIGHTS
#=================================================
+ynh_script_progression --message="Restoring user rights..."
# Restore permissions on app files
-chown -R $app: $final_path
+chown -R root: $final_path
#=================================================
# GENERIC FINALIZATION
#=================================================
-# RELOAD NGINX AND PHP-FPM
+# RELOAD NGINX
+#=================================================
+ynh_script_progression --message="Reloading nginx web server..."
+
+ynh_systemd_action --service_name=nginx --action=reload
+
+#=================================================
+# END OF SCRIPT
#=================================================
-systemctl reload nginx
+ynh_script_progression --message="Restoration completed for $app"
diff --git a/scripts/upgrade b/scripts/upgrade
index 8ffa310..9f98635 100755
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -12,36 +12,46 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
+ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
-domain=$(ynh_app_setting_get $app domain)
-path_url=$(ynh_app_setting_get $app path)
-is_public=$(ynh_app_setting_get $app is_public)
-final_path=$(ynh_app_setting_get $app final_path)
+domain=$(ynh_app_setting_get --app=$app --key=domain)
+path_url=$(ynh_app_setting_get --app=$app --key=path)
+is_public=$(ynh_app_setting_get --app=$app --key=is_public)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+
+#=================================================
+# CHECK VERSION
+#=================================================
+ynh_script_progression --message="Checking version..."
+
+upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
+ynh_script_progression --message="Ensuring downward compatibility..."
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
- ynh_app_setting_set $app is_public 1
+ ynh_app_setting_set --app=$app --key=is_public --value=1
is_public=1
elif [ "$is_public" = "No" ]; then
- ynh_app_setting_set $app is_public 0
+ ynh_app_setting_set --app=$app --key=is_public --value=0
is_public=0
fi
# If final_path doesn't exist, create it
-if [ -z $final_path ]; then
+if [ -z "$final_path" ]; then
final_path=/var/www/$app
- ynh_app_setting_set $app final_path $final_path
+ 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)..."
# Backup the current version of the app
ynh_backup_before_upgrade
@@ -57,7 +67,7 @@ ynh_abort_if_errors
#=================================================
# Normalize the URL path syntax
-path_url=$(ynh_normalize_url_path $path_url)
+path_url=$(ynh_normalize_url_path --path_url=$path_url)
#=================================================
# STANDARD UPGRADE STEPS
@@ -65,12 +75,18 @@ path_url=$(ynh_normalize_url_path $path_url)
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
-# Download, check integrity, uncompress and patch the source from app.src
-ynh_setup_source "$final_path"
+if [ "$upgrade_type" == "UPGRADE_APP" ]
+then
+ ynh_script_progression --message="Upgrading source files..."
+
+ # Download, check integrity, uncompress and patch the source from app.src
+ ynh_setup_source --dest_dir="$final_path"
+fi
#=================================================
# NGINX CONFIGURATION
#=================================================
+ynh_script_progression --message="Upgrading nginx web server configuration..."
# Create a dedicated nginx config
ynh_add_nginx_config
@@ -78,15 +94,17 @@ ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
+ynh_script_progression --message="Making sure dedicated system user exists..."
-# Create a system user
-ynh_system_user_create $app
+# Create a dedicated user (if not existing)
+ynh_system_user_create --username=$app
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
+ynh_script_progression --message="Securing files and directories..."
# Set right permissions for curl installation
chown -R $app: $final_path
@@ -94,6 +112,7 @@ chown -R $app: $final_path
#=================================================
# SETUP SSOWAT
#=================================================
+ynh_script_progression --message="Upgrading SSOwat configuration..."
if [ $is_public -eq 0 ]
then # Remove the public access
@@ -109,5 +128,12 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
+ynh_script_progression --message="Reloading nginx web server..."
-systemctl reload nginx
+ynh_systemd_action --service_name=nginx --action=reload
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Upgrade of $app completed"