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