grafana/0009-update-wrappers-and-systemd-with-distro-paths.patch
Sam Feifer 5cbb944b12 Resolves: RHEL-31246
Rebase to Grafana 10.2.6
2024-04-02 13:09:11 -04:00

77 lines
2.7 KiB
Diff

From 5fe02f961e67af04907dc57beda42456128ab1c8 Mon Sep 17 00:00:00 2001
From: Sam Feifer <sfeifer@redhat.com>
Date: Fri, 1 Mar 2024 15:05:24 -0500
Subject: [PATCH] update wrappers and systemd with distro paths
diff --git a/packaging/rpm/systemd/grafana-server.service b/packaging/rpm/systemd/grafana-server.service
index e3adc3f469..b2e4aced06 100644
--- a/packaging/rpm/systemd/grafana-server.service
+++ b/packaging/rpm/systemd/grafana-server.service
@@ -14,7 +14,7 @@ Restart=on-failure
WorkingDirectory=/usr/share/grafana
RuntimeDirectory=grafana
RuntimeDirectoryMode=0750
-ExecStart=/usr/share/grafana/bin/grafana server \
+ExecStart=/usr/sbin/grafana server \
--config=${CONF_FILE} \
--pidfile=${PID_FILE_DIR}/grafana-server.pid \
--packaging=rpm \
diff --git a/packaging/wrappers/grafana b/packaging/wrappers/grafana
index 86e0fc9faa..5c88bae4c3 100755
--- a/packaging/wrappers/grafana
+++ b/packaging/wrappers/grafana
@@ -5,7 +5,7 @@
# 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="${GRAFANA_HOME:-/usr/share/grafana}"
@@ -13,11 +13,12 @@ CONF_DIR=/etc/grafana
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"
++EXECUTABLE=$LIBEXEC_DIR/grafana
if [ ! -x $EXECUTABLE ]; then
echo "$EXECUTABLE not installed or not executable"
@@ -46,4 +47,13 @@ if [ "$CMD" = cli ]; then
--pluginsDir=${PLUGINS_DIR}"
fi
-eval $EXECUTABLE "$CMD" "$OPTS" "$@"
+if [ "$(id -u)" -eq 0 -o "$(id -g)" -eq 0 ]; then
+ cd "${GRAFANA_HOME}"
+ exec runuser -u "${GRAFANA_USER}" -- "$EXECUTABLE" "$CMD" "${OPTS[@]}" "$@"
+elif [ "$(id -u -n)" = "${GRAFANA_USER}" ]; then
+ cd "${GRAFANA_HOME}"
+ exec "$EXECUTABLE" "$CMD" "${OPTS[@]}" "$@"
+else
+ echo "$0: please run this script as user \"${GRAFANA_USER}\" or root."
+ exit 5
+fi
\ No newline at end of file
diff --git a/packaging/wrappers/grafana-server b/packaging/wrappers/grafana-server
index 466b0d7c69..6be356f562 100755
--- a/packaging/wrappers/grafana-server
+++ b/packaging/wrappers/grafana-server
@@ -7,7 +7,8 @@
GRAFANA_HOME="${GRAFANA_HOME:-/usr/share/grafana}"
-EXECUTABLE="$GRAFANA_HOME/bin/grafana"
+LIBEXEC_DIR=/usr/libexec/grafana
+EXECUTABLE=$LIBEXEC_DIR/grafana
if [ ! -x $EXECUTABLE ]; then
echo "$EXECUTABLE not installed or not executable"