From 29eedd66a6186ee777dd63e975a5452ed0fe6da6 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 11 Jun 2023 16:30:16 +0000 Subject: [PATCH 01/14] Auto-update README --- README.md | 19 ++++++++++--------- README_fr.md | 31 ++++++++++++++++++------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 517a290..0e328db 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ It shall NOT be edited by hand. # Linux-Dash for YunoHost -[![Integration level](https://dash.yunohost.org/integration/linuxdash.svg)](https://dash.yunohost.org/appci/app/linuxdash) ![](https://ci-apps.yunohost.org/ci/badges/linuxdash.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/linuxdash.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/linuxdash.svg)](https://dash.yunohost.org/appci/app/linuxdash) ![Working status](https://ci-apps.yunohost.org/ci/badges/linuxdash.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/linuxdash.maintain.svg) + [![Install Linux-Dash with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=linuxdash) *[Lire ce readme en français.](./README_fr.md)* @@ -21,24 +22,24 @@ A beautiful web dashboard for GNU/Linux which display CPU, RAM, memory, network **Shipped version:** 2.0~ynh3 **Demo:** https://afaqurk.github.io/linux-dash/ - ## Documentation and resources -* Official app website: https://github.com/afaqurk/linux-dash -* Official admin documentation: https://github.com/afaqurk/linux-dash/wiki -* Upstream app code repository: https://github.com/afaqurk/linux-dash -* YunoHost documentation for this app: https://yunohost.org/app_linuxdash -* Report a bug: https://github.com/YunoHost-Apps/linuxdash_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/linuxdash_ynh/tree/testing). To try the testing branch, please proceed like that. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/linuxdash_ynh/tree/testing --debug or sudo yunohost app upgrade linuxdash -u https://github.com/YunoHost-Apps/linuxdash_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 aab5823..0fcb923 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,15 +1,20 @@ + + # Linux-Dash pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/linuxdash.svg)](https://dash.yunohost.org/appci/app/linuxdash) ![](https://ci-apps.yunohost.org/ci/badges/linuxdash.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/linuxdash.maintain.svg) +[![Niveau d’intégration](https://dash.yunohost.org/integration/linuxdash.svg)](https://dash.yunohost.org/appci/app/linuxdash) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/linuxdash.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/linuxdash.maintain.svg) + [![Installer Linux-Dash avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=linuxdash) *[Read this readme in english.](./README.md)* -*[Lire ce readme en français.](./README_fr.md)* -> *Ce package vous permet d'installer Linux-Dash 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 Linux-Dash 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 A beautiful web dashboard for GNU/Linux which display CPU, RAM, memory, network and other usage. @@ -17,24 +22,24 @@ A beautiful web dashboard for GNU/Linux which display CPU, RAM, memory, network **Version incluse :** 2.0~ynh3 **Démo :** https://afaqurk.github.io/linux-dash/ - ## Documentations et ressources -* Site officiel de l'app : https://github.com/afaqurk/linux-dash -* Documentation officielle de l'admin : https://github.com/afaqurk/linux-dash/wiki -* Dépôt de code officiel de l'app : https://github.com/afaqurk/linux-dash -* Documentation YunoHost pour cette app : https://yunohost.org/app_linuxdash -* Signaler un bug : https://github.com/YunoHost-Apps/linuxdash_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/linuxdash_ynh/tree/testing). Pour essayer la branche testing, procédez comme suit. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/linuxdash_ynh/tree/testing --debug ou sudo yunohost app upgrade linuxdash -u https://github.com/YunoHost-Apps/linuxdash_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 :** \ No newline at end of file From 8abdb0ccda266bbeefacee304ad83c60eda55c18 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:30:58 +0200 Subject: [PATCH 02/14] v2 --- conf/app.src | 7 ----- conf/supervisor.service | 2 +- manifest.toml | 56 ++++++++++++++++++++++++++++++++++ scripts/_common.sh | 2 +- scripts/backup | 12 ++++---- scripts/change_url | 66 +++++++++++++++++++++-------------------- scripts/install | 64 +++++++++++++++++++-------------------- scripts/remove | 22 +++++++------- scripts/restore | 36 +++++++++++----------- scripts/upgrade | 48 +++++++++++++++--------------- 10 files changed, 183 insertions(+), 132 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 94f96d2..0000000 --- a/conf/app.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://codeload.github.com/afaqurk/linux-dash/tar.gz/186a802ea76e8bfcab7e8e7ebc533b74f80306fc -SOURCE_SUM=506ae346f69b2002d4e3494d6aaa92104dbc8e50c8740acb2c49bc592a5939ce -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/supervisor.service b/conf/supervisor.service index 76281de..ec6d1a6 100644 --- a/conf/supervisor.service +++ b/conf/supervisor.service @@ -1,5 +1,5 @@ [program:__APP__] -directory=__FINALPATH__/app/server/ +directory=__INSTALL_DIR__/app/server/ command=__YNH_NODE__ index.js --port __PORT__ autostart=true autorestart=true diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..42bf532 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,56 @@ +packaging_format = 2 + +id = "linuxdash" +name = "Linux-Dash" +description.en = "A drop-in, low-overhead monitoring web dashboard for GNU/linux machine." +description.fr = "Tableau de bord léger pour le monitoring d’un serveur GNU/linux." + +version = "2.0~ynh3" + +maintainers = ["Moul"] + +[upstream] +license = "MIT" +website = "https://github.com/afaqurk/linux-dash" +demo = "https://afaqurk.github.io/linux-dash/" +admindoc = "https://github.com/afaqurk/linux-dash/wiki" +code = "https://github.com/afaqurk/linux-dash" +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 = "/dash" + + [install.admin] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "user" + +[resources] + [resources.sources.main] + url = "https://codeload.github.com/afaqurk/linux-dash/tar.gz/186a802ea76e8bfcab7e8e7ebc533b74f80306fc" + sha256 = "506ae346f69b2002d4e3494d6aaa92104dbc8e50c8740acb2c49bc592a5939ce" + + + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh index 591bf13..f64154a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="supervisor" +#REMOVEME? pkg_dependencies="supervisor" nodejs_version=12 #================================================= diff --git a/scripts/backup b/scripts/backup index 0b4de3b..cd3ddf2 100755 --- a/scripts/backup +++ b/scripts/backup @@ -15,17 +15,17 @@ source /usr/share/yunohost/helpers #================================================= # 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) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -36,7 +36,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 be378cf..6405dda 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -13,57 +13,57 @@ 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) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # 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 #================================================= @@ -73,28 +73,30 @@ fi #================================================= 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 #================================================= @@ -102,9 +104,9 @@ 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? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 3997f17..37b5a75 100755 --- a/scripts/install +++ b/scripts/install @@ -14,81 +14,81 @@ 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 -admin=$YNH_APP_ARG_ADMIN +#REMOVEME? domain=$YNH_APP_ARG_DOMAIN +#REMOVEME? path=$YNH_APP_ARG_PATH +#REMOVEME? admin=$YNH_APP_ARG_ADMIN -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # 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 -ynh_app_setting_set --app=$app --key=admin --value=$admin +#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain +#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path +#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin #================================================= # 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_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= # 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" #================================================= # 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 @@ -105,14 +105,14 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Remobing Google..." -sed --in-place "/googlecode\|googleapis/d" "$final_path/index.html" +sed --in-place "/googlecode\|googleapis/d" "$install_dir/index.html" #================================================= # BUILD APP #================================================= ynh_script_progression --message="Building app..." -pushd "$final_path" +pushd "$install_dir" ynh_use_nodejs ynh_npm install --production popd @@ -145,17 +145,17 @@ ynh_supervisor_action --service_name=$app --action="start" --log_path="/var/log/ #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." +#REMOVEME? ynh_script_progression --message="Configuring permissions..." # Only the admin can access the admin panel of the app (if the app has an admin panel) -ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin +#REMOVEME? ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin #================================================= # 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 dfd1ca8..ef600ec 100755 --- a/scripts/remove +++ b/scripts/remove @@ -13,13 +13,13 @@ 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) -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? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) #================================================= # STANDARD REMOVE @@ -45,10 +45,10 @@ ynh_remove_supervisor_config #================================================= # 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 @@ -61,21 +61,21 @@ 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_nodejs -ynh_remove_app_dependencies +#REMOVEME? ynh_remove_app_dependencies #================================================= # GENERIC FINALIZATION #================================================= # 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 25c90fa..f523db0 100755 --- a/scripts/restore +++ b/scripts/restore @@ -15,30 +15,30 @@ 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) +#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) #================================================= # 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 @@ -52,31 +52,31 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # 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_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index f136a3e..8906ff5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -13,15 +13,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) -path_url=$(ynh_app_setting_get --app=$app --key=path) -admin=$(ynh_app_setting_get --app=$app --key=admin) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # CHECK VERSION @@ -33,17 +33,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 @@ -61,10 +61,10 @@ ynh_script_progression --message="Ensuring downward compatibility..." #================================================= # 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 @@ -75,12 +75,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="$final_path" + ynh_setup_source --dest_dir="$install_dir" 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" #================================================= # NGINX CONFIGURATION @@ -93,9 +93,9 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." +#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= @@ -104,14 +104,14 @@ ynh_install_nodejs --nodejs_version=$nodejs_version # REMOVE GOOGLE !!! #================================================= -sed --in-place "/googlecode\|googleapis/d" "$final_path/index.html" +sed --in-place "/googlecode\|googleapis/d" "$install_dir/index.html" #================================================= # BUILD APP #================================================= ynh_script_progression --message="Building app..." -pushd "$final_path" +pushd "$install_dir" ynh_use_nodejs ynh_npm install --production popd @@ -143,9 +143,9 @@ ynh_supervisor_action --service_name=$app --action="start" --log_path="/var/log/ #================================================= # 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 6d10ede6d82d65c4974a78c48b8cc6d6f141b03f Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 11 Jun 2023 16:31:03 +0000 Subject: [PATCH 03/14] Auto-update README --- README.md | 19 ++++++++++--------- README_fr.md | 31 ++++++++++++++++++------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 517a290..0e328db 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ It shall NOT be edited by hand. # Linux-Dash for YunoHost -[![Integration level](https://dash.yunohost.org/integration/linuxdash.svg)](https://dash.yunohost.org/appci/app/linuxdash) ![](https://ci-apps.yunohost.org/ci/badges/linuxdash.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/linuxdash.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/linuxdash.svg)](https://dash.yunohost.org/appci/app/linuxdash) ![Working status](https://ci-apps.yunohost.org/ci/badges/linuxdash.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/linuxdash.maintain.svg) + [![Install Linux-Dash with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=linuxdash) *[Lire ce readme en français.](./README_fr.md)* @@ -21,24 +22,24 @@ A beautiful web dashboard for GNU/Linux which display CPU, RAM, memory, network **Shipped version:** 2.0~ynh3 **Demo:** https://afaqurk.github.io/linux-dash/ - ## Documentation and resources -* Official app website: https://github.com/afaqurk/linux-dash -* Official admin documentation: https://github.com/afaqurk/linux-dash/wiki -* Upstream app code repository: https://github.com/afaqurk/linux-dash -* YunoHost documentation for this app: https://yunohost.org/app_linuxdash -* Report a bug: https://github.com/YunoHost-Apps/linuxdash_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/linuxdash_ynh/tree/testing). To try the testing branch, please proceed like that. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/linuxdash_ynh/tree/testing --debug or sudo yunohost app upgrade linuxdash -u https://github.com/YunoHost-Apps/linuxdash_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 aab5823..0fcb923 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,15 +1,20 @@ + + # Linux-Dash pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/linuxdash.svg)](https://dash.yunohost.org/appci/app/linuxdash) ![](https://ci-apps.yunohost.org/ci/badges/linuxdash.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/linuxdash.maintain.svg) +[![Niveau d’intégration](https://dash.yunohost.org/integration/linuxdash.svg)](https://dash.yunohost.org/appci/app/linuxdash) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/linuxdash.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/linuxdash.maintain.svg) + [![Installer Linux-Dash avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=linuxdash) *[Read this readme in english.](./README.md)* -*[Lire ce readme en français.](./README_fr.md)* -> *Ce package vous permet d'installer Linux-Dash 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 Linux-Dash 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 A beautiful web dashboard for GNU/Linux which display CPU, RAM, memory, network and other usage. @@ -17,24 +22,24 @@ A beautiful web dashboard for GNU/Linux which display CPU, RAM, memory, network **Version incluse :** 2.0~ynh3 **Démo :** https://afaqurk.github.io/linux-dash/ - ## Documentations et ressources -* Site officiel de l'app : https://github.com/afaqurk/linux-dash -* Documentation officielle de l'admin : https://github.com/afaqurk/linux-dash/wiki -* Dépôt de code officiel de l'app : https://github.com/afaqurk/linux-dash -* Documentation YunoHost pour cette app : https://yunohost.org/app_linuxdash -* Signaler un bug : https://github.com/YunoHost-Apps/linuxdash_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/linuxdash_ynh/tree/testing). Pour essayer la branche testing, procédez comme suit. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/linuxdash_ynh/tree/testing --debug ou sudo yunohost app upgrade linuxdash -u https://github.com/YunoHost-Apps/linuxdash_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 :** \ No newline at end of file From 135cc665527f6782563480e43329c16917c7ab19 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:39:46 +0200 Subject: [PATCH 04/14] v2 --- check_process | 22 ------ conf/nginx.conf | 4 +- manifest.json | 54 ------------- manifest.toml | 29 ++++--- scripts/_common.sh | 170 ++++++++++++++++++++++++++++++++++++++++- scripts/backup | 17 ----- scripts/change_url | 90 ---------------------- scripts/install | 80 +------------------ scripts/remove | 33 +------- scripts/restore | 58 ++------------ scripts/upgrade | 53 +------------ scripts/ynh_supervisor | 167 ---------------------------------------- tests.toml | 9 +++ 13 files changed, 204 insertions(+), 582 deletions(-) delete mode 100644 check_process delete mode 100644 manifest.json delete mode 100644 scripts/ynh_supervisor create mode 100644 tests.toml diff --git a/check_process b/check_process deleted file mode 100644 index c696543..0000000 --- a/check_process +++ /dev/null @@ -1,22 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/path" - admin="john" - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=0 - setup_public=0 - upgrade=1 - # 2.0~ynh2 - upgrade=1 from_commit=1319c98657f9b743cd345185aafc51c7a7da342f - backup_restore=1 - multi_instance=1 - port_already_use=0 - change_url=1 -;;; Options -Email= -Notification=none diff --git a/conf/nginx.conf b/conf/nginx.conf index 3fe2238..12fccee 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,8 +1,8 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - proxy_pass http://localhost:__PORT__/; - proxy_redirect off; + proxy_pass http://127.0.0.1:__PORT__/; + proxy_redirect off; proxy_hide_header Content-Type; # Include SSOWAT user panel. diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 342ea02..0000000 --- a/manifest.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "name": "Linux-Dash", - "id": "linuxdash", - "packaging_format": 1, - "description": { - "en": "A drop-in, low-overhead monitoring web dashboard for GNU/linux machine.", - "fr": "Tableau de bord léger pour le monitoring d’un serveur GNU/linux." - }, - "version": "2.0~ynh3", - "url": "https://github.com/afaqurk/linux-dash", - "upstream": { - "license": "MIT", - "website": "https://github.com/afaqurk/linux-dash", - "demo": "https://afaqurk.github.io/linux-dash/", - "admindoc": "https://github.com/afaqurk/linux-dash/wiki", - "code": "https://github.com/afaqurk/linux-dash" - }, - "license": "MIT", - "maintainer": { - "name": "Moul", - "email": "moul@moul.re", - "url": "https://moul.re" - }, - "requirements": { - "yunohost": ">= 4.3.0" - }, - "multi_instance": true, - "services": [ - "nginx" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/dash", - "default": "/dash" - }, - { - "name": "admin", - "type": "user", - "ask": { - "en": "Choose the YunoHost user which have access to Linux-Dash", - "fr": "Choisissez l’utilisateur YunoHost qui a accès à Linux-Dash" - }, - "example": "john" - } - ] - } -} diff --git a/manifest.toml b/manifest.toml index 42bf532..fca8862 100644 --- a/manifest.toml +++ b/manifest.toml @@ -2,8 +2,8 @@ packaging_format = 2 id = "linuxdash" name = "Linux-Dash" -description.en = "A drop-in, low-overhead monitoring web dashboard for GNU/linux machine." -description.fr = "Tableau de bord léger pour le monitoring d’un serveur GNU/linux." +description.en = "Monitoring web dashboard for GNU/linux machine" +description.fr = "Tableau de bord léger pour le monitoring d’un serveur GNU/linux" version = "2.0~ynh3" @@ -15,38 +15,34 @@ website = "https://github.com/afaqurk/linux-dash" demo = "https://afaqurk.github.io/linux-dash/" admindoc = "https://github.com/afaqurk/linux-dash/wiki" code = "https://github.com/afaqurk/linux-dash" -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 = false +sso = false +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 = "/dash" [install.admin] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "user" [resources] [resources.sources.main] - url = "https://codeload.github.com/afaqurk/linux-dash/tar.gz/186a802ea76e8bfcab7e8e7ebc533b74f80306fc" + url = "https://github.com/tariqbuilds/linux-dash/archive/186a802ea76e8bfcab7e8e7ebc533b74f80306fc.tar.gz" sha256 = "506ae346f69b2002d4e3494d6aaa92104dbc8e50c8740acb2c49bc592a5939ce" + [resources.ports] [resources.system_user] @@ -54,3 +50,6 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen [resources.permissions] main.url = "/" + + [resources.apt] + packages = "supervisor" diff --git a/scripts/_common.sh b/scripts/_common.sh index f64154a..810707c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,8 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -#REMOVEME? pkg_dependencies="supervisor" nodejs_version=12 #================================================= @@ -19,3 +17,171 @@ nodejs_version=12 #================================================= # FUTURE OFFICIAL HELPERS #================================================= + + +# Create a dedicated supervisor config +# +# usage: ynh_add_supervisor_config [--service=service] [--template=template] +# | arg: -s, --service= - Service name (optionnal, `$app` by default) +# | arg: -t, --template= - Name of template file (optionnal, this is 'supervisor' by default, meaning ./conf/supervisor.service will be used as template) +# +# This will use the template `../conf/.service`. +# +# See the documentation of `ynh_add_config` for a description of the template +# format and how placeholders are replaced with actual variables. +# +# Requires YunoHost version 2.7.11 or higher. +ynh_add_supervisor_config () { + # Declare an array to define the options of this helper. + local legacy_args=stv + local -A args_array=( [s]=service= [t]=template= [v]=others_var=) + local service + local template + local others_var + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + local service="${service:-$app}" + local template="${template:-supervisor.service}" + others_var="${others_var:-}" + + [[ -z "$others_var" ]] || ynh_print_warn --message="Packagers: using --others_var is unecessary since Yunohost 4.2" + + ynh_add_config --template="$YNH_APP_BASEDIR/conf/$template" --destination="/etc/supervisor/conf.d/$service.conf" + + supervisorctl reread + supervisorctl update +} + +# Remove the dedicated supervisor config +# +# usage: ynh_remove_supervisor_config [--service=service] +# | arg: -s, --service= - Service name (optionnal, $app by default) +# +# Requires YunoHost version 2.7.2 or higher. +ynh_remove_supervisor_config () { + # Declare an array to define the options of this helper. + local legacy_args=s + local -A args_array=( [s]=service= ) + local service + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + local service="${service:-$app}" + + local finalsupervisorconf="/etc/supervisor/conf.d/$service.conf" + if [ -e "$finalsupervisorconf" ] + then + ynh_supervisor_action --service_name=$service --action=stop + ynh_secure_remove --file="$finalsupervisorconf" + supervisorctl reread + supervisorctl update + fi +} + +# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started +# +# usage: ynh_supervisor_action [--service_name=service_name] [--action=action] [ [--line_match="line to match"] [--log_path=log_path] [--timeout=300] [--length=20] ] +# | arg: -n, --service_name= - Name of the service to start. Default : `$app` +# | arg: -a, --action= - Action to perform with supervisorctl. Default: start +# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. If not defined it don't wait until the service is completely started. +# | arg: -p, --log_path= - Log file - Path to the log file. Default : `/var/log/$app/$app.log` +# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds. +# | arg: -e, --length= - Length of the error log : Default : 20 +# +# Requires YunoHost version 3.5.0 or higher. +ynh_supervisor_action() { + # Declare an array to define the options of this helper. + local legacy_args=nalpte + declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= ) + local service_name + local action + local line_match + local length + local log_path + local timeout + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + service_name="${service_name:-$app}" + action=${action:-start} + line_match=${line_match:-} + length=${length:-20} + log_path="${log_path:-/var/log/$service_name/$service_name.log}" + timeout=${timeout:-300} + + # Start to read the log + if [[ -n "$line_match" ]] + then + local templog="$(mktemp)" + # Following the starting of the app in its log + if [ "$log_path" == "systemd" ] + then + # Read the supervisor journal + journalctl --unit=supervisor --follow --since=-0 --quiet > "$templog" & + # Get the PID of the journalctl command + local pid_tail=$! + else + # Read the specified log file + tail --follow=name --retry --lines=0 "$log_path" > "$templog" 2>&1 & + # Get the PID of the tail command + local pid_tail=$! + fi + fi + + # Use reload-or-restart instead of reload. So it wouldn't fail if the service isn't running. + if [ "$action" == "reload" ]; then + action="update" + fi + + # If the service fails to perform the action + if ! supervisorctl $action $service_name + then + # Show syslog for this service + ynh_exec_err journalctl --quiet --no-hostname --no-pager --lines=$length --unit=$service_name + # If a log is specified for this service, show also the content of this log + if [ -e "$log_path" ] + then + ynh_exec_err tail --lines=$length "$log_path" + fi + ynh_clean_check_starting + return 1 + fi + + # Start the timeout and try to find line_match + if [[ -n "${line_match:-}" ]] + then + set +x + local i=0 + for i in $(seq 1 $timeout) + do + # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout + if grep --extended-regexp --quiet "$line_match" "$templog" + then + ynh_print_info --message="The service $service_name has correctly executed the action ${action}." + break + fi + if [ $i -eq 3 ]; then + echo -n "Please wait, the service $service_name is ${action}ing" >&2 + fi + if [ $i -ge 3 ]; then + echo -n "." >&2 + fi + sleep 1 + done + set -x + if [ $i -ge 3 ]; then + echo "" >&2 + fi + if [ $i -eq $timeout ] + then + ynh_print_warn --message="The service $service_name didn't fully executed the action ${action} before the timeout." + ynh_print_warn --message="Please find here an extract of the end of the log of the service $service_name:" + ynh_exec_warn journalctl --quiet --no-hostname --no-pager --lines=$length --unit=$service_name + if [ -e "$log_path" ] + then + ynh_print_warn --message="\-\-\-" + ynh_exec_warn tail --lines=$length "$log_path" + fi + fi + ynh_clean_check_starting + fi +} + diff --git a/scripts/backup b/scripts/backup index cd3ddf2..b5ce173 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,23 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# 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) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= diff --git a/scripts/change_url b/scripts/change_url index 6405dda..690b1ba 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,63 +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) - -#================================================= -# 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 #================================================= @@ -75,39 +18,6 @@ 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 - -#================================================= -# GENERIC FINALISATION -#================================================= -# 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 37b5a75..ba92175 100755 --- a/scripts/install +++ b/scripts/install @@ -7,86 +7,23 @@ #================================================= source _common.sh -source ynh_supervisor 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? admin=$YNH_APP_ARG_ADMIN - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#================================================= -# 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..." - -#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain -#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path -#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin - -#================================================= -# 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..." +ynh_script_progression --message="Installing dependencies..." -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$nodejs_version -#================================================= -# 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" - #================================================= # 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" @@ -142,21 +79,6 @@ ynh_script_progression --message="Starting a systemd service..." # Start a systemd service ynh_supervisor_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -#================================================= -# SETUP SSOWAT -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring permissions..." - -# Only the admin can access the admin panel of the app (if the app has an admin panel) -#REMOVEME? ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin - -#================================================= -# 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 ef600ec..70d3576 100755 --- a/scripts/remove +++ b/scripts/remove @@ -7,20 +7,8 @@ #================================================= source _common.sh -source ynh_supervisor 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? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) - #================================================= # STANDARD REMOVE #================================================= @@ -42,14 +30,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_supervisor_config -#================================================= -# 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 #================================================= @@ -61,21 +41,10 @@ ynh_remove_nginx_config #================================================= # REMOVE DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Removing dependencies..." +ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_nodejs -#REMOVEME? ynh_remove_app_dependencies - -#================================================= -# 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 f523db0..0c5021e 100755 --- a/scripts/restore +++ b/scripts/restore @@ -8,55 +8,8 @@ # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh -source ../settings/scripts/ynh_supervisor 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) - -#================================================= -# 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 -#================================================= -# 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" - -#================================================= -# 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 #================================================= @@ -64,7 +17,6 @@ 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" @@ -73,12 +25,18 @@ chown -R $app:www-data "$install_dir" #================================================= # REINSTALL DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." +ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$nodejs_version +#================================================= +# 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 SYSTEMD #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 8906ff5..3d4c978 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,44 +7,14 @@ #================================================= source _common.sh -source ynh_supervisor 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? admin=$(ynh_app_setting_get --app=$app --key=admin) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) - #================================================= # 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 #================================================= @@ -54,18 +24,6 @@ ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." -#================================================= -# 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 #================================================= @@ -78,7 +36,6 @@ then ynh_setup_source --dest_dir="$install_dir" fi -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -93,9 +50,8 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." +ynh_script_progression --message="Upgrading dependencies..." -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= @@ -140,13 +96,6 @@ ynh_script_progression --message="Starting a systemd service..." ynh_supervisor_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -#================================================= -# 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/ynh_supervisor b/scripts/ynh_supervisor deleted file mode 100644 index 67bd2bd..0000000 --- a/scripts/ynh_supervisor +++ /dev/null @@ -1,167 +0,0 @@ -#!/bin/bash - -# Create a dedicated supervisor config -# -# usage: ynh_add_supervisor_config [--service=service] [--template=template] -# | arg: -s, --service= - Service name (optionnal, `$app` by default) -# | arg: -t, --template= - Name of template file (optionnal, this is 'supervisor' by default, meaning ./conf/supervisor.service will be used as template) -# -# This will use the template `../conf/.service`. -# -# See the documentation of `ynh_add_config` for a description of the template -# format and how placeholders are replaced with actual variables. -# -# Requires YunoHost version 2.7.11 or higher. -ynh_add_supervisor_config () { - # Declare an array to define the options of this helper. - local legacy_args=stv - local -A args_array=( [s]=service= [t]=template= [v]=others_var=) - local service - local template - local others_var - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - local service="${service:-$app}" - local template="${template:-supervisor.service}" - others_var="${others_var:-}" - - [[ -z "$others_var" ]] || ynh_print_warn --message="Packagers: using --others_var is unecessary since Yunohost 4.2" - - ynh_add_config --template="$YNH_APP_BASEDIR/conf/$template" --destination="/etc/supervisor/conf.d/$service.conf" - - supervisorctl reread - supervisorctl update -} - -# Remove the dedicated supervisor config -# -# usage: ynh_remove_supervisor_config [--service=service] -# | arg: -s, --service= - Service name (optionnal, $app by default) -# -# Requires YunoHost version 2.7.2 or higher. -ynh_remove_supervisor_config () { - # Declare an array to define the options of this helper. - local legacy_args=s - local -A args_array=( [s]=service= ) - local service - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - local service="${service:-$app}" - - local finalsupervisorconf="/etc/supervisor/conf.d/$service.conf" - if [ -e "$finalsupervisorconf" ] - then - ynh_supervisor_action --service_name=$service --action=stop - ynh_secure_remove --file="$finalsupervisorconf" - supervisorctl reread - supervisorctl update - fi -} - -# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started -# -# usage: ynh_supervisor_action [--service_name=service_name] [--action=action] [ [--line_match="line to match"] [--log_path=log_path] [--timeout=300] [--length=20] ] -# | arg: -n, --service_name= - Name of the service to start. Default : `$app` -# | arg: -a, --action= - Action to perform with supervisorctl. Default: start -# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. If not defined it don't wait until the service is completely started. -# | arg: -p, --log_path= - Log file - Path to the log file. Default : `/var/log/$app/$app.log` -# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds. -# | arg: -e, --length= - Length of the error log : Default : 20 -# -# Requires YunoHost version 3.5.0 or higher. -ynh_supervisor_action() { - # Declare an array to define the options of this helper. - local legacy_args=nalpte - declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= ) - local service_name - local action - local line_match - local length - local log_path - local timeout - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - service_name="${service_name:-$app}" - action=${action:-start} - line_match=${line_match:-} - length=${length:-20} - log_path="${log_path:-/var/log/$service_name/$service_name.log}" - timeout=${timeout:-300} - - # Start to read the log - if [[ -n "$line_match" ]] - then - local templog="$(mktemp)" - # Following the starting of the app in its log - if [ "$log_path" == "systemd" ] - then - # Read the supervisor journal - journalctl --unit=supervisor --follow --since=-0 --quiet > "$templog" & - # Get the PID of the journalctl command - local pid_tail=$! - else - # Read the specified log file - tail --follow=name --retry --lines=0 "$log_path" > "$templog" 2>&1 & - # Get the PID of the tail command - local pid_tail=$! - fi - fi - - # Use reload-or-restart instead of reload. So it wouldn't fail if the service isn't running. - if [ "$action" == "reload" ]; then - action="update" - fi - - # If the service fails to perform the action - if ! supervisorctl $action $service_name - then - # Show syslog for this service - ynh_exec_err journalctl --quiet --no-hostname --no-pager --lines=$length --unit=$service_name - # If a log is specified for this service, show also the content of this log - if [ -e "$log_path" ] - then - ynh_exec_err tail --lines=$length "$log_path" - fi - ynh_clean_check_starting - return 1 - fi - - # Start the timeout and try to find line_match - if [[ -n "${line_match:-}" ]] - then - set +x - local i=0 - for i in $(seq 1 $timeout) - do - # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout - if grep --extended-regexp --quiet "$line_match" "$templog" - then - ynh_print_info --message="The service $service_name has correctly executed the action ${action}." - break - fi - if [ $i -eq 3 ]; then - echo -n "Please wait, the service $service_name is ${action}ing" >&2 - fi - if [ $i -ge 3 ]; then - echo -n "." >&2 - fi - sleep 1 - done - set -x - if [ $i -ge 3 ]; then - echo "" >&2 - fi - if [ $i -eq $timeout ] - then - ynh_print_warn --message="The service $service_name didn't fully executed the action ${action} before the timeout." - ynh_print_warn --message="Please find here an extract of the end of the log of the service $service_name:" - ynh_exec_warn journalctl --quiet --no-hostname --no-pager --lines=$length --unit=$service_name - if [ -e "$log_path" ] - then - ynh_print_warn --message="\-\-\-" - ynh_exec_warn tail --lines=$length "$log_path" - fi - fi - ynh_clean_check_starting - fi -} diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..e16cf02 --- /dev/null +++ b/tests.toml @@ -0,0 +1,9 @@ +test_format = 1.0 + +[default] + + # ------------------------------- + # Commits to test upgrade from + # ------------------------------- + + test_upgrade_from.1319c98657f9b743cd345185aafc51c7a7da342f.name = "Upgrade from 2.0~ynh2" From 5d093096a33dcce9f290a54a0085d4e2cc19271e 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:40:46 +0200 Subject: [PATCH 05/14] Update manifest.toml --- manifest.toml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/manifest.toml b/manifest.toml index fca8862..7dd5689 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,19 +5,18 @@ name = "Linux-Dash" description.en = "Monitoring web dashboard for GNU/linux machine" description.fr = "Tableau de bord léger pour le monitoring d’un serveur GNU/linux" -version = "2.0~ynh3" +version = "2.0~ynh4" maintainers = ["Moul"] [upstream] license = "MIT" -website = "https://github.com/afaqurk/linux-dash" demo = "https://afaqurk.github.io/linux-dash/" admindoc = "https://github.com/afaqurk/linux-dash/wiki" code = "https://github.com/afaqurk/linux-dash" [integration] -yunohost = ">= 11.1.19" +yunohost = ">= 11.1.20" architectures = "all" multi_instance = true ldap = false @@ -41,6 +40,8 @@ ram.runtime = "50M" [resources.sources.main] url = "https://github.com/tariqbuilds/linux-dash/archive/186a802ea76e8bfcab7e8e7ebc533b74f80306fc.tar.gz" sha256 = "506ae346f69b2002d4e3494d6aaa92104dbc8e50c8740acb2c49bc592a5939ce" + autoupdate.upstream = "https://github.com/tariqbuilds/linux-dash" + autoupdate.strategy = "latest_github_commit" [resources.ports] From 978ed21e38a347cb4fc69507932c508924128e5c Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 11 Jun 2023 16:40:51 +0000 Subject: [PATCH 06/14] Auto-update README --- README.md | 3 +-- README_fr.md | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0e328db..d4deeb9 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,11 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in A beautiful web dashboard for GNU/Linux which display CPU, RAM, memory, network and other usage. -**Shipped version:** 2.0~ynh3 +**Shipped version:** 2.0~ynh4 **Demo:** https://afaqurk.github.io/linux-dash/ ## Documentation and resources -* Official app website: * Official admin documentation: * Upstream app code repository: * YunoHost documentation for this app: diff --git a/README_fr.md b/README_fr.md index 0fcb923..a483f0d 100644 --- a/README_fr.md +++ b/README_fr.md @@ -19,12 +19,11 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po A beautiful web dashboard for GNU/Linux which display CPU, RAM, memory, network and other usage. -**Version incluse :** 2.0~ynh3 +**Version incluse :** 2.0~ynh4 **Démo :** https://afaqurk.github.io/linux-dash/ ## Documentations et ressources -* Site officiel de l’app : * Documentation officielle de l’admin : * Dépôt de code officiel de l’app : * Documentation YunoHost pour cette app : From aed83920f3905bf8e18f7f4f6be54f139688dab4 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 19:10:07 +0200 Subject: [PATCH 07/14] fix --- doc/DISCLAIMER.md | 0 scripts/_common.sh | 2 +- scripts/install | 2 +- scripts/upgrade | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 doc/DISCLAIMER.md diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index e69de29..0000000 diff --git a/scripts/_common.sh b/scripts/_common.sh index 810707c..2c7f5c0 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -44,7 +44,7 @@ ynh_add_supervisor_config () { local template="${template:-supervisor.service}" others_var="${others_var:-}" - [[ -z "$others_var" ]] || ynh_print_warn --message="Packagers: using --others_var is unecessary since Yunohost 4.2" + [[ -z "$others_var" ]] || ynh_print_warn --message="Packagers: using others var is unecessary since Yunohost 4.2" ynh_add_config --template="$YNH_APP_BASEDIR/conf/$template" --destination="/etc/supervisor/conf.d/$service.conf" diff --git a/scripts/install b/scripts/install index ba92175..e2d1e59 100755 --- a/scripts/install +++ b/scripts/install @@ -51,7 +51,7 @@ ynh_script_progression --message="Building app..." pushd "$install_dir" ynh_use_nodejs - ynh_npm install --production + ynh_exec_warn_less ynh_npm install --production popd #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 3d4c978..84eaf41 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -69,7 +69,7 @@ ynh_script_progression --message="Building app..." pushd "$install_dir" ynh_use_nodejs - ynh_npm install --production + ynh_exec_warn_less ynh_npm install --production popd #================================================= From e5de2dd874671849842aacf367eb4c40b69d98d1 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:02:30 +0200 Subject: [PATCH 08/14] fix --- scripts/_common.sh | 2 +- scripts/install | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 2c7f5c0..ba61ced 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,7 +4,7 @@ # COMMON VARIABLES #================================================= -nodejs_version=12 +nodejs_version=18 #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index e2d1e59..179e98f 100755 --- a/scripts/install +++ b/scripts/install @@ -51,7 +51,8 @@ ynh_script_progression --message="Building app..." pushd "$install_dir" ynh_use_nodejs - ynh_exec_warn_less ynh_npm install --production + #ynh_exec_warn_less ynh_npm install --production + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --production popd #================================================= From ae6c7e34c45edf28c5881e6bac183f9c83166606 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:13:03 +0200 Subject: [PATCH 09/14] fix --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 179e98f..dbf19ab 100755 --- a/scripts/install +++ b/scripts/install @@ -70,7 +70,7 @@ ynh_add_supervisor_config #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --log="/var/log/$app/$app.log" +yunohost service add $app --description="Monitoring web dashboard" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/restore b/scripts/restore index 0c5021e..8619afd 100755 --- a/scripts/restore +++ b/scripts/restore @@ -51,7 +51,7 @@ supervisorctl update #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --log="/var/log/$app/$app.log" +yunohost service add $app --description="Monitoring web dashboard" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index 84eaf41..42f8f9f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -87,7 +87,7 @@ ynh_add_supervisor_config #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --log="/var/log/$app/$app.log" +yunohost service add $app --description="Monitoring web dashboard" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE From 509fd2c30759853b8380b665c53ae7dc73588827 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 21:01:44 +0200 Subject: [PATCH 10/14] fix --- scripts/change_url | 18 +++++++++++++++++- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 4 ++-- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 690b1ba..63c40b2 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -11,13 +11,29 @@ source /usr/share/yunohost/helpers #================================================= # STANDARD MODIFICATIONS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" + #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 ynh_change_url_nginx_config +#================================================= +# GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index dbf19ab..079ac36 100755 --- a/scripts/install +++ b/scripts/install @@ -78,7 +78,7 @@ yunohost service add $app --description="Monitoring web dashboard" --log="/var/l ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_supervisor_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_supervisor_action --service_name=$app --action="start" --log_path="systemd" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 8619afd..03b293d 100755 --- a/scripts/restore +++ b/scripts/restore @@ -58,7 +58,7 @@ yunohost service add $app --description="Monitoring web dashboard" --log="/var/l #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_supervisor_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_supervisor_action --service_name=$app --action="start" --log_path="systemd" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 42f8f9f..57025d0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,7 +22,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -94,7 +94,7 @@ yunohost service add $app --description="Monitoring web dashboard" --log="/var/l #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_supervisor_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_supervisor_action --service_name=$app --action="start" --log_path="systemd" #================================================= # END OF SCRIPT From ac243bfd995e64865e6d72a02a1923f5e3da8f86 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 21:03:08 +0200 Subject: [PATCH 11/14] Update upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 57025d0..9584780 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -69,7 +69,7 @@ ynh_script_progression --message="Building app..." pushd "$install_dir" ynh_use_nodejs - ynh_exec_warn_less ynh_npm install --production + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --production popd #================================================= From 5585670ff674cbea9f583787ae3f3631fd9dfb4f 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 21:34:41 +0200 Subject: [PATCH 12/14] fix --- scripts/change_url | 4 ++-- scripts/install | 2 +- scripts/upgrade | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 63c40b2..8d9a947 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -16,7 +16,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" +ynh_supervisor_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF @@ -32,7 +32,7 @@ ynh_change_url_nginx_config #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" +ynh_supervisor_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 079ac36..dbf19ab 100755 --- a/scripts/install +++ b/scripts/install @@ -78,7 +78,7 @@ yunohost service add $app --description="Monitoring web dashboard" --log="/var/l ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_supervisor_action --service_name=$app --action="start" --log_path="systemd" +ynh_supervisor_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index 9584780..286c8ad 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,7 +22,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= 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="/var/log/$app/$app.log" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -94,7 +94,7 @@ yunohost service add $app --description="Monitoring web dashboard" --log="/var/l #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_supervisor_action --service_name=$app --action="start" --log_path="systemd" +ynh_supervisor_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT From 6878c7a54d379b3d58f58eee09d5f0d2072faee0 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 22:20:09 +0200 Subject: [PATCH 13/14] Update upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 286c8ad..32c17b1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,7 +22,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_supervisor_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE From 0eca4cd30ac050b76bcde8a430bb8a31fedd30ab Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sat, 2 Dec 2023 21:42:05 +0000 Subject: [PATCH 14/14] 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 d4deeb9..4f96a45 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ A beautiful web dashboard for GNU/Linux which display CPU, RAM, memory, network * Official admin documentation: * Upstream app code repository: -* YunoHost documentation for this app: +* YunoHost Store: * Report a bug: ## Developer info diff --git a/README_fr.md b/README_fr.md index a483f0d..6ef7b01 100644 --- a/README_fr.md +++ b/README_fr.md @@ -26,7 +26,7 @@ A beautiful web dashboard for GNU/Linux which display CPU, RAM, memory, network * Documentation officielle de l’admin : * Dépôt de code officiel de l’app : -* Documentation YunoHost pour cette app : +* YunoHost Store: * Signaler un bug : ## Informations pour les développeurs