From 086f9c95696dd1a4dc5f6c3796e06e1d6785afca Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 15 Aug 2022 19:15:30 +0200 Subject: [PATCH 01/15] set relative path for --keep opt --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index c08a1aa..316462d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -129,7 +129,7 @@ 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="$final_path" #--keep="lstu.conf" fi chmod 750 "$final_path" From 8c172a1ae16a740d633f9d96e14820438a2f2ca8 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Mon, 15 Aug 2022 17:15:37 +0000 Subject: [PATCH 02/15] Auto-update README --- README.md | 1 + README_fr.md | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ae5b2ee..c432a41 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Lstu means Let's Shorten That URL. **Shipped version:** 0.26.0~ynh2 + **Demo:** https://lstu.fr ## Screenshots diff --git a/README_fr.md b/README_fr.md index 4c5d4ba..6893165 100644 --- a/README_fr.md +++ b/README_fr.md @@ -18,7 +18,8 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Raccourcisseur d'URL -**Version incluse :** 0.26.0~ynh2 +**Version incluse :** 0.26.0~ynh2 + **Démo :** https://lstu.fr From 0090f9719f5d4dd803ef0917111ce4c73539affa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 31 May 2023 20:58:29 +0200 Subject: [PATCH 03/15] v2 --- conf/app.src | 7 --- conf/logrotate | 2 +- conf/lstu-minion@.service | 2 +- conf/systemd.service | 4 +- manifest.toml | 70 ++++++++++++++++++++++++++++ scripts/_common.sh | 4 +- scripts/backup | 16 +++---- scripts/change_url | 98 ++++++++++++++++++++------------------- scripts/install | 92 ++++++++++++++++++------------------ scripts/remove | 30 ++++++------ scripts/restore | 48 +++++++++---------- scripts/upgrade | 98 +++++++++++++++++++-------------------- 12 files changed, 268 insertions(+), 203 deletions(-) delete mode 100644 conf/app.src create mode 100644 manifest.toml 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/manifest.toml b/manifest.toml new file mode 100644 index 0000000..36c8ce1 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,70 @@ +packaging_format = 2 + +id = "lstu" +name = "Lstu" +description.en = "URL Shortener" +description.fr = "Raccourcisseur d'URL" + +version = "0.26.0~ynh2" + +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" +cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) +fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. + +[integration] +yunohost = ">= 4.3.0" +architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +multi_instance = true +ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. +sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. +disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +[install] + [install.domain] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "domain" + + [install.path] + # this is a generic question - ask strings are automatically handled by Yunohost's core + 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] + # this is a generic question - ask strings are automatically handled by Yunohost's core + 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.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" + + [resources.database] + type = "postgresql" diff --git a/scripts/_common.sh b/scripts/_common.sh index 330f35d..79d1443 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="build-essential libssl-dev zlib1g-dev libpng-dev libpq-dev memcached postgresql carton libpod-parser-perl" +#REMOVEME? pkg_dependencies="build-essential libssl-dev zlib1g-dev libpng-dev libpq-dev memcached postgresql carton libpod-parser-perl" #================================================= # PERSONAL HELPERS @@ -38,7 +38,7 @@ ynh_send_readme_to_admin() { type="${type:-install}" # Get the value of admin_mail_html - admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) +#REMOVEME? admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) admin_mail_html="${admin_mail_html:-0}" # Retrieve the email of users diff --git a/scripts/backup b/scripts/backup index 37a5e95..0247afc 100644 --- a/scripts/backup +++ b/scripts/backup @@ -14,22 +14,22 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +#REMOVEME? ynh_print_info --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? 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) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -40,7 +40,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..9a52508 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -13,64 +13,64 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH +#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN +#REMOVEME? old_path=$YNH_APP_OLD_PATH -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH +#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN +#REMOVEME? new_path=$YNH_APP_NEW_PATH -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +#REMOVEME? 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) +#REMOVEME? # Needed for helper "ynh_add_nginx_config" +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) # 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) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? is_public=$(ynh_app_setting_get --app=$app --key=is_public) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +#REMOVEME? db_user=$db_name +#REMOVEME? secret=$(ynh_app_setting_get --app=$app --key=secret) +#REMOVEME? theme=$(ynh_app_setting_get --app=$app --key=theme) +#REMOVEME? 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)..." +#REMOVEME? 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 +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { + #REMOVEME? 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" +#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= -change_domain=0 -if [ "$old_domain" != "$new_domain" ] +#REMOVEME? change_domain=0 +#REMOVEME? if [ "$old_domain" != "$new_domain" ] then - change_domain=1 + #REMOVEME? change_domain=1 fi -change_path=0 -if [ "$old_path" != "$new_path" ] +#REMOVEME? change_path=0 +#REMOVEME? if [ "$old_path" != "$new_path" ] then - change_path=1 + #REMOVEME? change_path=1 fi #================================================= @@ -87,28 +87,30 @@ 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 +ynh_change_url_nginx_config + +#REMOVEME? 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" +#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path" # Set global variables for NGINX helper - domain="$old_domain" - path_url="$new_path" +#REMOVEME? domain="$old_domain" +#REMOVEME? path="$new_path" # Create a dedicated NGINX config - ynh_add_nginx_config +#REMOVEME? 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 +#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" +#REMOVEME? 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" +#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= @@ -117,15 +119,15 @@ fi # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." - +#REMOVEME? domain="$new_domain" -path_url="$new_path" +path="$new_path" -if [ $is_public -eq 0 ]; +#REMOVEME? if [ $is_public -eq 0 ]; then - ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$final_path/lstu.conf" + ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$install_dir/lstu.conf" else - ynh_add_config --template="../conf/lstu.conf.template" --destination="$final_path/lstu.conf" + ynh_add_config --template="../conf/lstu.conf.template" --destination="$install_dir/lstu.conf" fi #================================================= @@ -133,16 +135,16 @@ fi #================================================= ynh_script_progression --message="Reconfigure SSOwat" -if [ $is_public -eq 0 ] +#REMOVEME? if [ $is_public -eq 0 ] then # If the app is private, only the shortened URLs are publics. - if [ "$path_url" == "/" ]; then + if [ "$path" == "/" ]; then # If the path is /, clear it to prevent any error with the regex. - path_url="" +#REMOVEME? path="" 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/$" +#REMOVEME? ynh_app_setting_set $app protected_regex "$domain_regex$path/login$","$domain_regex$path/logout$","$domain_regex$path/api$","$domain_regex$path/extensions$","$domain_regex$path/stats$","$domain_regex$path/d/.*$","$domain_regex$path/a$","$domain_regex$path/$" fi #================================================= @@ -158,9 +160,9 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index d356330..876eec1 100644 --- a/scripts/install +++ b/scripts/install @@ -13,23 +13,23 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? 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 +#REMOVEME? domain=$YNH_APP_ARG_DOMAIN +#REMOVEME? path=$YNH_APP_ARG_PATH +#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC +#REMOVEME? theme=$YNH_APP_ARG_THEME +#REMOVEME? password=$YNH_APP_ARG_PASSWORD -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME secret=$(ynh_string_random --length=24) hashed_password=$(echo -n $password | sha256sum | cut -d' ' -f1) @@ -37,76 +37,76 @@ 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..." +#REMOVEME? 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" +#REMOVEME? install_dir=/var/www/$app +#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" # Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url +#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." +#REMOVEME? 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 +#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain +#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path 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 +#REMOVEME? 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..." +#REMOVEME? 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 +#REMOVEME? port=$(ynh_find_port --port=8095) +#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." +#REMOVEME? ynh_script_progression --message="Installing dependencies..." -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." +#REMOVEME? ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." +#REMOVEME? 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 +#REMOVEME? ynh_psql_test_if_first_run +#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app) +#REMOVEME? db_user=$db_name +#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name +#REMOVEME? 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 +#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir # 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 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # NGINX CONFIGURATION @@ -123,11 +123,11 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Adding a configuration file..." -if [ $is_public -eq 0 ]; +#REMOVEME? if [ $is_public -eq 0 ]; then - ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$final_path/lstu.conf" + ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$install_dir/lstu.conf" else - ynh_add_config --template="../conf/lstu.conf.template" --destination="$final_path/lstu.conf" + ynh_add_config --template="../conf/lstu.conf.template" --destination="$install_dir/lstu.conf" fi #================================================= @@ -135,7 +135,7 @@ fi #================================================= ynh_script_progression --message="Installing Lstu..." -pushd $final_path +pushd $install_dir carton install --deployment --without=sqlite --without=mysql popd @@ -173,30 +173,30 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." +#REMOVEME? 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" +#REMOVEME? ynh_permission_update --permission="main" --add="visitors" -if [ $is_public -eq 0 ] +#REMOVEME? if [ $is_public -eq 0 ] then # If the app is private, only the shortened URLs are publics. - if [ "$path_url" == "/" ]; then + if [ "$path" == "/" ]; then # If the path is /, clear it to prevent any error with the regex. - path_url="" + path="" 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/$" +#REMOVEME? ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path/login$","$domain_regex$path/logout$","$domain_regex$path/api$","$domain_regex$path/extensions$","$domain_regex$path/stats$","$domain_regex$path/d/.*$","$domain_regex$path/a$","$domain_regex$path/$" fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 9aa3392..e3f88dd 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,15 +12,15 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +#REMOVEME? ynh_script_progression --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? 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) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? db_user=$db_name +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) #================================================= # STANDARD REMOVE @@ -54,18 +54,18 @@ ynh_remove_logrotate #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." +#REMOVEME? 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 +#REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." +#REMOVEME? ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely -ynh_secure_remove --file="$final_path" +#REMOVEME? ynh_secure_remove --file="$install_dir" #================================================= # REMOVE NGINX CONFIGURATION @@ -78,10 +78,10 @@ ynh_remove_nginx_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." +#REMOVEME? ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies -ynh_remove_app_dependencies +#REMOVEME? ynh_remove_app_dependencies #================================================= # SPECIFIC REMOVE @@ -98,10 +98,10 @@ ynh_secure_remove --file="/var/log/$app.log" #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." +#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user -ynh_system_user_delete --username=$app +#REMOVEME? ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index f6cc83f..3a83388 100644 --- a/scripts/restore +++ b/scripts/restore @@ -14,64 +14,64 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +#REMOVEME? ynh_script_progression --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? 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) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? db_user=$db_name +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." +#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " +#REMOVEME? test ! -d $install_dir \ + || ynh_die --message="There is already a directory: $install_dir " #================================================= # STANDARD RESTORATION STEPS #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." +#REMOVEME? 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" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # 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" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." +#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE NGINX CONFIGURATION @@ -83,10 +83,10 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostregSQL database..." +#REMOVEME? 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 +#REMOVEME? ynh_psql_test_if_first_run +#REMOVEME? 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 #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 316462d..f68b950 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,21 +12,21 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +#REMOVEME? ynh_script_progression --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? 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) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? is_public=$(ynh_app_setting_get --app=$app --key=is_public) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? secret=$(ynh_app_setting_get --app=$app --key=secret) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? db_user=$db_name +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +#REMOVEME? theme=$(ynh_app_setting_get --app=$app theme) +#REMOVEME? hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password) #================================================= # CHECK VERSION @@ -38,17 +38,17 @@ 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)..." +#REMOVEME? 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 () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS @@ -64,25 +64,25 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= 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 +# If install_dir doesn't exist, create it +if [ -z "$install_dir" ]; then +#REMOVEME? install_dir=/var/www/$app +#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir fi if [ -z "$db_pwd" ]; then - db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) # Fix old db_pwd +#REMOVEME? 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 +#REMOVEME? 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 +#REMOVEME? ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" +#REMOVEME? ynh_app_setting_set --app="$app" --key=db_name --value="$db_name" +#REMOVEME? #REMOVEME? 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 +#REMOVEME? ynh_app_setting_set --app=$app --key=psqlpwd --value=$db_pwd fi fi @@ -102,7 +102,7 @@ if [ -z "$hashed_password" ]; then ynh_send_readme_to_admin --app_message="mail_to_send" --type="upgrade" - ynh_app_setting_set --app=$app --key=hashed_password --value=$hashed_password +#REMOVEME? 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 >_> @@ -115,10 +115,10 @@ fi #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." +#REMOVEME? 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" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -129,19 +129,19 @@ 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="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" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." +#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # NGINX CONFIGURATION @@ -158,11 +158,11 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Updating a configuration file..." -if [ $is_public -eq 0 ]; +#REMOVEME? if [ $is_public -eq 0 ]; then - ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$final_path/lstu.conf" + ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$install_dir/lstu.conf" else - ynh_add_config --template="../conf/lstu.conf.template" --destination="$final_path/lstu.conf" + ynh_add_config --template="../conf/lstu.conf.template" --destination="$install_dir/lstu.conf" fi #================================================= @@ -170,7 +170,7 @@ fi #================================================= ynh_script_progression --message="Building lstu..." -pushd $final_path +pushd $install_dir carton install --deployment --without=sqlite --without=mysql popd @@ -209,30 +209,30 @@ ynh_systemd_action --service_name=$app --action=reload --line_match="Reloaded Sh #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." +#REMOVEME? 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" +#REMOVEME? ynh_permission_update --permission="main" --add="visitors" -if [ $is_public -eq 0 ] +#REMOVEME? if [ $is_public -eq 0 ] then # If the app is private, only the shortened URLs are publics. - if [ "$path_url" == "/" ]; then + if [ "$path" == "/" ]; then # If the path is /, clear it to prevent any error with the regex. - path_url="" + path="" 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/$" +#REMOVEME? ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path/login$","$domain_regex$path/logout$","$domain_regex$path/api$","$domain_regex$path/extensions$","$domain_regex$path/stats$","$domain_regex$path/d/.*$","$domain_regex$path/a$","$domain_regex$path/$" fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT From 7857c8995adcf69843ad37ab5f10453998bf3357 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 31 May 2023 18:58:35 +0000 Subject: [PATCH 04/15] Auto-update README --- README.md | 4 ++-- README_fr.md | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index c432a41..24411a2 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)* @@ -20,7 +21,6 @@ Lstu means Let's Shorten That URL. **Shipped version:** 0.26.0~ynh2 - **Demo:** https://lstu.fr ## Screenshots diff --git a/README_fr.md b/README_fr.md index 6893165..4d471c5 100644 --- a/README_fr.md +++ b/README_fr.md @@ -5,27 +5,27 @@ 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~ynh2 **Démo :** https://lstu.fr -## Captures d'écran +## Captures d’écran -![Capture d'écran de Lstu](./doc/screenshots/LSTU_screenshot.png) +![Capture d’écran de Lstu](./doc/screenshots/LSTU_screenshot.png) ## Avertissements / informations importantes @@ -35,9 +35,9 @@ Comment configurer cette application : un fichier simple à `/var/www/lstu/lstu. ## 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 : @@ -53,4 +53,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 From f7ac631aea741cf7b38e612772f98c53f72d8b6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 31 May 2023 21:08:32 +0200 Subject: [PATCH 05/15] v2 --- actions.json | 77 ------------------ manifest.json | 63 --------------- manifest.toml | 23 +++--- scripts/_common.sh | 3 - scripts/actions/change_password | 56 -------------- scripts/actions/change_theme | 55 ------------- scripts/actions/public_private | 94 ---------------------- scripts/backup | 21 ----- scripts/change_url | 114 +-------------------------- scripts/install | 112 +-------------------------- scripts/remove | 47 ----------- scripts/restore | 57 +------------- scripts/upgrade | 133 +------------------------------- tests.toml | 3 + 14 files changed, 22 insertions(+), 836 deletions(-) delete mode 100644 actions.json delete mode 100644 manifest.json delete mode 100755 scripts/actions/change_password delete mode 100755 scripts/actions/change_theme delete mode 100755 scripts/actions/public_private create mode 100644 tests.toml 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/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 index 36c8ce1..bea3cd0 100644 --- a/manifest.toml +++ b/manifest.toml @@ -15,26 +15,22 @@ 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" -cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) -fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. [integration] -yunohost = ">= 4.3.0" -architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +yunohost = ">= 11.1.19" +architectures = "all" multi_instance = true -ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. -sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. -disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... -ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... -ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ldap = true +sso = true +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" [install] [install.domain] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "domain" [install.path] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "path" default = "/lstu" @@ -50,7 +46,6 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen default = "milligram" [install.password] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "password" [resources] @@ -58,6 +53,7 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen 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] @@ -66,5 +62,8 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen [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 79d1443..03f3ceb 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -#REMOVEME? pkg_dependencies="build-essential libssl-dev zlib1g-dev libpng-dev libpq-dev memcached postgresql carton libpod-parser-perl" - #================================================= # PERSONAL 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 0247afc..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 -#================================================= - -#REMOVEME? ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_print_info --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= diff --git a/scripts/change_url b/scripts/change_url index 9a52508..6ef2cea 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,70 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN -#REMOVEME? old_path=$YNH_APP_OLD_PATH - -#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN -#REMOVEME? new_path=$YNH_APP_NEW_PATH - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -#REMOVEME? # Needed for helper "ynh_add_nginx_config" -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) - -# Add settings here as needed by your application -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) -#REMOVEME? is_public=$(ynh_app_setting_get --app=$app --key=is_public) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -#REMOVEME? db_user=$db_name -#REMOVEME? secret=$(ynh_app_setting_get --app=$app --key=secret) -#REMOVEME? theme=$(ynh_app_setting_get --app=$app --key=theme) -#REMOVEME? hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password) - -#================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - #REMOVEME? 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. -#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -#REMOVEME? change_domain=0 -#REMOVEME? if [ "$old_domain" != "$new_domain" ] -then - #REMOVEME? change_domain=1 -fi - -#REMOVEME? change_path=0 -#REMOVEME? if [ "$old_path" != "$new_path" ] -then - #REMOVEME? change_path=1 -fi - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -89,37 +25,13 @@ ynh_script_progression --message="Updating NGINX web server configuration..." ynh_change_url_nginx_config -#REMOVEME? 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 -#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper -#REMOVEME? domain="$old_domain" -#REMOVEME? path="$new_path" - # Create a dedicated NGINX config -#REMOVEME? 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 -#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" -#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location -#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi - #================================================= # SPECIFIC MODIFICATIONS #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." -#REMOVEME? + domain="$new_domain" path="$new_path" @@ -130,23 +42,6 @@ else ynh_add_config --template="../conf/lstu.conf.template" --destination="$install_dir/lstu.conf" fi -#================================================= -# UPDATE SSOWAT -#================================================= -ynh_script_progression --message="Reconfigure SSOwat" - -#REMOVEME? if [ $is_public -eq 0 ] -then - # If the app is private, only the shortened URLs are publics. - if [ "$path" == "/" ]; then - # If the path is /, clear it to prevent any error with the regex. -#REMOVEME? path="" - fi - # Modify the domain to be used in a regex - domain_regex=$(echo "$domain" | sed 's@-@.@g') -#REMOVEME? ynh_app_setting_set $app protected_regex "$domain_regex$path/login$","$domain_regex$path/logout$","$domain_regex$path/api$","$domain_regex$path/extensions$","$domain_regex$path/stats$","$domain_regex$path/d/.*$","$domain_regex$path/a$","$domain_regex$path/$" -fi - #================================================= # GENERIC FINALISATION #================================================= @@ -157,13 +52,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 -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." - -#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 876eec1..6a194c2 100644 --- a/scripts/install +++ b/scripts/install @@ -9,102 +9,29 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -#REMOVEME? domain=$YNH_APP_ARG_DOMAIN -#REMOVEME? path=$YNH_APP_ARG_PATH -#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC -#REMOVEME? theme=$YNH_APP_ARG_THEME -#REMOVEME? password=$YNH_APP_ARG_PASSWORD - -#REMOVEME? 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 -#================================================= -#REMOVEME? ynh_script_progression --message="Validating installation parameters..." - -#REMOVEME? install_dir=/var/www/$app -#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path - #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -#REMOVEME? ynh_script_progression --message="Storing installation settings..." +ynh_script_progression --message="Storing installation settings..." -#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain -#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path -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 -#REMOVEME? ynh_app_setting_set --app=$app --key=hashed_password --value=$hashed_password - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -#REMOVEME? ynh_script_progression --message="Finding an available port..." - -# Find an available port -#REMOVEME? port=$(ynh_find_port --port=8095) -#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Installing dependencies..." - -#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring system user..." - -# Create a system user -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - -#================================================= -# CREATE A POSTGRESQL DATABASE -#================================================= -#REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..." - -# Create postgresql database -#REMOVEME? ynh_psql_test_if_first_run -#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app) -#REMOVEME? db_user=$db_name -#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name -#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name +ynh_app_setting_set --app=$app --key=hashed_password --value=$hashed_password #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." -#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -123,12 +50,7 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Adding a configuration file..." -#REMOVEME? if [ $is_public -eq 0 ]; -then - ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$install_dir/lstu.conf" -else - ynh_add_config --template="../conf/lstu.conf.template" --destination="$install_dir/lstu.conf" -fi +ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$install_dir/lstu.conf" #================================================= # INSTALL LSTU @@ -170,34 +92,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 -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring permissions..." - -# Everyone can access the app. -# The "main" permission is automatically created before the install script. -#REMOVEME? ynh_permission_update --permission="main" --add="visitors" - -#REMOVEME? if [ $is_public -eq 0 ] -then - # If the app is private, only the shortened URLs are publics. - if [ "$path" == "/" ]; then - # If the path is /, clear it to prevent any error with the regex. - path="" - fi - # Modify the domain to be used in a regex - domain_regex=$(echo "$domain" | sed 's@-@.@g') -#REMOVEME? ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path/login$","$domain_regex$path/logout$","$domain_regex$path/api$","$domain_regex$path/extensions$","$domain_regex$path/stats$","$domain_regex$path/d/.*$","$domain_regex$path/a$","$domain_regex$path/$" -fi - -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index e3f88dd..f49d8b3 100644 --- a/scripts/remove +++ b/scripts/remove @@ -9,19 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) - #================================================= # STANDARD REMOVE #================================================= @@ -51,22 +38,6 @@ ynh_script_progression --message="Removing logrotate configuration..." # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE THE POSTGRESQL DATABASE -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the PostgreSQL database..." - -# Remove a database if it exists, along with the associated user -#REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name - -#================================================= -# REMOVE APP MAIN DIR -#================================================= -#REMOVEME? ynh_script_progression --message="Removing app main directory..." - -# Remove the app directory securely -#REMOVEME? ynh_secure_remove --file="$install_dir" - #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -75,14 +46,6 @@ ynh_script_progression --message="Removing NGINX web server configuration..." # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Removing dependencies..." - -# Remove metapackage and its dependencies -#REMOVEME? ynh_remove_app_dependencies - #================================================= # SPECIFIC REMOVE #================================================= @@ -93,16 +56,6 @@ ynh_script_progression --message="Removing various files..." # Remove the log files ynh_secure_remove --file="/var/log/$app.log" -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." - -# Delete a system user -#REMOVEME? ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 3a83388..678c06b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,48 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." - -#REMOVEME? test ! -d $install_dir \ - || ynh_die --message="There is already a directory: $install_dir " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." - -# Create the dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -59,20 +17,9 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$install_dir" -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." - -# Define and install dependencies -#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= @@ -83,10 +30,8 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -#REMOVEME? ynh_script_progression --message="Restoring the PostregSQL database..." +ynh_script_progression --message="Restoring the PostregSQL database..." -#REMOVEME? ynh_psql_test_if_first_run -#REMOVEME? 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 #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index f68b950..089257e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,47 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? is_public=$(ynh_app_setting_get --app=$app --key=is_public) -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? secret=$(ynh_app_setting_get --app=$app --key=secret) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -#REMOVEME? theme=$(ynh_app_setting_get --app=$app theme) -#REMOVEME? 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 -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -64,62 +29,11 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= ynh_script_progression --message="Ensuring downward compatibility..." -# If install_dir doesn't exist, create it -if [ -z "$install_dir" ]; then -#REMOVEME? install_dir=/var/www/$app -#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir -fi - -if [ -z "$db_pwd" ]; then -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) # Fix old db_pwd - if [ -z "$db_pwd" ]; then -#REMOVEME? 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 -#REMOVEME? ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" -#REMOVEME? ynh_app_setting_set --app="$app" --key=db_name --value="$db_name" -#REMOVEME? #REMOVEME? 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 -#REMOVEME? 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" - -#REMOVEME? 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 -#================================================= -#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -129,20 +43,12 @@ then ynh_script_progression --message="Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$install_dir" #--keep="lstu.conf" + ynh_setup_source --dest_dir="$install_dir" --keep="lstu.conf" fi -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." - -#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - #================================================= # NGINX CONFIGURATION #================================================= @@ -156,14 +62,9 @@ ynh_add_nginx_config #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." +#ynh_script_progression --message="Updating a configuration file..." -#REMOVEME? if [ $is_public -eq 0 ]; -then - ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$install_dir/lstu.conf" -else - ynh_add_config --template="../conf/lstu.conf.template" --destination="$install_dir/lstu.conf" -fi +#ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$install_dir/lstu.conf" #================================================= # BUILD LSU @@ -206,34 +107,6 @@ 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 -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring permissions..." - -# Everyone can access the app. -# The "main" permission is automatically created before the install script. -#REMOVEME? ynh_permission_update --permission="main" --add="visitors" - -#REMOVEME? if [ $is_public -eq 0 ] -then - # If the app is private, only the shortened URLs are publics. - if [ "$path" == "/" ]; then - # If the path is /, clear it to prevent any error with the regex. - path="" - fi - # Modify the domain to be used in a regex - domain_regex=$(echo "$domain" | sed 's@-@.@g') -#REMOVEME? ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path/login$","$domain_regex$path/logout$","$domain_regex$path/api$","$domain_regex$path/extensions$","$domain_regex$path/stats$","$domain_regex$path/d/.*$","$domain_regex$path/a$","$domain_regex$path/$" -fi - -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..cbbeef1 --- /dev/null +++ b/tests.toml @@ -0,0 +1,3 @@ +test_format = 1.0 + +[default] From b97f13d63ab42cd6879999f6387cb15db1fbf254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 31 May 2023 21:09:16 +0200 Subject: [PATCH 06/15] Fix --- doc/{DISCLAIMER.md => ADMIN.md} | 0 doc/{DISCLAIMER_fr.md => ADMIN_fr.md} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename doc/{DISCLAIMER.md => ADMIN.md} (100%) rename doc/{DISCLAIMER_fr.md => ADMIN_fr.md} (100%) diff --git a/doc/DISCLAIMER.md b/doc/ADMIN.md similarity index 100% rename from doc/DISCLAIMER.md rename to doc/ADMIN.md diff --git a/doc/DISCLAIMER_fr.md b/doc/ADMIN_fr.md similarity index 100% rename from doc/DISCLAIMER_fr.md rename to doc/ADMIN_fr.md From d6f04cfb7bf06780ca2f1204c28c5226136b1ca4 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 31 May 2023 19:09:21 +0000 Subject: [PATCH 07/15] Auto-update README --- README.md | 6 ------ README_fr.md | 6 ------ 2 files changed, 12 deletions(-) diff --git a/README.md b/README.md index 24411a2..a29550c 100644 --- a/README.md +++ b/README.md @@ -27,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 4d471c5..e7bce38 100644 --- a/README_fr.md +++ b/README_fr.md @@ -27,12 +27,6 @@ Raccourcisseur d'URL ![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. - ## Documentations et ressources * Site officiel de l’app : From 6caadc7b919433002f750c46830e6c56d54a79f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 31 May 2023 21:16:10 +0200 Subject: [PATCH 08/15] fix --- doc/ADMIN.md | 4 +--- doc/ADMIN_fr.md | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/doc/ADMIN.md b/doc/ADMIN.md index 2d34b90..b7e1a48 100644 --- a/doc/ADMIN.md +++ b/doc/ADMIN.md @@ -1,3 +1 @@ -## Configuration - -How to configure this app: a plain file at `/var/www/lstu/lstu.conf` with SSH. +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 index 9c5d939..8093d80 100644 --- a/doc/ADMIN_fr.md +++ b/doc/ADMIN_fr.md @@ -1,3 +1 @@ -## Configuration - -Comment configurer cette application : un fichier simple à `/var/www/lstu/lstu.conf` avec SSH. +Comment configurer cette application : un fichier simple à `__INSTALL_DIR__/lstu.conf` avec SSH. From 8560e4bddd411f63a31d8f6a85f622ba73f071d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 31 May 2023 21:39:34 +0200 Subject: [PATCH 09/15] Update tests.toml --- tests.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests.toml b/tests.toml index cbbeef1..7e3cf40 100644 --- a/tests.toml +++ b/tests.toml @@ -1,3 +1,8 @@ test_format = 1.0 [default] + # ------------------------------- + # Default args to use for install + # ------------------------------- + + args.theme = "milligram" From d40100182668524242a171487fd0788a467a6bbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 1 Jun 2023 08:32:39 +0200 Subject: [PATCH 10/15] Update change_url --- scripts/change_url | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 6ef2cea..4db7ac8 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -35,12 +35,7 @@ ynh_script_progression --message="Updating a configuration file..." domain="$new_domain" path="$new_path" -#REMOVEME? if [ $is_public -eq 0 ]; -then - ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$install_dir/lstu.conf" -else - ynh_add_config --template="../conf/lstu.conf.template" --destination="$install_dir/lstu.conf" -fi +ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$install_dir/lstu.conf" #================================================= # GENERIC FINALISATION From 8f7d86771ead4a50dbe3b316c0c91eb170b739ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 1 Jun 2023 08:32:58 +0200 Subject: [PATCH 11/15] Update _common.sh --- scripts/_common.sh | 135 --------------------------------------------- 1 file changed, 135 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 03f3ceb..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -12,141 +12,6 @@ # 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 -#REMOVEME? 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
 #=================================================

