diff --git a/README.md b/README.md index ae5b2ee..e4d1e9b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ It shall NOT be edited by hand. # Lstu for YunoHost -[![Integration level](https://dash.yunohost.org/integration/lstu.svg)](https://dash.yunohost.org/appci/app/lstu) ![Working status](https://ci-apps.yunohost.org/ci/badges/lstu.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/lstu.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/lstu.svg)](https://dash.yunohost.org/appci/app/lstu) ![Working status](https://ci-apps.yunohost.org/ci/badges/lstu.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/lstu.maintain.svg) + [![Install Lstu with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=lstu) *[Lire ce readme en français.](./README_fr.md)* @@ -18,7 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Lstu means Let's Shorten That URL. -**Shipped version:** 0.26.0~ynh2 +**Shipped version:** 0.26.0~ynh3 **Demo:** https://lstu.fr @@ -26,12 +27,6 @@ Lstu means Let's Shorten That URL. ![Screenshot of Lstu](./doc/screenshots/LSTU_screenshot.png) -## Disclaimers / important information - -## Configuration - -How to configure this app: a plain file at `/var/www/lstu/lstu.conf` with SSH. - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index 4c5d4ba..152939f 100644 --- a/README_fr.md +++ b/README_fr.md @@ -5,38 +5,33 @@ It shall NOT be edited by hand. # Lstu pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/lstu.svg)](https://dash.yunohost.org/appci/app/lstu) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/lstu.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/lstu.maintain.svg) +[![Niveau d’intégration](https://dash.yunohost.org/integration/lstu.svg)](https://dash.yunohost.org/appci/app/lstu) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/lstu.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/lstu.maintain.svg) + [![Installer Lstu avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=lstu) *[Read this readme in english.](./README.md)* -> *Ce package vous permet d'installer Lstu rapidement et simplement sur un serveur YunoHost. -Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* +> *Ce package vous permet d’installer Lstu rapidement et simplement sur un serveur YunoHost. +Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l’installer et en profiter.* -## Vue d'ensemble +## Vue d’ensemble Raccourcisseur d'URL -**Version incluse :** 0.26.0~ynh2 +**Version incluse :** 0.26.0~ynh3 **Démo :** https://lstu.fr -## Captures d'écran +## Captures d’écran -![Capture d'écran de Lstu](./doc/screenshots/LSTU_screenshot.png) - -## Avertissements / informations importantes - -## Configuration - -Comment configurer cette application : un fichier simple à `/var/www/lstu/lstu.conf` avec SSH. +![Capture d’écran de Lstu](./doc/screenshots/LSTU_screenshot.png) ## Documentations et ressources -* Site officiel de l'app : -* Documentation officielle de l'admin : -* Dépôt de code officiel de l'app : +* 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 : @@ -52,4 +47,4 @@ ou sudo yunohost app upgrade lstu -u https://github.com/YunoHost-Apps/lstu_ynh/tree/testing --debug ``` -**Plus d'infos sur le packaging d'applications :** +**Plus d’infos sur le packaging d’applications :** \ No newline at end of file diff --git a/actions.json b/actions.json deleted file mode 100644 index 34dfc3f..0000000 --- a/actions.json +++ /dev/null @@ -1,77 +0,0 @@ -[ - { - "id": "public_private", - "name": "Move to public or private", - "command": "/bin/bash scripts/actions/public_private", - "user": "root", - "accepted_return_codes": [ - 0 - ], - "description": { - "en": "Change the public access of the app.", - "fr": "Modifiez l'accès public de l'application." - }, - "arguments": [ - { - "name": "is_public", - "type": "boolean", - "ask": { - "en": "Is it a public app?", - "fr": "Est-ce une application publique ?" - }, - "default": true - } - ] - }, - { - "id": "change_password", - "name": "Change the admin password", - "command": "/bin/bash scripts/actions/change_password", - "user": "root", - "accepted_return_codes": [ - 0 - ], - "description": { - "en": "Change the admin password of the app.", - "fr": "Change le mot de passe administrateur de l'app." - }, - "arguments": [ - { - "name": "password", - "type": "password", - "ask": { - "en": "New password", - "fr": "Nouveau mot de passe" - } - } - ] - }, - { - "id": "change_theme", - "name": "Change the theme", - "command": "/bin/bash scripts/actions/change_theme", - "user": "root", - "accepted_return_codes": [ - 0 - ], - "description": { - "en": "Change the theme of the app.", - "fr": "Change le thème de l'app." - }, - "arguments": [ - { - "name": "theme", - "type": "string", - "ask": { - "en": "Choose a theme", - "fr": "Choisissez un theme" - }, - "choices": [ - "default", - "milligram" - ], - "default": "milligram" - } - ] - } -] \ No newline at end of file diff --git a/check_process b/check_process deleted file mode 100644 index 792949a..0000000 --- a/check_process +++ /dev/null @@ -1,27 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/path" - is_public=1 - theme="milligram" - password="1Strong-Password" - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - #Merge pull request #52 - upgrade=1 from_commit=469fb267ebc496d2c63b10de35aaf3493ce8124f - backup_restore=1 - multi_instance=1 - port_already_use=0 - change_url=1 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=469fb267ebc496d2c63b10de35aaf3493ce8124f - name=Merge pull request #52 diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index 67c9576..0000000 --- a/conf/app.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://framagit.org/fiat-tux/hat-softwares/lstu/-/archive/0.26-0/lstu-0.26-0.tar.gz -SOURCE_SUM=323c81b4cb04a97eda7cb37b2a63d16e808591fd46eb4326f6619200ce742960 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/logrotate b/conf/logrotate index d116834..d33a185 100644 --- a/conf/logrotate +++ b/conf/logrotate @@ -1,5 +1,5 @@ -__FINALPATH__/log/production.log { +__INSTALL_DIR__/log/production.log { # Effectue une rotation des logs tout les mois monthly # Ou si le fichier de log dépasse 100Mo diff --git a/conf/lstu-minion@.service b/conf/lstu-minion@.service index 20ac888..45a0324 100644 --- a/conf/lstu-minion@.service +++ b/conf/lstu-minion@.service @@ -7,7 +7,7 @@ Type=forking User=__APP__ Restart=always RestartSec=10 -WorkingDirectory=__FINALPATH__ +WorkingDirectory=__INSTALL_DIR__ ExecStart=/usr/bin/carton exec script/application minion worker [Install] diff --git a/conf/systemd.service b/conf/systemd.service index 8c88509..ac2989f 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -10,8 +10,8 @@ User=__APP__ Group=__APP__ Restart=always RestartSec=10 -WorkingDirectory=__FINALPATH__ -PIDFile=__FINALPATH__/script/hypnotoad.pid +WorkingDirectory=__INSTALL_DIR__ +PIDFile=__INSTALL_DIR__/script/hypnotoad.pid ExecStart=/usr/bin/carton exec hypnotoad script/lstu ExecStop=/usr/bin/carton exec hypnotoad -s script/lstu ExecReload=/usr/bin/carton exec hypnotoad script/lstu diff --git a/doc/ADMIN.md b/doc/ADMIN.md new file mode 100644 index 0000000..b7e1a48 --- /dev/null +++ b/doc/ADMIN.md @@ -0,0 +1 @@ +How to configure this app: a plain file at `__INSTALL_DIR__/lstu.conf` with SSH. diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md new file mode 100644 index 0000000..8093d80 --- /dev/null +++ b/doc/ADMIN_fr.md @@ -0,0 +1 @@ +Comment configurer cette application : un fichier simple à `__INSTALL_DIR__/lstu.conf` avec SSH. diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index 2d34b90..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1,3 +0,0 @@ -## Configuration - -How to configure this app: a plain file at `/var/www/lstu/lstu.conf` with SSH. diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md deleted file mode 100644 index 9c5d939..0000000 --- a/doc/DISCLAIMER_fr.md +++ /dev/null @@ -1,3 +0,0 @@ -## Configuration - -Comment configurer cette application : un fichier simple à `/var/www/lstu/lstu.conf` avec SSH. diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 4e620a7..0000000 --- a/manifest.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "Lstu", - "id": "lstu", - "packaging_format": 1, - "description": { - "en": "URL Shortener", - "fr": "Raccourcisseur d'URL" - }, - "version": "0.26.0~ynh2", - "url": "https://lstu.fr", - "upstream": { - "license": "WTFPL", - "website": "https://lstu.fr", - "demo": "https://lstu.fr", - "admindoc": "https://framagit.org/fiat-tux/hat-softwares/lstu/wikis/home", - "code": "https://framagit.org/fiat-tux/hat-softwares/lstu" - }, - "license": "WTFPL", - "maintainer": { - "name": "frju365", - "email": "abld@abld.info" - }, - "requirements": { - "yunohost": ">= 4.3.0" - }, - "multi_instance": true, - "services": [ - "nginx" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/lstu", - "default": "/lstu" - }, - { - "name": "is_public", - "type": "boolean", - "default": false - }, - { - "name": "theme", - "type": "string", - "ask": { - "en": "Choose a theme", - "fr": "Choisissez un theme" - }, - "choices": ["default", "milligram"], - "default": "milligram" - }, - { - "name": "password", - "type": "password" - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..98471d5 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,69 @@ +packaging_format = 2 + +id = "lstu" +name = "Lstu" +description.en = "URL Shortener" +description.fr = "Raccourcisseur d'URL" + +version = "0.26.0~ynh3" + +maintainers = ["frju365"] + +[upstream] +license = "WTFPL" +website = "https://lstu.fr" +demo = "https://lstu.fr" +admindoc = "https://framagit.org/fiat-tux/hat-softwares/lstu/wikis/home" +code = "https://framagit.org/fiat-tux/hat-softwares/lstu" + +[integration] +yunohost = ">= 11.1.20" +architectures = "all" +multi_instance = true +ldap = true +sso = true +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" + +[install] + [install.domain] + type = "domain" + + [install.path] + type = "path" + default = "/lstu" + + [install.init_main_permission] + type = "group" + default = false + + [install.theme] + ask.en = "Choose a theme" + ask.fr = "Choisissez un theme" + type = "string" + choices = ["default", "milligram"] + default = "milligram" + + [install.password] + type = "password" + +[resources] + [resources.sources.main] + url = "https://framagit.org/fiat-tux/hat-softwares/lstu/-/archive/0.26-0/lstu-0.26-0.tar.gz" + sha256 = "323c81b4cb04a97eda7cb37b2a63d16e808591fd46eb4326f6619200ce742960" + + [resources.ports] + + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" + + [resources.apt] + packages = "build-essential libssl-dev zlib1g-dev libpng-dev libpq-dev memcached postgresql carton libpod-parser-perl" + + [resources.database] + type = "postgresql" diff --git a/scripts/_common.sh b/scripts/_common.sh index 330f35d..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -pkg_dependencies="build-essential libssl-dev zlib1g-dev libpng-dev libpq-dev memcached postgresql carton libpod-parser-perl" - #================================================= # PERSONAL HELPERS #================================================= @@ -15,141 +12,6 @@ pkg_dependencies="build-essential libssl-dev zlib1g-dev libpng-dev libpq-dev mem # EXPERIMENTAL HELPERS #================================================= -# Send an email to inform the administrator -# -# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type] -# | arg: -m --app_message= - The file with the content to send to the administrator. -# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root -# example: "root admin@domain" -# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you -# example: "root admin@domain user1 user2" -# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade' -ynh_send_readme_to_admin() { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= ) - local app_message - local recipients - local type - # Manage arguments with getopts - - ynh_handle_getopts_args "$@" - app_message="${app_message:-}" - recipients="${recipients:-root}" - type="${type:-install}" - - # Get the value of admin_mail_html - admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) - admin_mail_html="${admin_mail_html:-0}" - - # Retrieve the email of users - find_mails () { - local list_mails="$1" - local mail - local recipients=" " - # Read each mail in argument - for mail in $list_mails - do - # Keep root or a real email address as it is - if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" - then - recipients="$recipients $mail" - else - # But replace an user name without a domain after by its email - if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) - then - recipients="$recipients $mail" - fi - fi - done - echo "$recipients" - } - recipients=$(find_mails "$recipients") - - # Subject base - local mail_subject="☁️🆈🅽🅷☁️: \`$app\`" - - # Adapt the subject according to the type of mail required. - if [ "$type" = "backup" ]; then - mail_subject="$mail_subject has just been backup." - elif [ "$type" = "change_url" ]; then - mail_subject="$mail_subject has just been moved to a new URL!" - elif [ "$type" = "remove" ]; then - mail_subject="$mail_subject has just been removed!" - elif [ "$type" = "restore" ]; then - mail_subject="$mail_subject has just been restored!" - elif [ "$type" = "upgrade" ]; then - mail_subject="$mail_subject has just been upgraded!" - else # install - mail_subject="$mail_subject has just been installed!" - fi - - local mail_message="This is an automated message from your beloved YunoHost server. -Specific information for the application $app. -$(if [ -n "$app_message" ] -then - cat "$app_message" -else - echo "...No specific information..." -fi) ---- -Automatic diagnosis data from YunoHost -__PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')__PRE_TAG2__" - - # Store the message into a file for further modifications. - echo "$mail_message" > mail_to_send - - # If a html email is required. Apply html tags to the message. - if [ "$admin_mail_html" -eq 1 ] - then - # Insert 'br' tags at each ending of lines. - ynh_replace_string "$" "
" mail_to_send - - # Insert starting HTML tags - sed --in-place '1s@^@\n\n\n\n@' mail_to_send - - # Keep tabulations - ynh_replace_string " " "\ \ " mail_to_send - ynh_replace_string "\t" "\ \ " mail_to_send - - # Insert url links tags - ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "\1" mail_to_send - - # Insert pre tags - ynh_replace_string "__PRE_TAG1__" "
" mail_to_send
-		ynh_replace_string "__PRE_TAG2__" "<\pre>" mail_to_send
-
-		# Insert finishing HTML tags
-		echo -e "\n\n" >> mail_to_send
-
-	# Otherwise, remove tags to keep a plain text.
-	else
-		# Remove URL tags
-		ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send
-		ynh_replace_string "__URL_TAG2__" ": " mail_to_send
-
-		# Remove PRE tags
-		ynh_replace_string "__PRE_TAG[1-2]__" "" mail_to_send
-	fi
-
-	# Define binary to use for mail command
-	if [ -e /usr/bin/bsd-mailx ]
-	then
-		local mail_bin=/usr/bin/bsd-mailx
-	else
-		local mail_bin=/usr/bin/mail.mailutils
-	fi
-
-	if [ "$admin_mail_html" -eq 1 ]
-	then
-		content_type="text/html"
-	else
-		content_type="text/plain"
-	fi
-
-	# Send the email to the recipients
-	cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients"
-}
-
 #=================================================
 # FUTURE OFFICIAL HELPERS
 #=================================================
