refs #2575 add mysql datasources yaml and adds it in the post install

debian-package
Luis Gerardo Romero Garcia 2025-08-08 09:45:57 +02:00
parent 5f228f1601
commit 54188a947a
2 changed files with 35 additions and 1 deletions

14
debian/oglog.postinst vendored
View File

@ -107,7 +107,7 @@ update_etc_hosts() {
fi
echo "Actualizando $HOSTS_FILE para incluir el CN '$CN'."
# Agregar CN a la entrada de localhost en /etc/hosts
sudo sed -i "/127.0.0.1/s/$/ $CN/" /etc/hosts
sed -i "/127.0.0.1/s/$/ $CN/" /etc/hosts
}
### Main script execution starts here ###
@ -176,6 +176,8 @@ configure_grafana(){
local TMPLATE_BASE_DIR="/opt/opengnsys/oglog/etc/grafana"
local OPENSEARCH_TMPL_FILE="$TMPLATE_BASE_DIR/provisioning/datasources/opensearch.yaml"
local OPENSEARCH_FILE="$BASE_DIR/provisioning/datasources/opensearch.yaml"
local MYSQL_TMPL_FILE="$TMPLATE_BASE_DIR/provisioning/datasources/mysql.yaml"
local MYSQL_FILE="$BASE_DIR/provisioning/datasources/mysql.yaml"
# Install OpenSearch datasource plugin if not already installed
if ! grafana-cli plugins ls | grep -q "grafana-opensearch-datasource"; then
@ -188,6 +190,16 @@ configure_grafana(){
chmod 644 "$OPENSEARCH_FILE"
echo "Configuring Grafana with OpenSearch datasource at $OPENSEARCH_FILE"
# Install MySQL datasource plugin if not already installed
if ! grafana-cli plugins ls | grep -q "grafana-mysql-datasource"; then
echo "Installing MySQL datasource plugin for Grafana..."
grafana-cli plugins install grafana-mysql-datasource
fi
envsubst < "$MYSQL_TMPL_FILE" > "$MYSQL_FILE"
chown grafana:grafana "$MYSQL_FILE"
chmod 644 "$MYSQL_FILE"
echo "Configuring Grafana with MySQL datasource at $MYSQL_FILE"
# Copy dashboards
install -d /etc/grafana/dashboards
cp -a /opt/opengnsys/oglog/etc/grafana/resources/dashboards/*.json /etc/grafana/dashboards/

View File

@ -0,0 +1,22 @@
apiVersion: 1
datasources:
- name: mysql
uid: mysql-ds
type: mysql
access: proxy
url: ${OGCORE_SERVER}:3306
user: grafana
database: ogcore
isDefault: false
basicAuth: false
readOnly: false
jsonData:
connMaxLifetime: 14400
database: ogcore
maxIdleConns: 100
maxIdleConnsAuto: true
maxOpenConns: 100
tlsSkipVerify: false
secureJsonData:
password: root