From 5327dd4a083972bfdfecdada546ce8d5b3e0858b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?E=CC=81ric=20Gaspar?=
 <46165813+ericgaspar@users.noreply.github.com>
Date: Thu, 1 Jun 2023 08:37:45 +0200
Subject: [PATCH 12/15] fix

---
 scripts/install | 31 ++++++++-----------------------
 scripts/remove  | 22 ----------------------
 scripts/restore | 32 ++++++++++----------------------
 scripts/upgrade | 35 ++++-------------------------------
 4 files changed, 22 insertions(+), 98 deletions(-)

diff --git a/scripts/install b/scripts/install
index 6a194c2..075417f 100644
--- a/scripts/install
+++ b/scripts/install
@@ -43,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
 #=================================================
@@ -61,29 +69,6 @@ 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
 #=================================================
diff --git a/scripts/remove b/scripts/remove
index f49d8b3..86cee08 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -22,37 +22,15 @@ 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 NGINX CONFIGURATION
-#=================================================
-ynh_script_progression --message="Removing NGINX web server configuration..."
-
 # Remove the dedicated NGINX config
 ynh_remove_nginx_config
 
-#=================================================
-# SPECIFIC REMOVE
-#=================================================
-# REMOVE VARIOUS FILES
-#=================================================
-ynh_script_progression --message="Removing various files..."
-
 # Remove the log files
 ynh_secure_remove --file="/var/log/$app.log"
 