diff --git a/scripts/actions/change_password b/scripts/actions/change_password
deleted file mode 100755
index dbd4551..0000000
--- a/scripts/actions/change_password
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-
-#=================================================
-# GENERIC STARTING
-#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-
-source scripts/_common.sh
-source /usr/share/yunohost/helpers
-
-#=================================================
-# RETRIEVE ARGUMENTS
-#=================================================
-
-# Get is_public
-password=${YNH_ACTION_PASSWORD}
-hashed_password=$(echo -n $password | sha256sum | cut -d' ' -f1)
-
-app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
-
-final_path=$(ynh_app_setting_get $app final_path)
-
-#=================================================
-# CHECK IF AN ACTION HAS TO BE DONE
-#=================================================
-
-hashed_password_old=$(ynh_app_setting_get $app hashed_password)
-
-if [ "$hashed_password" == "$hashed_password_old" ]
-then
-	ynh_die --message="Same password." --ret_code=0
-fi
-
-#=================================================
-# SPECIFIC ACTION
-#=================================================
-# MOVE TO PUBLIC OR PRIVATE
-#=================================================
-
-ynh_backup_if_checksum_is_different "$final_path/lstu.conf"
-ynh_replace_string "$hashed_password_old" "$hashed_password" "${final_path}/lstu.conf"
-ynh_store_file_checksum "${final_path}/lstu.conf"
-
-# Update the config of the app
-ynh_app_setting_set $app hashed_password $hashed_password
-
-#=================================================
-# RELOAD NGINX
-#=================================================
-
-ynh_systemd_action --service_name=$app --action="reload" --log_path="systemd" --line_match="Server available at"
-
-#=================================================
-# END OF SCRIPT
-#=================================================
diff --git a/scripts/actions/change_theme b/scripts/actions/change_theme
deleted file mode 100755
index 6c72973..0000000
--- a/scripts/actions/change_theme
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/bash
-
-#=================================================
-# GENERIC STARTING
-#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-
-source scripts/_common.sh
-source /usr/share/yunohost/helpers
-
-#=================================================
-# RETRIEVE ARGUMENTS
-#=================================================
-
-# Get is_public
-theme=${YNH_ACTION_THEME}
-
-app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
-
-final_path=$(ynh_app_setting_get $app final_path)
-
-#=================================================
-# CHECK IF AN ACTION HAS TO BE DONE
-#=================================================
-
-theme_old=$(ynh_app_setting_get $app theme)
-
-if [ "$theme" == "$theme_old" ]
-then
-	ynh_die --message="Same theme." --ret_code=0
-fi
-
-#=================================================
-# SPECIFIC ACTION
-#=================================================
-# MOVE TO PUBLIC OR PRIVATE
-#=================================================
-
-ynh_backup_if_checksum_is_different "$final_path/lstu.conf"
-ynh_replace_string "$theme_old" "$theme" "${final_path}/lstu.conf"
-ynh_store_file_checksum "${final_path}/lstu.conf"
-
-# Update the config of the app
-ynh_app_setting_set $app theme $theme
-
-#=================================================
-# RELOAD NGINX
-#=================================================
-
-ynh_systemd_action --service_name=$app --action="reload" --log_path="systemd" --line_match="Server available at"
-
-#=================================================
-# END OF SCRIPT
-#=================================================
diff --git a/scripts/actions/public_private b/scripts/actions/public_private
deleted file mode 100755
index 97a6ba7..0000000
--- a/scripts/actions/public_private
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/bin/bash
-
-#=================================================
-# GENERIC STARTING
-#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-
-source scripts/_common.sh
-source /usr/share/yunohost/helpers
-
-#=================================================
-# RETRIEVE ARGUMENTS
-#=================================================
-
-# Get is_public
-is_public=${YNH_ACTION_IS_PUBLIC}
-
-app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
-
-domain=$(ynh_app_setting_get $app domain)
-path_url=$(ynh_app_setting_get $app path)
-port=$(ynh_app_setting_get $app port)
-final_path=$(ynh_app_setting_get $app final_path)
-secret=$(ynh_app_setting_get $app secret)
-db_name=$(ynh_app_setting_get $app db_name)
-db_user=$db_name
-db_pwd=$(ynh_app_setting_get $app psqlpwd)
-theme=$(ynh_app_setting_get $app theme)
-hashed_password=$(ynh_app_setting_get $app hashed_password)
-
-#=================================================
-# CHECK IF ARGUMENTS ARE CORRECT
-#=================================================
-
-#=================================================
-# CHECK IF AN ACTION HAS TO BE DONE
-#=================================================
-
-is_public_old=$(ynh_app_setting_get $app is_public)
-
-if [ $is_public -eq $is_public_old ]
-then
-	ynh_die --message="is_public is already set as $is_public." --ret_code=0
-fi
-
-#=================================================
-# SPECIFIC ACTION
-#=================================================
-# MOVE TO PUBLIC OR PRIVATE
-#=================================================
-
-if [ $is_public -eq 0 ];
-then
-	ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$final_path/lstu.conf"
-else
-	ynh_add_config --template="../conf/lstu.conf.template" --destination="$final_path/lstu.conf"
-fi
-
-if [ $is_public -eq 0 ]; then
-	public_private="private"
-else
-	public_private="public"
-fi
-
-if [ $is_public -eq 0 ]
-then
-	# If the app is private, only the shortened URLs are publics.
-	if [ "$path_url" == "/" ]; then
-		# If the path is /, clear it to prevent any error with the regex.
-		path_url=""
-	fi
-	# Modify the domain to be used in a regex
-	domain_regex=$(echo "$domain" | sed 's@-@.@g')
-	ynh_app_setting_set $app protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$"
-else
-	ynh_app_setting_delete $app protected_regex
-fi
-
-# Regen ssowat configuration
-yunohost app ssowatconf
-
-# Update the config of the app
-ynh_app_setting_set $app is_public $is_public
-
-#=================================================
-# RELOAD NGINX
-#=================================================
-
-ynh_systemd_action --service_name=$app --action="reload" --log_path="systemd" --line_match="Server available at"
-
-#=================================================
-# END OF SCRIPT
-#=================================================
diff --git a/scripts/backup b/scripts/backup
index 37a5e95..0f520f0 100644
--- a/scripts/backup
+++ b/scripts/backup
@@ -10,27 +10,6 @@
 source ../settings/scripts/_common.sh
 source /usr/share/yunohost/helpers
 
-#=================================================
-# MANAGE SCRIPT FAILURE
-#=================================================
-
-ynh_clean_setup () {
-	true
-}
-# Exit if an error occurs during the execution of the script
-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=$app --key=final_path)
-domain=$(ynh_app_setting_get --app=$app --key=domain)
-db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-
 #=================================================
 # DECLARE DATA AND CONF FILES TO BACKUP
 #=================================================
@@ -40,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..."
 # BACKUP THE APP MAIN DIR
 #=================================================
 
-ynh_backup --src_path="$final_path"
+ynh_backup --src_path="$install_dir"
 
 #=================================================
 # BACKUP THE NGINX CONFIGURATION
diff --git a/scripts/change_url b/scripts/change_url
index 6bb49eb..4db7ac8 100644
--- a/scripts/change_url
+++ b/scripts/change_url
@@ -9,70 +9,6 @@
 source _common.sh
 source /usr/share/yunohost/helpers
 
-#=================================================
-# RETRIEVE ARGUMENTS
-#=================================================
-
-old_domain=$YNH_APP_OLD_DOMAIN
-old_path=$YNH_APP_OLD_PATH
-
-new_domain=$YNH_APP_NEW_DOMAIN
-new_path=$YNH_APP_NEW_PATH
-
-app=$YNH_APP_INSTANCE_NAME
-
-#=================================================
-# LOAD SETTINGS
-#=================================================
-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
-port=$(ynh_app_setting_get --app=$app --key=port)
-is_public=$(ynh_app_setting_get --app=$app --key=is_public)
-db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
-db_user=$db_name
-secret=$(ynh_app_setting_get --app=$app --key=secret)
-theme=$(ynh_app_setting_get --app=$app --key=theme)
-hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password)
-
-#=================================================
-# 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
-#=================================================
-
-change_domain=0
-if [ "$old_domain" != "$new_domain" ]
-then
-	change_domain=1
-fi
-
-change_path=0
-if [ "$old_path" != "$new_path" ]
-then
-	change_path=1
-fi
-
 #=================================================
 # STANDARD MODIFICATIONS
 #=================================================
