diff --git a/README.md b/README.md index 9c674c6..7d87946 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ How to configure this app: by an admin panel. ## Documentation * Official documentation: https://thelounge.chat/docs - * YunoHost documentation: https://yunohost.org/#/app_thelounge + * YunoHost documentation: https://yunohost.org/en/app_thelounge ## YunoHost specific features diff --git a/README_fr.md b/README_fr.md index c717791..279c2e2 100644 --- a/README_fr.md +++ b/README_fr.md @@ -28,7 +28,7 @@ Comment configurer cette application : via le panneau d’administration. ## Documentation * Documentation officielle : https://thelounge.chat/docs - * Documentation YunoHost : https://yunohost.org/#/app_thelounge_fr + * Documentation YunoHost : https://yunohost.org/fr/app_thelounge ## Caractéristiques spécifiques YunoHost diff --git a/check_process b/check_process index d5c5b3e..946bdf9 100644 --- a/check_process +++ b/check_process @@ -21,7 +21,6 @@ upgrade=1 from_commit=bd00c8e3ce43563f33fde073cf36b997c348d05c backup_restore=1 multi_instance=0 - port_already_use=0 change_url=1 ;;; Options Email= diff --git a/manifest.json b/manifest.json index 054b760..0e8f148 100644 --- a/manifest.json +++ b/manifest.json @@ -19,7 +19,7 @@ "email": "beudbeud@beudibox.fr" }, "requirements": { - "yunohost": ">= 3.8.1" + "yunohost": ">= 4.1.7" }, "multi_instance": false, "services": [ @@ -31,29 +31,17 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain name for The Lounge", - "fr": "Choisissez un nom de domaine pour The Lounge" - }, "example": "example.com" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for The Lounge", - "fr": "Choisissez un chemin pour The Lounge" - }, "example": "/irc", "default": "/irc" }, { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?" - }, "default": true } ] diff --git a/pull_request_template.md b/pull_request_template.md index f44dbc6..6c28fc5 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -13,6 +13,4 @@ ## Package_check results --- -*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* - -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/thelounge_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/thelounge_ynh%20PR-NUM-%20(USERNAME)/) +* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"* diff --git a/scripts/backup b/scripts/backup index 3aa23aa..073460e 100644 --- a/scripts/backup +++ b/scripts/backup @@ -23,8 +23,8 @@ ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) -config_path=$(ynh_app_setting_get --app=$app --key=config_path) domain=$(ynh_app_setting_get --app=$app --key=domain) +config_path=$(ynh_app_setting_get --app=$app --key=config_path) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP diff --git a/scripts/change_url b/scripts/change_url index 6375a95..9273ac3 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -30,6 +30,23 @@ ynh_script_progression --message="Loading installation settings..." final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= @@ -92,7 +109,7 @@ fi 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="Available at http" +ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Available at http" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index dbaa8c6..28cd8db 100644 --- a/scripts/install +++ b/scripts/install @@ -45,9 +45,8 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= ynh_script_progression --message="Storing installation settings..." -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=is_public --value=$is_public +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=config_path --value=$config_path #================================================= @@ -72,6 +71,14 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +#================================================= +# 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 #================================================= @@ -89,14 +96,6 @@ ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$app - #================================================= # SPECIFIC SETUP #================================================= @@ -104,14 +103,9 @@ ynh_system_user_create --username=$app #================================================= ynh_script_progression --message="Modifying a config file..." -mkdir -p $config_path +mkdir -p /home/yunohost.app/$app -# Main config File -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.js" - -cp -a ../conf/config.js "$config_path" - -ynh_store_file_checksum "$config_path/config.js" +ynh_add_config --template="../conf/config.js" --destination="$config_path/config.js" #================================================= # INSTALL THE LOUNGE @@ -129,10 +123,8 @@ popd #================================================= ynh_script_progression --message="Configuring a systemd service..." -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" ynh_add_systemd_config @@ -160,15 +152,15 @@ yunohost service add $app --description="Client Web IRC" --log="/var/log/$app/$a 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="Available at http" +ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Available at http" #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." +ynh_script_progression --message="Configuring permissions..." # Make app public if necessary or protect it -[ $is_public -eq 0 ] || ynh_permission_update --permission "main" --add "visitors" +[ $is_public -eq 0 ] || ynh_permission_update --permission="main" --add="visitors" #================================================= # RELOAD NGINX diff --git a/scripts/restore b/scripts/restore index 00611d4..8d34e05 100644 --- a/scripts/restore +++ b/scripts/restore @@ -50,6 +50,14 @@ ynh_script_progression --message="Restoring the NGINX configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -64,14 +72,6 @@ ynh_script_progression --message="Restoring the config path..." ynh_restore_file --origin_path="$config_path" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # RESTORE USER RIGHTS #================================================= @@ -114,7 +114,7 @@ yunohost service add $app --description="Client Web IRC" --log="/var/log/$app/$a #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Available at http" +ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Available at http" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 9ec59bc..0865c5c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,7 +18,6 @@ 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) final_path=$(ynh_app_setting_get --app=$app --key=final_path) config_path=$(ynh_app_setting_get --app=$app --key=config_path) port=$(ynh_app_setting_get --app=$app --key=port) @@ -35,15 +34,6 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 -fi - # If final_path doesn't exist, create it if [ -z "$final_path" ]; then final_path=/var/www/$app @@ -53,9 +43,17 @@ fi # If config_path doesn't exist, create it if [ -z "$config_path" ]; then config_path=/home/yunohost.app/$app + mkdir -p /home/yunohost.app/$app ynh_app_setting_set --app=$app --key=config_path --value=$config_path 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 #================================================= @@ -78,7 +76,15 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" +ynh_systemd_action --service_name=$app --action=stop --log_path=systemd + +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -113,14 +119,6 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # SPECIFIC UPGRADE #================================================= @@ -142,22 +140,15 @@ fi #================================================= ynh_script_progression --message="Modifying a config file..." -ynh_backup_if_checksum_is_different --file="$config_path" -# Main config File -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.js" - -cp -a ../conf/config.js "$config_path" -ynh_store_file_checksum "$config_path/config.js" +ynh_add_config --template="../conf/config.js" --destination="$config_path/config.js" #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression --message="Upgrading systemd configuration..." -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" ynh_add_systemd_config @@ -186,7 +177,7 @@ yunohost service add $app --description="Client Web IRC" --log="/var/log/$app/$a #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Available at http" +ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Available at http" #================================================= # RELOAD NGINX