diff --git a/conf/nginx.conf b/conf/nginx.conf index 23ad529..1bc6f42 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,11 +1,6 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - # Force usage of https - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } - proxy_redirect off; proxy_set_header Host $host; diff --git a/manifest.json b/manifest.json index 0360566..94e1850 100644 --- a/manifest.json +++ b/manifest.json @@ -7,7 +7,6 @@ "fr": "Tableaux de bords de supervision" }, "version": "8.3.3~ynh1", - "license": "AGPL-3.0-only", "url": "https://grafana.com/oss/grafana/", "upstream": { "license": "AGPL-3.0-only", @@ -15,24 +14,23 @@ "demo": "https://play.grafana.org", "code": "https://github.com/grafana/" }, + "license": "AGPL-3.0-only", "maintainer": { "name": "JimboJoe", - "email": "jimmy@monin.net", - "url": "" + "email": "jimmy@monin.net" }, "requirements": { - "yunohost": ">= 4.2.0" + "yunohost": ">= 4.3.0" }, "multi_instance": false, "services": [ "nginx" ], "arguments": { - "install" : [ + "install": [ { "name": "domain", - "type": "domain", - "example": "domain.org" + "type": "domain" }, { "name": "path", @@ -42,8 +40,7 @@ }, { "name": "admin", - "type": "user", - "example": "homer" + "type": "user" }, { "name": "is_public", diff --git a/scripts/change_url b/scripts/change_url index 9a4369a..af1e5ac 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -29,7 +29,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 port=$(ynh_app_setting_get --app=$app --key=port) #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=4 @@ -40,7 +40,7 @@ ynh_clean_setup () { # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -78,19 +78,19 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -# Change the path in the nginx config file +# Change the path in the NGINX config file if [ $change_path -eq 1 ] then - # Make a backup of the original nginx config file if modified + # Make a backup of the original NGINX config file if modified ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for nginx helper + # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" - # Create a dedicated nginx config + # Create a dedicated NGINX config ynh_add_nginx_config fi -# Change the domain for nginx +# Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location @@ -103,8 +103,10 @@ fi #================================================= # SPECIFIC MODIFICATIONS #================================================= - +# UPDATE GRAFANA CONFIGURATION +#================================================= ynh_script_progression --message="Updating Grafana configuration..." --weight=1 + grafana_conf="/etc/grafana/grafana.ini" # Set domain sed -i "/^\[server\]$/,/^\[/ s@domain = .*@domain = $new_domain@" $grafana_conf diff --git a/scripts/install b/scripts/install index bfb6ab7..50d6846 100644 --- a/scripts/install +++ b/scripts/install @@ -185,15 +185,15 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name <<< # Import default dashboard for NetData (source: https://grafana.com/grafana/dashboards/2701) # Remove new lines tr -d '\n' < ../conf/netdata_dashboard.json > dashboard.json -# Fill the template with the defined data source +# Fill the template with the defined data source sed -i 's/${DS_CENTCOM-INFLUXDB}/InfluxDB/g' dashboard.json # Escape the dashboard definition for MySQL query (source: https://stackoverflow.com/a/4383994) dashboard=$(cat dashboard.json) printf -v escaped_dashboard "%q" "$dashboard" -# Import dashboard into MySQL +# Import dashboard into MySQL ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name <<< "INSERT INTO dashboard (id, version, slug, title, data, org_id, created, updated, uid) VALUES (99999, 0, 'NetData', 'NetData', \"$escaped_dashboard\", 1, '2020-05-16 14:36:50', '2020-05-16 14:36:50', 'yunohost');" -# Add dashboard version +# Add dashboard version ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name <<< "INSERT INTO dashboard_version (id, dashboard_id, parent_version, restored_from, version, created, created_by, message, data) VALUES (99999, 99999, 0, 0, 1, '2020-05-16 14:36:50', 1, 'YunoHost installer', \"$escaped_dashboard\");" # Enable the systemd service so that InfluxDB and Grafana start at boot diff --git a/scripts/remove b/scripts/remove index 15c499f..96a02d0 100644 --- a/scripts/remove +++ b/scripts/remove @@ -43,14 +43,6 @@ ynh_script_progression --message="Removing the MySQL database..." --weight=3 # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=26 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -59,6 +51,14 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=26 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + #================================================= # SPECIFIC REMOVE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 6062c47..e9588b7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -39,7 +39,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { - ynh_clean_check_starting + ynh_clean_check_starting # Restore it if the upgrade fails ynh_restore_upgradebackup } @@ -66,6 +66,11 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi +# Migration: remove old repository if defined +if [ -f "/etc/apt/sources.list.d/grafana_stable.list" ] ; then + ynh_secure_remove --file="/etc/apt/sources.list.d/grafana_stable.list" +fi + #================================================= # NGINX CONFIGURATION #================================================= @@ -79,13 +84,8 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Upgrading dependencies..." --weight=12 -# Migration: remove old repository if defined -if [ -f "/etc/apt/sources.list.d/grafana_stable.list" ] ; then - ynh_secure_remove --file="/etc/apt/sources.list.d/grafana_stable.list" -fi - ynh_install_app_dependencies $pkg_dependencies -ynh_install_extra_app_dependencies --repo="deb https://packages.grafana.com/oss/deb stable main" --package="grafana (>=$GRAFANA_VERSION)" --key="https://packages.grafana.com/gpg.key" +ynh_install_extra_app_dependencies --repo="deb https://packages.grafana.com/oss/deb stable main" --package="grafana" --key="https://packages.grafana.com/gpg.key" #================================================= # SPECIFIC UPGRADE @@ -145,12 +145,12 @@ fi # Update default dashboard for NetData (source: https://grafana.com/grafana/dashboards/2701) # Remove new lines tr -d '\n' < ../conf/netdata_dashboard.json > dashboard.json -# Fill the template with the defined data source +# Fill the template with the defined data source sed -i 's/${DS_CENTCOM-INFLUXDB}/InfluxDB/g' dashboard.json # Escape the dashboard definition for MySQL query dashboard=$(cat dashboard.json) printf -v escaped_dashboard "%q" "$dashboard" -# Import dashboard into MySQL +# Import dashboard into MySQL ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name <<< "UPDATE dashboard set data=\"$escaped_dashboard\" WHERE id=99999;" # Insert dashboard version if non existent (for downward compatibility) ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name <<< "INSERT INTO dashboard_version (id, dashboard_id, parent_version, restored_from, version, created, created_by, message, data) VALUES (99999, 99999, 0, 0, 1, '2020-05-16 14:36:50', 1, 'YunoHost installer', \"$escaped_dashboard\");" > /dev/null 2>&1 || true