@@ -87,29 +23,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
 #=================================================
 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 --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 --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 --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
-fi
+ynh_change_url_nginx_config
 
 #=================================================
 # SPECIFIC MODIFICATIONS
@@ -119,31 +33,9 @@ fi
 ynh_script_progression --message="Updating a configuration file..."
 
 domain="$new_domain"
-path_url="$new_path"
+path="$new_path"
 
-if [ $is_public -eq 0 ];
-then
-	ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$final_path/lstu.conf"
-else
-	ynh_add_config --template="../conf/lstu.conf.template" --destination="$final_path/lstu.conf"
-fi
-
-#=================================================
-# UPDATE SSOWAT
-#=================================================
-ynh_script_progression --message="Reconfigure SSOwat"
-
-if [ $is_public -eq 0 ]
-then
-	# If the app is private, only the shortened URLs are publics.
-	if [ "$path_url" == "/" ]; then
-		# If the path is /, clear it to prevent any error with the regex.
-		path_url=""
-	fi
-	# Modify the domain to be used in a regex
-	domain_regex=$(echo "$domain" | sed 's@-@.@g')
-	ynh_app_setting_set $app protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$"
-fi
+ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$install_dir/lstu.conf"
 
 #=================================================
 # GENERIC FINALISATION
@@ -155,13 +47,6 @@ ynh_script_progression --message="Starting a systemd service..."
 # Start a systemd service
 ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at"
 
