From 3a84b9824144a88968616ad150a52a1f61155845 Mon Sep 17 00:00:00 2001 From: biva Date: Mon, 7 Feb 2022 16:35:47 +0100 Subject: [PATCH] Update install to include influxdb2 This is a WIP and it requires support... I'm not skilled enough, notably for the configuration of the data base, and the change from "data base" (influxDB 1) to "bucket" (influxdb2) --- scripts/install | 65 +++++++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/scripts/install b/scripts/install index 50d6846..57f6803 100644 --- a/scripts/install +++ b/scripts/install @@ -58,6 +58,16 @@ ynh_script_progression --message="Finding an available port..." --weight=1 port=$(ynh_find_port --port=3000) ynh_app_setting_set --app=$app --key=port --value=$port +#================================================= +# ADD INFLUXDATA REPOSITORY +#================================================= + +wget -qO- https://repos.influxdata.com/influxdb.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdb.gpg > /dev/null +export DISTRIB_ID=$(lsb_release -si); export DISTRIB_CODENAME=$(lsb_release -sc) +echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdb.gpg] https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list > /dev/null + +apt update + #================================================= # INSTALL DEPENDENCIES #================================================= @@ -92,35 +102,38 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring Grafana and InfluxDB..." --weight=30 # If NetData is installed, configure it to feed InfluxDB -netdata_conf="/opt/netdata/etc/netdata/exporting.conf" -if [ -f "$netdata_conf" ] ; then - sed -i '/^\[exporting:global\]$/,/^\[/ { - s/enabled = no/enabled = yes/ - s/# update every = 10/update every = 60/ - }' $netdata_conf - if [ -z "$(grep "yunohost" $netdata_conf)" ] ; then - cat >> $netdata_conf <> $netdata_conf < dashboard.json +###tr -d '\n' < ../conf/netdata_dashboard.json > dashboard.json # Fill the template with the defined data source -sed -i 's/${DS_CENTCOM-INFLUXDB}/InfluxDB/g' dashboard.json +###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" +###dashboard=$(cat dashboard.json) +###printf -v escaped_dashboard "%q" "$dashboard" # 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');" +###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 -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\");" +###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 systemctl enable influxdb.service --quiet