diff --git a/scripts/restore b/scripts/restore
index 678c06b..f9f2cd4 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -32,43 +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_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 089257e..0af045f 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -24,16 +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 [ -z "$theme" ]; then
-	theme="milligram"
-	ynh_app_setting_set --app=$app --key=theme --value=$theme
-fi
-
 #=================================================
 # DOWNLOAD, CHECK AND UNPACK SOURCE
 #=================================================
@@ -49,14 +39,6 @@ fi
 chmod -R o-rwx "$install_dir"
 chown -R $app:www-data "$install_dir"
 
-#=================================================
-# NGINX CONFIGURATION
-#=================================================
-ynh_script_progression --message="Upgrading NGINX web server configuration..."
-
-# Create a dedicated NGINX config
-ynh_add_nginx_config
-
 #=================================================
 # SPECIFIC UPGRADE
 #=================================================
@@ -80,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"
 
 #=================================================
@@ -105,7 +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"
+ynh_systemd_action --service_name=$app --action=reload --log_path="systemd" --line_match="Reloaded Shortened URLs service."
 
 #=================================================
 # END OF SCRIPT

From 9edc26d71ea16f0433dd878202a8263b5cd562c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?E=CC=81ric=20Gaspar?=
 <46165813+ericgaspar@users.noreply.github.com>
