2022-07-27 10:43:28 +00:00
|
|
|
From 055e0dd18587a4fb04d314527a39e419989b6cd3 Mon Sep 17 00:00:00 2001
|
2022-06-22 17:13:29 +00:00
|
|
|
From: Andreas Gerstmayr <agerstmayr@redhat.com>
|
|
|
|
Date: Wed, 22 Jun 2022 16:57:52 +0200
|
|
|
|
Subject: [PATCH] update grafana-cli script with distro-specific paths and
|
|
|
|
switch to grafana user
|
|
|
|
|
|
|
|
|
2020-02-25 21:38:50 +00:00
|
|
|
diff --git a/packaging/wrappers/grafana-cli b/packaging/wrappers/grafana-cli
|
2022-07-14 12:28:36 +00:00
|
|
|
index dafa075a2c..eda358c425 100755
|
2020-02-25 21:38:50 +00:00
|
|
|
--- a/packaging/wrappers/grafana-cli
|
|
|
|
+++ b/packaging/wrappers/grafana-cli
|
2020-11-04 16:44:15 +00:00
|
|
|
@@ -5,18 +5,19 @@
|
|
|
|
# the system-wide Grafana configuration that was bundled with the package as we
|
|
|
|
# use the binary.
|
|
|
|
|
|
|
|
-DEFAULT=/etc/default/grafana
|
|
|
|
+DEFAULT=/etc/sysconfig/grafana-server
|
|
|
|
|
|
|
|
GRAFANA_HOME=/usr/share/grafana
|
|
|
|
CONF_DIR=/etc/grafana
|
2020-02-25 21:38:50 +00:00
|
|
|
DATA_DIR=/var/lib/grafana
|
|
|
|
PLUGINS_DIR=/var/lib/grafana/plugins
|
|
|
|
LOG_DIR=/var/log/grafana
|
|
|
|
+LIBEXEC_DIR=/usr/libexec/grafana
|
|
|
|
|
|
|
|
CONF_FILE=$CONF_DIR/grafana.ini
|
|
|
|
PROVISIONING_CFG_DIR=$CONF_DIR/provisioning
|
|
|
|
|
|
|
|
-EXECUTABLE=$GRAFANA_HOME/bin/grafana-cli
|
|
|
|
+EXECUTABLE=$LIBEXEC_DIR/grafana-cli
|
|
|
|
|
|
|
|
if [ ! -x $EXECUTABLE ]; then
|
|
|
|
echo "Program not installed or not executable"
|
2022-07-14 12:28:36 +00:00
|
|
|
@@ -28,12 +29,21 @@ if [ -f "$DEFAULT" ]; then
|
|
|
|
. "$DEFAULT"
|
|
|
|
fi
|
2020-11-04 16:44:15 +00:00
|
|
|
|
2022-07-14 12:28:36 +00:00
|
|
|
-OPTS="--homepath=${GRAFANA_HOME} \
|
|
|
|
- --config=${CONF_FILE} \
|
|
|
|
- --pluginsDir=${PLUGINS_DIR} \
|
|
|
|
- --configOverrides='cfg:default.paths.provisioning=$PROVISIONING_CFG_DIR \
|
|
|
|
- cfg:default.paths.data=${DATA_DIR} \
|
|
|
|
- cfg:default.paths.logs=${LOG_DIR} \
|
|
|
|
- cfg:default.paths.plugins=${PLUGINS_DIR}'"
|
|
|
|
-
|
2022-06-22 17:13:29 +00:00
|
|
|
-eval $EXECUTABLE "$OPTS" '$@'
|
2022-07-14 12:28:36 +00:00
|
|
|
+OPTS=("--homepath=${GRAFANA_HOME}"
|
|
|
|
+ "--config=${CONF_FILE}"
|
|
|
|
+ "--pluginsDir=${PLUGINS_DIR}"
|
|
|
|
+ "--configOverrides=cfg:default.paths.provisioning=$PROVISIONING_CFG_DIR \
|
|
|
|
+ cfg:default.paths.data=${DATA_DIR} \
|
|
|
|
+ cfg:default.paths.logs=${LOG_DIR} \
|
|
|
|
+ cfg:default.paths.plugins=${PLUGINS_DIR}")
|
|
|
|
+
|
2020-11-04 16:44:15 +00:00
|
|
|
+if [ "$(id -u)" -eq 0 ]; then
|
2021-01-22 11:41:42 +00:00
|
|
|
+ cd "${GRAFANA_HOME}"
|
2022-07-14 12:28:36 +00:00
|
|
|
+ exec runuser -u "${GRAFANA_USER}" -- "$EXECUTABLE" "${OPTS[@]}" "$@"
|
2020-11-04 16:44:15 +00:00
|
|
|
+elif [ "$(id -u -n)" = "${GRAFANA_USER}" ]; then
|
2021-01-22 11:41:42 +00:00
|
|
|
+ cd "${GRAFANA_HOME}"
|
2022-07-14 12:28:36 +00:00
|
|
|
+ exec "$EXECUTABLE" "${OPTS[@]}" "$@"
|
2020-11-04 16:44:15 +00:00
|
|
|
+else
|
2021-06-18 14:20:24 +00:00
|
|
|
+ echo "$0: please run this script as user \"${GRAFANA_USER}\" or root."
|
2020-11-04 16:44:15 +00:00
|
|
|
+ exit 5
|
|
|
|
+fi
|