2020-11-16 22:57:05 +00:00
|
|
|
diff --git a/packaging/wrappers/grafana-cli b/packaging/wrappers/grafana-cli
|
|
|
|
index 9cad151c0d..a786edc596 100755
|
|
|
|
--- a/packaging/wrappers/grafana-cli
|
|
|
|
+++ b/packaging/wrappers/grafana-cli
|
|
|
|
@@ -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
|
|
|
|
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"
|
|
|
|
@@ -24,6 +25,7 @@ if [ ! -x $EXECUTABLE ]; then
|
|
|
|
fi
|
|
|
|
|
|
|
|
# overwrite settings from default file
|
|
|
|
+#shellcheck disable=SC1090
|
|
|
|
if [ -f "$DEFAULT" ]; then
|
|
|
|
. "$DEFAULT"
|
|
|
|
fi
|
2021-01-22 12:38:42 +00:00
|
|
|
@@ -36,4 +38,13 @@ OPTS="--homepath=${GRAFANA_HOME} \
|
2020-11-16 22:57:05 +00:00
|
|
|
cfg:default.paths.logs=${LOG_DIR} \
|
|
|
|
cfg:default.paths.plugins=${PLUGINS_DIR}'"
|
|
|
|
|
|
|
|
-eval $EXECUTABLE "$OPTS" "$@"
|
|
|
|
+if [ "$(id -u)" -eq 0 ]; then
|
2021-01-22 12:38:42 +00:00
|
|
|
+ cd "${GRAFANA_HOME}"
|
2020-11-16 22:57:05 +00:00
|
|
|
+ exec runuser -u "${GRAFANA_USER}" -- "$EXECUTABLE" "$OPTS" "$@"
|
|
|
|
+elif [ "$(id -u -n)" = "${GRAFANA_USER}" ]; then
|
2021-01-22 12:38:42 +00:00
|
|
|
+ cd "${GRAFANA_HOME}"
|
2020-11-16 22:57:05 +00:00
|
|
|
+ exec "$EXECUTABLE" "$OPTS" "$@"
|
|
|
|
+else
|
|
|
|
+ echo "Please run this script as user \"${GRAFANA_USER}\" or root."
|
|
|
|
+ exit 5
|
|
|
|
+fi
|