Date: Sun, 11 Jun 2023 18:46:42 +0200
Subject: [PATCH 13/15] cleaning

---
 check_process | 27 ---------------------------
 manifest.toml |  2 +-
 tests.toml    |  6 ++++++
 3 files changed, 7 insertions(+), 28 deletions(-)
 delete mode 100644 check_process

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/manifest.toml b/manifest.toml
index bea3cd0..24dda7b 100644
--- a/manifest.toml
+++ b/manifest.toml
@@ -17,7 +17,7 @@ admindoc = "https://framagit.org/fiat-tux/hat-softwares/lstu/wikis/home"
 code = "https://framagit.org/fiat-tux/hat-softwares/lstu"
 
 [integration]
-yunohost = ">= 11.1.19"
+yunohost = ">= 11.1.20"
 architectures = "all"
 multi_instance = true
 ldap = true
diff --git a/tests.toml b/tests.toml
index 7e3cf40..2bd5109 100644
--- a/tests.toml
+++ b/tests.toml
@@ -6,3 +6,9 @@ test_format = 1.0
     # -------------------------------
 
 	args.theme = "milligram"
+
+    # -------------------------------
+    # Commits to test upgrade from
+    # -------------------------------
+
+    test_upgrade_from.469fb267ebc496d2c63b10de35aaf3493ce8124f.name = "Upgrade from #52"