-#=================================================
-# RELOAD NGINX
-#=================================================
-ynh_script_progression --message="Reloading NGINX web server..."
-
-ynh_systemd_action --service_name=nginx --action=reload
-
 #=================================================
 # END OF SCRIPT
 #=================================================
diff --git a/scripts/install b/scripts/install
index d356330..075417f 100644
--- a/scripts/install
+++ b/scripts/install
@@ -9,104 +9,31 @@
 source _common.sh
 source /usr/share/yunohost/helpers
 
-#=================================================
-# MANAGE SCRIPT FAILURE
-#=================================================
-
-ynh_clean_setup () {
-	ynh_clean_check_starting
-}
-# Exit if an error occurs during the execution of the script
-ynh_abort_if_errors
-
 #=================================================
 # RETRIEVE ARGUMENTS FROM THE MANIFEST
 #=================================================
 
-domain=$YNH_APP_ARG_DOMAIN
-path_url=$YNH_APP_ARG_PATH
-is_public=$YNH_APP_ARG_IS_PUBLIC
-theme=$YNH_APP_ARG_THEME
-password=$YNH_APP_ARG_PASSWORD
-
-app=$YNH_APP_INSTANCE_NAME
-
 secret=$(ynh_string_random --length=24)
 hashed_password=$(echo -n $password | sha256sum | cut -d' ' -f1)
 
-#=================================================
-# 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 --message="This path already contains a folder"
-
-# Register (book) web path
-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=$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
-ynh_app_setting_set --app=$app --key=theme --value=$theme
 ynh_app_setting_set --app=$app --key=secret --value=$secret
 ynh_app_setting_set --app=$app --key=hashed_password --value=$hashed_password
 
-#=================================================
-# STANDARD MODIFICATIONS
-#=================================================
-# FIND AND OPEN A PORT
-#=================================================
-ynh_script_progression --message="Finding an available port..."
-
-# Find an available port
-port=$(ynh_find_port --port=8095)
-ynh_app_setting_set --app=$app --key=port --value=$port
-
-#=================================================
-# INSTALL DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Installing dependencies..."
-
-ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
-
-#=================================================
-# CREATE DEDICATED USER
-#=================================================
-ynh_script_progression --message="Configuring system user..."
-
-# Create a system user
-ynh_system_user_create --username=$app --home_dir="$final_path"
-
-#=================================================
-# CREATE A POSTGRESQL DATABASE
-#=================================================
-ynh_script_progression --message="Creating a PostgreSQL database..."
-
-# Create postgresql database
-ynh_psql_test_if_first_run
-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_psql_setup_db --db_user=$db_user --db_name=$db_name
-
 #=================================================
 # DOWNLOAD, CHECK AND UNPACK SOURCE
 #=================================================
 ynh_script_progression --message="Setting up source files..."
 
