From 867c2763232b8667f7093b9520eb0184cb05719f Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 3 Aug 2021 08:02:26 +0200 Subject: [PATCH] Fix --- check_process | 10 +++++----- manifest.json | 23 +++-------------------- scripts/backup | 1 + scripts/change_url | 6 +++--- scripts/install | 10 ++++------ scripts/remove | 2 +- scripts/restore | 2 +- scripts/upgrade | 33 +++++++++------------------------ 8 files changed, 27 insertions(+), 60 deletions(-) diff --git a/check_process b/check_process index 8252236..6fc1eed 100644 --- a/check_process +++ b/check_process @@ -1,11 +1,11 @@ ;; Complete test auto_remove=1 ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) - admin="john" (USER) - is_public=1 (PUBLIC|public=1|private=0) - port="3000" (PORT) + domain="domain.tld" + path="/path" + admin="john" + is_public=1 + port="3000" ; Checks pkg_linter=1 setup_sub_dir=1 diff --git a/manifest.json b/manifest.json index d33b74a..d79f8a9 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "id": "grafana", "packaging_format": 1, "description": { - "en": "Beautiful metric & analytic dashboards for monitoring", + "en": "Metric & analytic dashboards for monitoring", "fr": "Tableaux de bords de supervision" }, "version": "7.5.5~ynh1", @@ -15,50 +15,33 @@ "url": "" }, "requirements": { - "yunohost": ">= 3.8.1" + "yunohost": ">= 4.2.0" }, "multi_instance": false, "services": [ - "nginx", - "php7.0-fpm" + "nginx" ], "arguments": { "install" : [ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain for Grafana", - "fr": "Choisissez un nom de domaine pour Grafana" - }, "example": "domain.org" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for Grafana", - "fr": "Choisissez un chemin pour Grafana" - }, "example": "/grafana", "default": "/grafana" }, { "name": "admin", "type": "user", - "ask": { - "en": "Choose an admin user", - "fr": "Choisissez l'administrateur" - }, "example": "homer" }, { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?" - }, "default": false } ] diff --git a/scripts/backup b/scripts/backup index 8fda6ca..4a8ef29 100644 --- a/scripts/backup +++ b/scripts/backup @@ -63,6 +63,7 @@ ynh_mysql_dump_db --database="$db_name" > db.sql # SPECIFIC BACKUP #================================================= ynh_print_info --message="Backing up the InfluxDB database..." + # Backup InfluxDB data # Source: http://stackoverflow.com/questions/39501416/how-to-restore-data-base-using-influxd mkdir influxdb_data diff --git a/scripts/change_url b/scripts/change_url index 6462af3..95cfd7e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -31,7 +31,7 @@ port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --weight=4 +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=4 # Backup the current version of the app ynh_backup_before_upgrade @@ -73,7 +73,7 @@ ynh_systemd_action --service_name=grafana-server --action="stop" --log_path="/va #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." --weight=1 +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -128,7 +128,7 @@ ynh_systemd_action --service_name=grafana-server --action="start" --log_path="/v #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/install b/scripts/install index c553c53..57d9552 100644 --- a/scripts/install +++ b/scripts/install @@ -48,7 +48,6 @@ ynh_script_progression --message="Storing installation settings..." --weight=2 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 -ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= # STANDARD MODIFICATIONS @@ -88,7 +87,7 @@ ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." --weight=1 +ynh_script_progression --message="Configuring NGINX web server..." --weight=1 ### `ynh_add_nginx_config` will use the file conf/nginx.conf @@ -227,19 +226,18 @@ ynh_systemd_action --service_name=grafana-server --action="restart" --log_path=" #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --weight=1 +ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary if [ $is_public -eq 1 ] then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" + ynh_permission_update --permission="main" --add="visitors" fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/remove b/scripts/remove index a5bed51..1108b04 100644 --- a/scripts/remove +++ b/scripts/remove @@ -54,7 +54,7 @@ ynh_remove_app_dependencies #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." --weight=1 +ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 # Remove the dedicated nginx config ynh_remove_nginx_config diff --git a/scripts/restore b/scripts/restore index fb4bfed..4ae4573 100644 --- a/scripts/restore +++ b/scripts/restore @@ -113,7 +113,7 @@ ynh_systemd_action --service_name=grafana-server --action="start" --log_path="/v #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index d283cd4..69ecbba 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,7 +19,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) admin=$(ynh_app_setting_get --app=$app --key=admin) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) @@ -36,21 +35,19 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 -fi - # If db_name doesn't exist, create it if [ -z "$db_name" ]; then db_name=$(ynh_sanitize_dbid --db_name=$app) ynh_app_setting_set --app=$app --key=db_name --value=$db_name fi +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -70,7 +67,7 @@ ynh_abort_if_errors #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1 +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 # Create a dedicated nginx config ynh_add_nginx_config @@ -163,18 +160,6 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name <<< yunohost service add influxdb --description="open source time series database" --log="/var/log/grafana/grafana.log" yunohost service add grafana-server --description="open source analytics and monitoring solution" --log="/var/log/grafana/grafana.log" -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1 - -# Make app public if necessary -if [ $is_public -eq 1 ] -then - # unprotected_uris allows SSO credentials to be passed anyway - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" -fi - #================================================= # START SYSTEMD SERVICE #================================================= @@ -185,7 +170,7 @@ ynh_systemd_action --service_name=grafana-server --action="restart" --log_path=" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload