diff --git a/README.md b/README.md index a947789..3e93ac5 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ 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) ![](https://ci-apps.yunohost.org/ci/badges/lstu.status.svg) ![](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)* @@ -17,13 +17,13 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in URL Shortener -**Shipped version:** 0.25.0~ynh1 +**Shipped version:** 0.26.0~ynh1 **Demo:** https://lstu.fr ## Screenshots -![](./doc/screenshots/LSTU_screenshot.png) +![Screenshot of Lstu](./doc/screenshots/LSTU_screenshot.png) ## Disclaimers / important information @@ -33,21 +33,22 @@ How to configure this app: a plain file at `/var/www/lstu/lstu.conf` with SSH. ## Documentation and resources -* Official app website: https://lstu.fr -* Official admin documentation: https://framagit.org/fiat-tux/hat-softwares/lstu/wikis/home -* Upstream app code repository: https://framagit.org/fiat-tux/hat-softwares/lstu -* YunoHost documentation for this app: https://yunohost.org/app_lstu -* Report a bug: https://github.com/YunoHost-Apps/lstu_ynh/issues +* Official app website: +* Official admin documentation: +* Upstream app code repository: +* YunoHost documentation for this app: +* Report a bug: ## Developer info Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/lstu_ynh/tree/testing). To try the testing branch, please proceed like that. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/lstu_ynh/tree/testing --debug or sudo yunohost app upgrade lstu -u https://github.com/YunoHost-Apps/lstu_ynh/tree/testing --debug ``` -**More info regarding app packaging:** https://yunohost.org/packaging_apps \ No newline at end of file +**More info regarding app packaging:** diff --git a/README_fr.md b/README_fr.md index 9b38095..c2de48e 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,10 +1,14 @@ + + # Lstu pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/lstu.svg)](https://dash.yunohost.org/appci/app/lstu) ![](https://ci-apps.yunohost.org/ci/badges/lstu.status.svg) ![](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)* -*[Lire ce readme en français.](./README_fr.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.* @@ -13,13 +17,13 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Raccourcisseur d'URL -**Version incluse :** 0.25.0~ynh1 +**Version incluse :** 0.26.0~ynh1 **Démo :** https://lstu.fr ## Captures d'écran -![](./doc/screenshots/LSTU_screenshot.png) +![Capture d'écran de Lstu](./doc/screenshots/LSTU_screenshot.png) ## Avertissements / informations importantes @@ -29,21 +33,22 @@ Comment configurer cette application : un fichier simple à `/var/www/lstu/lstu. ## Documentations et ressources -* Site officiel de l'app : https://lstu.fr -* Documentation officielle de l'admin : https://framagit.org/fiat-tux/hat-softwares/lstu/wikis/home -* Dépôt de code officiel de l'app : https://framagit.org/fiat-tux/hat-softwares/lstu -* Documentation YunoHost pour cette app : https://yunohost.org/app_lstu -* Signaler un bug : https://github.com/YunoHost-Apps/lstu_ynh/issues +* Site officiel de l'app : +* Documentation officielle de l'admin : +* Dépôt de code officiel de l'app : +* Documentation YunoHost pour cette app : +* Signaler un bug : ## Informations pour les développeurs Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/lstu_ynh/tree/testing). Pour essayer la branche testing, procédez comme suit. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/lstu_ynh/tree/testing --debug 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 :** https://yunohost.org/packaging_apps \ No newline at end of file +**Plus d'infos sur le packaging d'applications :** diff --git a/check_process b/check_process index 63e98a0..792949a 100644 --- a/check_process +++ b/check_process @@ -1,11 +1,10 @@ -;; Nom du test - auto_remove=1 +;; Test complet ; Manifest domain="domain.tld" path="/path" is_public=1 theme="milligram" - password="verysecretpassword" + password="1Strong-Password" ; Checks pkg_linter=1 setup_sub_dir=1 @@ -15,10 +14,14 @@ setup_public=1 upgrade=1 #Merge pull request #52 - upgrade=1 from_commit=469fb267ebc496d2c63b10de35aaf3493ce8124f + upgrade=1 from_commit=469fb267ebc496d2c63b10de35aaf3493ce8124f backup_restore=1 multi_instance=1 + port_already_use=0 change_url=1 +;;; Options +Email= +Notification=none ;;; Upgrade options ; commit=469fb267ebc496d2c63b10de35aaf3493ce8124f name=Merge pull request #52 diff --git a/conf/app.src b/conf/app.src index c943df8..67c9576 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,7 @@ -SOURCE_URL=https://framagit.org/fiat-tux/hat-softwares/lstu/-/archive/0.25-0/lstu-0.25-0.tar.gz -SOURCE_SUM=eae4bc13ef761996a13c8133647dce14e040a67173b099b630ef35dba3b19209 +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/lstu.conf.ldap b/conf/lstu.conf.ldap index 2aac266..7101f59 100644 --- a/conf/lstu.conf.ldap +++ b/conf/lstu.conf.ldap @@ -14,11 +14,11 @@ # put a way to contact you here and uncomment it # MANDATORY - contact => 'webmaster@__DOMAIN__', + contact => 'webmaster@__DOMAIN__', # array of random strings used to encrypt cookies # optional, default is ['fdjsofjoihrei'], PLEASE, CHANGE IT - secrets => ['__SECRET__'], + secrets => ['__SECRET__'], # secret passphrase to access some admin features # If you don't want to have a plain text password in configuration, @@ -31,6 +31,11 @@ # optional, but you won't have access to admin /stats if not set and if adminpwd is not set either hashed_adminpwd => '__HASHED_PASSWORD__', + # indicates if you want to really delete URLs from admin page (/stats) + # or just want to deactivate the shorten URL (won’t redirect anymore, can’t be used anymore) + # optional, default to 0 (false) + #really_delete_urls => 0, + # choose a theme. See the available themes in `themes` directory # optional, default is 'default' theme => '__THEME__', # default or milligram @@ -66,6 +71,10 @@ # optional #fixed_domain => 'example.org', + # if set to 1, Lstu will try to prevent its use without using the web interface + # optional, default is 0 + #disable_api => 0, + # choose what database you want to use # valid choices are sqlite, postgresql and mysql (all lowercase) # optional, default is sqlite @@ -264,5 +273,9 @@ # Set to 1 if you want to register the IP addresses of URL creators # optional, default is 0 #log_creator_ip => 0, -}; + # Positive integer which specifies how many pixels one "module" (one block of the QR code) occupies. + # You can't use fractional values. An arbitrary upper limit of 100 is imposed by Image::PNG::QRCode module. + # optional, default is 3 + #qrcode_size => 3, +}; diff --git a/conf/lstu.conf.template b/conf/lstu.conf.template index 0ba8420..c026a72 100644 --- a/conf/lstu.conf.template +++ b/conf/lstu.conf.template @@ -14,11 +14,11 @@ # put a way to contact you here and uncomment it # MANDATORY - contact => 'webmaster@__DOMAIN__', + contact => 'webmaster@__DOMAIN__', # array of random strings used to encrypt cookies # optional, default is ['fdjsofjoihrei'], PLEASE, CHANGE IT - secrets => ['__SECRET__'], + secrets => ['__SECRET__'], # secret passphrase to access some admin features # If you don't want to have a plain text password in configuration, @@ -273,5 +273,9 @@ # Set to 1 if you want to register the IP addresses of URL creators # optional, default is 0 #log_creator_ip => 0, -}; + # Positive integer which specifies how many pixels one "module" (one block of the QR code) occupies. + # You can't use fractional values. An arbitrary upper limit of 100 is imposed by Image::PNG::QRCode module. + # optional, default is 3 + #qrcode_size => 3, +}; diff --git a/conf/nginx.conf b/conf/nginx.conf index 85b19c1..4939bf4 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,20 +1,20 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - access_log /var/log/nginx/lstu.access.log; - error_log /var/log/nginx/lstu.error.log; + access_log /var/log/nginx/lstu.access.log; + error_log /var/log/nginx/lstu.error.log; - proxy_pass http://127.0.0.1:__PORT__; + proxy_pass http://127.0.0.1:__PORT__; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Remote-Port $remote_port; - proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Remote-Port $remote_port; + proxy_set_header X-Forwarded-Proto $scheme; - # We expect the downsteam servers to redirect to the right hostname, so don't do any rewrite$ - proxy_redirect off; + # We expect the downsteam servers to redirect to the right hostname, so don't do any rewrite$ + proxy_redirect off; - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; } diff --git a/manifest.json b/manifest.json index 971f66a..a37b077 100644 --- a/manifest.json +++ b/manifest.json @@ -1,63 +1,63 @@ { - "name": "Lstu", - "id": "lstu", - "packaging_format": 1, - "description": { - "en": "URL Shortener", - "fr": "Raccourcisseur d'URL" - }, - "version": "0.25.0~ynh1", - "url": "https://lstu.fr", - "upstream": { + "name": "Lstu", + "id": "lstu", + "packaging_format": 1, + "description": { + "en": "URL Shortener", + "fr": "Raccourcisseur d'URL" + }, + "version": "0.26.0~ynh1", + "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": { + "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" - } - ] - } + }, + "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/scripts/_common.sh b/scripts/_common.sh index 1effe6e..330f35d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -149,3 +149,7 @@ __PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/service # Send the email to the recipients cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients" } + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/actions/public_private b/scripts/actions/public_private index 4091fa5..97a6ba7 100755 --- a/scripts/actions/public_private +++ b/scripts/actions/public_private @@ -67,8 +67,8 @@ 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="" + # 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') diff --git a/scripts/backup b/scripts/backup index 63ca8f7..37a5e95 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -34,7 +34,6 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= - ynh_print_info --message="Declaring files to be backed up..." #================================================= diff --git a/scripts/change_url b/scripts/change_url index 1b2ae87..569a0d8 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -40,17 +40,18 @@ theme=$(ynh_app_setting_get --app=$app --key=theme) hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password) #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + ynh_clean_check_starting # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -88,19 +89,19 @@ ynh_script_progression --message="Updating NGINX web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -# Change the path in the nginx config file +# Change the path in the NGINX config file if [ $change_path -eq 1 ] then - # Make a backup of the original nginx config file if modified + # Make a backup of the original NGINX config file if modified ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for nginx helper + # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" - # Create a dedicated nginx config + # Create a dedicated NGINX config ynh_add_nginx_config fi -# Change the domain for nginx +# Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location @@ -113,32 +114,19 @@ fi #================================================= # SPECIFIC MODIFICATIONS #================================================= -# CONFIGURE LSTU +# UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Configuring lstu..." +ynh_script_progression --message="Updating a configuration file..." domain="$new_domain" path_url="$new_path" -config="${final_path}/lstu.conf" -ynh_backup_if_checksum_is_different --file="$config" -cp ../conf/lstu.conf.template "$config" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config" -ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config" -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config" -ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config" -ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config" -ynh_replace_string --match_string="__SELECTED_THEME__" --replace_string="$theme" --target_file="$config" -ynh_replace_string --match_string="__PASSWORD_HASHED__" --replace_string="$hashed_password" --target_file="$config" -ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config" if [ $is_public -eq 0 ]; then - ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="" --target_file="$config" + ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$final_path/lstu.conf" else - ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="#" --target_file="$config" + ynh_add_config --template="../conf/lstu.conf.template" --destination="$final_path/lstu.conf" fi -ynh_store_file_checksum --file="$config" #================================================= # UPDATE SSOWAT @@ -149,8 +137,8 @@ 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="" + # 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') diff --git a/scripts/install b/scripts/install index 57272de..d356330 100644 --- a/scripts/install +++ b/scripts/install @@ -28,11 +28,12 @@ path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC theme=$YNH_APP_ARG_THEME password=$YNH_APP_ARG_PASSWORD -secret=$(ynh_string_random --length=24) -hashed_password=$(echo -n $password | sha256sum | cut -d' ' -f1) 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 #================================================= @@ -74,6 +75,14 @@ ynh_script_progression --message="Installing dependencies..." ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # CREATE A POSTGRESQL DATABASE #================================================= @@ -86,14 +95,6 @@ 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 -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -118,9 +119,9 @@ ynh_add_nginx_config #================================================= # SPECIFIC SETUP #================================================= -# CONFIGURE LSTU +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Configuring Lstu..." +ynh_script_progression --message="Adding a configuration file..." if [ $is_public -eq 0 ]; then @@ -174,14 +175,16 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l #================================================= ynh_script_progression --message="Configuring permissions..." +# Everyone can access the app. +# The "main" permission is automatically created before the install script. ynh_permission_update --permission="main" --add="visitors" if [ $is_public -eq 0 ] then # If the app is private, only the shortened URLs are publics. if [ "$path_url" == "/" ]; then - # If the path is /, clear it to prevent any error with the regex. - path_url="" + # 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') diff --git a/scripts/remove b/scripts/remove index b50047e..9aa3392 100644 --- a/scripts/remove +++ b/scripts/remove @@ -28,10 +28,10 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) +# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null then - ynh_script_progression --message="Removing $app service..." + ynh_script_progression --message="Removing $app service integration..." yunohost service remove $app fi @@ -43,21 +43,21 @@ ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." + +# Remove the app-specific logrotate config +ynh_remove_logrotate + #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= ynh_script_progression --message="Removing the PostgreSQL database..." # Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name" - -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies +ynh_psql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE APP MAIN DIR @@ -72,23 +72,23 @@ ynh_secure_remove --file="$final_path" #================================================= ynh_script_progression --message="Removing NGINX web server configuration..." -# Remove the dedicated nginx config +# Remove the dedicated NGINX config ynh_remove_nginx_config #================================================= -# REMOVE LOGROTATE CONFIGURATION +# REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing logrotate configuration..." +ynh_script_progression --message="Removing dependencies..." -# Remove the app-specific logrotate config -ynh_remove_logrotate +# Remove metapackage and its dependencies +ynh_remove_app_dependencies #================================================= # SPECIFIC REMOVE #================================================= -# REMOVE LOG FILES +# REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing log 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 3b63ff4..f6cc83f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -23,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -44,13 +44,6 @@ test ! -d $final_path \ #================================================= # STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -80,6 +73,13 @@ ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= @@ -87,7 +87,7 @@ ynh_script_progression --message="Restoring the PostregSQL database..." ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" +ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name #================================================= # RESTORE SYSTEMD @@ -97,6 +97,13 @@ ynh_script_progression --message="Restoring the systemd configuration..." 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 #================================================= @@ -111,13 +118,6 @@ ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at" -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 03cc820..c08a1aa 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -35,6 +35,30 @@ ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + ynh_clean_check_starting + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# STANDARD UPGRADE STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." + +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -88,37 +112,6 @@ then ynh_exec_warn_less yunohost firewall disallow TCP $port fi -# Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - ynh_clean_check_starting - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# STANDARD UPGRADE STEPS -#================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." - -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" - #================================================= # CREATE DEDICATED USER #================================================= @@ -143,14 +136,6 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." - -# Create a dedicated nginx config -ynh_add_nginx_config - #================================================= # UPGRADE DEPENDENCIES #================================================= @@ -159,9 +144,19 @@ ynh_script_progression --message="Upgrading dependencies..." ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= -# CONFIGURE LSTU +# NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring Lstu..." +ynh_script_progression --message="Upgrading NGINX web server configuration..." + +# Create a dedicated NGINX config +ynh_add_nginx_config + +#================================================= +# SPECIFIC UPGRADE +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a configuration file..." if [ $is_public -eq 0 ]; then @@ -179,14 +174,6 @@ pushd $final_path carton install --deployment --without=sqlite --without=mysql popd -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - #================================================= # SETUP SYSTEMD #================================================= @@ -195,6 +182,16 @@ ynh_script_progression --message="Upgrading systemd configuration..." # 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 #================================================= @@ -202,32 +199,34 @@ 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=reload --line_match="Reloaded Shortened URLs service." --log_path="systemd" + #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." +ynh_script_progression --message="Configuring permissions..." +# Everyone can access the app. +# The "main" permission is automatically created before the install script. ynh_permission_update --permission="main" --add="visitors" if [ $is_public -eq 0 ] then # If the app is private, only the shortened URLs are publics. if [ "$path_url" == "/" ]; then - # If the path is /, clear it to prevent any error with the regex. - path_url="" + # If the path is /, clear it to prevent any error with the regex. + path_url="" fi # Modify the domain to be used in a regex domain_regex=$(echo "$domain" | sed 's@-@.@g') ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$" fi -#================================================= -# START SYSTEMD SERVICE -#================================================= -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" - #================================================= # RELOAD NGINX #=================================================