-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 --dest_dir="$final_path"
+ynh_setup_source --dest_dir="$install_dir"
 
-chmod 750 "$final_path"
-chmod -R o-rwx "$final_path"
-chown -R $app:www-data "$final_path"
+chmod -R o-rwx "$install_dir"
+chown -R $app:www-data "$install_dir"
 
 #=================================================
 # NGINX CONFIGURATION
@@ -116,6 +43,14 @@ ynh_script_progression --message="Configuring NGINX web server..."
 # Create a dedicated nginx config
 ynh_add_nginx_config
 
+# Create a dedicated systemd config
+ynh_add_systemd_config
+
+# Use logrotate to manage application logfile(s)
+ynh_use_logrotate
+
+yunohost service add $app --log="/var/log/$app.log" --log="/var/www/$app/log/production.log"
+
 #=================================================
 # SPECIFIC SETUP
 #=================================================
@@ -123,45 +58,17 @@ ynh_add_nginx_config
 #=================================================
 ynh_script_progression --message="Adding a configuration file..."
 
-if [ $is_public -eq 0 ];
-then
-	ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$final_path/lstu.conf"
-else
-	ynh_add_config --template="../conf/lstu.conf.template" --destination="$final_path/lstu.conf"
-fi
+ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$install_dir/lstu.conf"
 
 #=================================================
 # INSTALL LSTU
 #=================================================
 ynh_script_progression --message="Installing Lstu..."
 
-pushd $final_path
+pushd $install_dir
 	carton install --deployment --without=sqlite --without=mysql
 popd
 
-#=================================================
-# SETUP SYSTEMD
-#=================================================
-ynh_script_progression --message="Configuring a systemd service..."
-
-# Create a dedicated systemd config
-ynh_add_systemd_config
-
-#=================================================
-# SETUP LOGROTATE
-#=================================================
-ynh_script_progression --message="Configuring log rotation..."
-
-# Use logrotate to manage application logfile(s)
-ynh_use_logrotate
-
-#=================================================
-# INTEGRATE SERVICE IN YUNOHOST
-#=================================================
-ynh_script_progression --message="Integrating service in YunoHost..."
-
-yunohost service add $app --log="/var/log/$app.log" --log="/var/www/$app/log/production.log"
-
 #=================================================
 # START SYSTEMD SERVICE
 #=================================================
@@ -170,34 +77,6 @@ ynh_script_progression --message="Starting a systemd service..."
 # Start a systemd service
 ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at"
 
-#=================================================
-# SETUP SSOWAT
-#=================================================
-ynh_script_progression --message="Configuring permissions..."
-
-# Everyone can access the app.
-# The "main" permission is automatically created before the install script.
-ynh_permission_update --permission="main" --add="visitors"
-
-if [ $is_public -eq 0 ]
-then
-	# If the app is private, only the shortened URLs are publics.
-	if [ "$path_url" == "/" ]; then
-		# If the path is /, clear it to prevent any error with the regex.
-		path_url=""
-	fi
-	# Modify the domain to be used in a regex
-	domain_regex=$(echo "$domain" | sed 's@-@.@g')
-	ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$"
-fi
-
-#=================================================
-# RELOAD NGINX
-#=================================================
-ynh_script_progression --message="Reloading NGINX web server..."
-
-ynh_systemd_action --service_name=nginx --action=reload
-
 #=================================================
 # END OF SCRIPT
 #=================================================
diff --git a/scripts/remove b/scripts/remove
index 9aa3392..86cee08 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -9,19 +9,6 @@
 source _common.sh
 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=$app --key=domain)
-port=$(ynh_app_setting_get --app=$app --key=port)
-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
 #=================================================
@@ -35,74 +22,18 @@ then
 	yunohost service remove $app
 fi
 
-#=================================================
-# STOP AND REMOVE SERVICE
-#=================================================
-ynh_script_progression --message="Stopping and removing the systemd service..."
-
 # Remove the dedicated systemd config
 ynh_remove_systemd_config
 
-#=================================================
-# REMOVE LOGROTATE CONFIGURATION
-#=================================================
-ynh_script_progression --message="Removing logrotate configuration..."
-
 # Remove the app-specific logrotate config
 ynh_remove_logrotate
 
-#=================================================
-# REMOVE THE POSTGRESQL DATABASE
-#=================================================
-ynh_script_progression --message="Removing the PostgreSQL database..."
-
-# Remove a database if it exists, along with the associated user
-ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
-
-#=================================================
-# REMOVE APP MAIN DIR
-#=================================================
-ynh_script_progression --message="Removing app main directory..."
-
-# Remove the app directory securely
-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
 
-#=================================================
-# REMOVE DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Removing dependencies..."
-
-# Remove metapackage and its dependencies
-ynh_remove_app_dependencies
-
-#=================================================
-# SPECIFIC REMOVE
-#=================================================
-# REMOVE VARIOUS FILES
-#=================================================
-ynh_script_progression --message="Removing various files..."
-
 # Remove the log files
 ynh_secure_remove --file="/var/log/$app.log"
 
-#=================================================
-# GENERIC FINALIZATION
-#=================================================
-# REMOVE DEDICATED USER
-#=================================================
-ynh_script_progression --message="Removing the dedicated system user..."
-
-# Delete a system user
-ynh_system_user_delete --username=$app
-
 #=================================================
 # END OF SCRIPT
 #=================================================