From d7f6817b73337204e8257364188c58ddcc753018 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?E=CC=81ric=20Gaspar?=
 <46165813+ericgaspar@users.noreply.github.com>
Date: Sun, 11 Jun 2023 20:09:11 +0200
Subject: [PATCH 14/15] fix

---
 manifest.toml | 2 +-
 tests.toml    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/manifest.toml b/manifest.toml
index 24dda7b..98471d5 100644
--- a/manifest.toml
+++ b/manifest.toml
@@ -5,7 +5,7 @@ name = "Lstu"
 description.en = "URL Shortener"
 description.fr = "Raccourcisseur d'URL"
 
-version = "0.26.0~ynh2"
+version = "0.26.0~ynh3"
 
 maintainers = ["frju365"]
 
diff --git a/tests.toml b/tests.toml
index 2bd5109..fbc133d 100644
--- a/tests.toml
+++ b/tests.toml
@@ -11,4 +11,4 @@ test_format = 1.0
     # Commits to test upgrade from
     # -------------------------------
 
-    test_upgrade_from.469fb267ebc496d2c63b10de35aaf3493ce8124f.name = "Upgrade from #52"
+    test_upgrade_from.af9f0258204e71bc567206ef2dc00d151319fa21.name = "Upgrade from 0.26.0~ynh2"

From 52a22717ad4f95ce0dd25c0a93b1199f747c3cef Mon Sep 17 00:00:00 2001
From: yunohost-bot 
Date: Sun, 11 Jun 2023 18:09:15 +0000
Subject: [PATCH 15/15] Auto-update README

---
 README.md    | 2 +-
 README_fr.md | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index a29550c..e4d1e9b 100644
--- a/README.md
+++ b/README.md
@@ -19,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
 
diff --git a/README_fr.md b/README_fr.md
index e7bce38..152939f 100644
--- a/README_fr.md
+++ b/README_fr.md
@@ -19,7 +19,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
 Raccourcisseur d'URL
 
 
-**Version incluse :** 0.26.0~ynh2
+**Version incluse :** 0.26.0~ynh3
 
 **Démo :** https://lstu.fr