Blame SOURCES/001-wrappers-grafana-cli.patch

5bde66
diff --git a/packaging/wrappers/grafana-cli b/packaging/wrappers/grafana-cli
5bde66
index 9cad151c0d..a786edc596 100755
5bde66
--- a/packaging/wrappers/grafana-cli
5bde66
+++ b/packaging/wrappers/grafana-cli
5bde66
@@ -5,18 +5,19 @@
5bde66
 # the system-wide Grafana configuration that was bundled with the package as we
5bde66
 # use the binary.
5bde66
 
5bde66
-DEFAULT=/etc/default/grafana
5bde66
+DEFAULT=/etc/sysconfig/grafana-server
5bde66
 
5bde66
 GRAFANA_HOME=/usr/share/grafana
5bde66
 CONF_DIR=/etc/grafana
5bde66
 DATA_DIR=/var/lib/grafana
5bde66
 PLUGINS_DIR=/var/lib/grafana/plugins
5bde66
 LOG_DIR=/var/log/grafana
5bde66
+LIBEXEC_DIR=/usr/libexec/grafana
5bde66
 
5bde66
 CONF_FILE=$CONF_DIR/grafana.ini
5bde66
 PROVISIONING_CFG_DIR=$CONF_DIR/provisioning
5bde66
 
5bde66
-EXECUTABLE=$GRAFANA_HOME/bin/grafana-cli
5bde66
+EXECUTABLE=$LIBEXEC_DIR/grafana-cli
5bde66
 
5bde66
 if [ ! -x $EXECUTABLE ]; then
5bde66
  echo "Program not installed or not executable"
5bde66
@@ -24,6 +25,7 @@ if [ ! -x $EXECUTABLE ]; then
5bde66
 fi
5bde66
 
5bde66
 # overwrite settings from default file
5bde66
+#shellcheck disable=SC1090
5bde66
 if [ -f "$DEFAULT" ]; then
5bde66
   . "$DEFAULT"
5bde66
 fi
5bde66
@@ -36,4 +38,13 @@ OPTS="--homepath=${GRAFANA_HOME} \
5bde66
                         cfg:default.paths.logs=${LOG_DIR} \
5bde66
                         cfg:default.paths.plugins=${PLUGINS_DIR}'"
5bde66
 
5bde66
-eval $EXECUTABLE "$OPTS" "$@"
5bde66
+if [ "$(id -u)" -eq 0 ]; then
5bde66
+  cd "${GRAFANA_HOME}"
5bde66
+  exec runuser -u "${GRAFANA_USER}" -- "$EXECUTABLE" "$OPTS" "$@"
5bde66
+elif [ "$(id -u -n)" = "${GRAFANA_USER}" ]; then
5bde66
+  cd "${GRAFANA_HOME}"
5bde66
+  exec "$EXECUTABLE" "$OPTS" "$@"
5bde66
+else
5bde66
+  echo "$0: please run this script as user \"${GRAFANA_USER}\" or root."
5bde66
+  exit 5
5bde66
+fi