diff --git a/scripts/restore b/scripts/restore
index f6cc83f..f9f2cd4 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -10,68 +10,15 @@
 source ../settings/scripts/_common.sh
 source /usr/share/yunohost/helpers
 
-#=================================================
-# MANAGE SCRIPT FAILURE
-#=================================================
-
-ynh_clean_setup () {
-	ynh_clean_check_starting
-}
-# Exit if an error occurs during the execution of the script
-ynh_abort_if_errors
-
-#=================================================
-# LOAD SETTINGS
-#=================================================
-ynh_script_progression --message="Loading installation settings..."
-
-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
-db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
-
-#=================================================
-# CHECK IF THE APP CAN BE RESTORED
-#=================================================
-ynh_script_progression --message="Validating restoration parameters..."
-
-test ! -d $final_path \
-	|| ynh_die --message="There is already a directory: $final_path "
-
-#=================================================
-# STANDARD RESTORATION STEPS
-#=================================================
-# RECREATE THE DEDICATED USER
-#=================================================
-ynh_script_progression --message="Recreating the dedicated system user..."
-
-# Create the dedicated user (if not existing)
-ynh_system_user_create --username=$app --home_dir="$final_path"
-
 #=================================================
 # RESTORE THE APP MAIN DIR
 #=================================================
 ynh_script_progression --message="Restoring the app main directory..."
 
-ynh_restore_file --origin_path="$final_path"
+ynh_restore_file --origin_path="$install_dir"
 
-chmod 750 "$final_path"
-chmod -R o-rwx "$final_path"
-chown -R $app:www-data "$final_path"
-
-#=================================================
-# SPECIFIC RESTORATION
-#=================================================
-# REINSTALL DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Reinstalling dependencies..."
-
-# Define and install dependencies
-ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
+chmod -R o-rwx "$install_dir"
+chown -R $app:www-data "$install_dir"
 
 #=================================================
 # RESTORE THE NGINX CONFIGURATION
@@ -85,45 +32,31 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
 #=================================================
 ynh_script_progression --message="Restoring the PostregSQL database..."
 
-ynh_psql_test_if_first_run
-ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
-ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
+#ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
+ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
 
 #=================================================
-# RESTORE SYSTEMD
+# RESTORE SYSTEM CONFIGURATIONS
 #=================================================
-ynh_script_progression --message="Restoring the systemd configuration..."
+# RESTORE THE PHP-FPM CONFIGURATION
+#=================================================
+ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
 
 ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
 systemctl enable $app.service --quiet
 
-#=================================================
-# RESTORE THE LOGROTATE CONFIGURATION
-#=================================================
-ynh_script_progression --message="Restoring the logrotate configuration..."
-
 ynh_restore_file --origin_path="/etc/logrotate.d/$app"
 
-#=================================================
-# INTEGRATE SERVICE IN YUNOHOST
-#=================================================
-ynh_script_progression --message="Integrating service in YunoHost..."
-
 yunohost service add $app --log="/var/log/$app.log" --log="/var/www/$app/log/production.log"
 
-#=================================================
-# START SYSTEMD SERVICE
-#=================================================
-ynh_script_progression --message="Starting a systemd service..."
-
-ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at"
-
 #=================================================
 # GENERIC FINALIZATION
 #=================================================
-# RELOAD NGINX
+# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
 #=================================================
-ynh_script_progression --message="Reloading NGINX web server..."
+ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
+
+ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at"
 
 ynh_systemd_action --service_name=nginx --action=reload
 
diff --git a/scripts/upgrade b/scripts/upgrade
index c08a1aa..0af045f 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -9,47 +9,12 @@
 source _common.sh
 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=$app --key=domain)
-path_url=$(ynh_app_setting_get --app=$app --key=path)
-is_public=$(ynh_app_setting_get --app=$app --key=is_public)
-port=$(ynh_app_setting_get --app=$app --key=port)
-final_path=$(ynh_app_setting_get --app=$app --key=final_path)
-secret=$(ynh_app_setting_get --app=$app --key=secret)
-db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_user=$db_name
-db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
-theme=$(ynh_app_setting_get --app=$app theme)
-hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password)
-
 #=================================================
 # CHECK VERSION
 #=================================================
-ynh_script_progression --message="Checking version..."
 
 upgrade_type=$(ynh_check_app_version_changed)
 
