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