-#=================================================
-# 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
-ynh_clean_setup () {
-	ynh_clean_check_starting
-	# 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
 #=================================================
@@ -59,67 +24,6 @@ ynh_script_progression --message="Stopping a systemd service..."
 
 ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
 
-#=================================================
-# ENSURE DOWNWARD COMPATIBILITY
-#=================================================
-ynh_script_progression --message="Ensuring downward compatibility..."
-
-# 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
-
-if [ -z "$db_pwd" ]; then
-	db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)	# Fix old db_pwd
-	if [ -z "$db_pwd" ]; then
-		ynh_psql_test_if_first_run
-		db_name=$(ynh_sanitize_dbid --db_name="$app")
-		db_user=$db_name
-		# Initialize database and store postgres password for upgrade
-		ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name"
-		ynh_app_setting_set --app="$app" --key=db_name --value="$db_name"
-		db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) # Password created in ynh_psql_setup_db function
-	else
-		ynh_app_setting_delete --app=$app --key=db_pwd
-		ynh_app_setting_set --app=$app --key=psqlpwd --value=$db_pwd
-	fi
-fi
-
-if [ -z "$theme" ]; then
-	theme="milligram"
-	ynh_app_setting_set --app=$app --key=theme --value=$theme
-fi
-
-if [ -z "$hashed_password" ]; then
-	# Generate random password
-	password=$(ynh_string_random --length=8)
-	hashed_password=$(echo -n $password | sha256sum | cut -d' ' -f1)
-
-	echo "The new version of LSTU provide an admin and a stats area which required a password." > mail_to_send
-	echo "" >> mail_to_send
-	echo "This password is: $password" >> mail_to_send
-
-	ynh_send_readme_to_admin --app_message="mail_to_send" --type="upgrade"
-	
-	ynh_app_setting_set --app=$app --key=hashed_password --value=$hashed_password
-fi
-
-# In previous versions, the port was mistakenly exposed to the outside world >_>
-if yunohost firewall list | grep -q "\- $port$"
-then
-	ynh_script_progression --message="Closing port $port..."
-	ynh_exec_warn_less yunohost firewall disallow TCP $port
-fi
-
-#=================================================
-# CREATE DEDICATED USER
-#=================================================
-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"
-
 #=================================================
 # DOWNLOAD, CHECK AND UNPACK SOURCE
 #=================================================
@@ -129,48 +33,27 @@ 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" #--keep="$final_path/lstu.conf"
+	ynh_setup_source --dest_dir="$install_dir" --keep="lstu.conf"
 fi
 
-chmod 750 "$final_path"
-chmod -R o-rwx "$final_path"
-chown -R $app:www-data "$final_path"
-
-#=================================================
-# UPGRADE DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Upgrading dependencies..."
-
-ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
-
-#=================================================
-# NGINX CONFIGURATION
-#=================================================
-ynh_script_progression --message="Upgrading NGINX web server configuration..."
-
-# Create a dedicated NGINX config
-ynh_add_nginx_config
+chmod -R o-rwx "$install_dir"
+chown -R $app:www-data "$install_dir"
 
 #=================================================
 # SPECIFIC UPGRADE
 #=================================================
 # UPDATE A CONFIG FILE
 #=================================================
-ynh_script_progression --message="Updating a configuration file..."
+#ynh_script_progression --message="Updating a configuration file..."
 
-if [ $is_public -eq 0 ];
-then
-	ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$final_path/lstu.conf"
-else
-	ynh_add_config --template="../conf/lstu.conf.template" --destination="$final_path/lstu.conf"
-fi
+#ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$install_dir/lstu.conf"
 
 #=================================================
 # BUILD LSU
 #=================================================
 ynh_script_progression --message="Building lstu..."
 
-pushd $final_path
+pushd $install_dir
 	carton install --deployment --without=sqlite --without=mysql
 popd
 
@@ -179,24 +62,15 @@ popd
 #=================================================
 ynh_script_progression --message="Upgrading systemd configuration..."
 
+# Create a dedicated NGINX config
+ynh_add_nginx_config
+
 # Create a dedicated systemd config
 ynh_add_systemd_config
 
-#=================================================
-# GENERIC FINALIZATION
-#=================================================
-# SETUP LOGROTATE
-#=================================================
-ynh_script_progression --message="Upgrading logrotate configuration..."
-
 # Use logrotate to manage app-specific logfile(s)
 ynh_use_logrotate --non-append
 
-#=================================================
-# INTEGRATE SERVICE IN YUNOHOST
-#=================================================
-ynh_script_progression --message="Integrating service in YunoHost..."
-
 yunohost service add $app --log="/var/log/$app.log" --log="/var/www/$app/log/production.log"
 
 #=================================================
@@ -204,35 +78,7 @@ yunohost service add $app --log="/var/log/$app.log" --log="/var/www/$app/log/pro
 #=================================================
 ynh_script_progression --message="Starting a systemd service..."
 
-ynh_systemd_action --service_name=$app --action=reload --line_match="Reloaded Shortened URLs service." --log_path="systemd"
-
-#=================================================
-# SETUP SSOWAT
-#=================================================
-ynh_script_progression --message="Configuring permissions..."
-
-# Everyone can access the app.
-# The "main" permission is automatically created before the install script.
-ynh_permission_update --permission="main" --add="visitors"
-
-if [ $is_public -eq 0 ]
-then
-	# If the app is private, only the shortened URLs are publics.
-	if [ "$path_url" == "/" ]; then
-		# If the path is /, clear it to prevent any error with the regex.
-		path_url=""
-	fi
-	# Modify the domain to be used in a regex
-	domain_regex=$(echo "$domain" | sed 's@-@.@g')
-	ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$"
-fi
-
-#=================================================
-# RELOAD NGINX
-#=================================================
-ynh_script_progression --message="Reloading NGINX web server..."
-
-ynh_systemd_action --service_name=nginx --action=reload
+ynh_systemd_action --service_name=$app --action=reload --log_path="systemd" --line_match="Reloaded Shortened URLs service."
 
 #=================================================
 # END OF SCRIPT
diff --git a/tests.toml b/tests.toml
new file mode 100644
index 0000000..fbc133d
--- /dev/null
+++ b/tests.toml
@@ -0,0 +1,14 @@
+test_format = 1.0
+
+[default]
+    # -------------------------------
+    # Default args to use for install
+    # -------------------------------
+
+	args.theme = "milligram"
+
+    # -------------------------------
+    # Commits to test upgrade from
+    # -------------------------------
+
+    test_upgrade_from.af9f0258204e71bc567206ef2dc00d151319fa21.name = "Upgrade from 0.26.0~ynh2"