File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -e
4+ if ! command -v jq > /dev/null || ! command -v grafana-cli > /dev/null; then
5+ echo " ERROR: This script can not run without jq or grafana-cli binaries."
6+ exit 1
7+ fi
8+ DOWNLOAD_URL=$( wget -O- -q https://api.github.com/repos/tribe29/grafana-checkmk-datasource/releases/latest | jq -r " .assets[0].browser_download_url" )
9+ COMMAND=" grafana-cli --pluginUrl " " $DOWNLOAD_URL " " plugins install tribe-29-checkmk-datasource"
10+
11+ # we have to make sure that the grafana-cli command is executed as grafana user
12+ # see https://github.com/grafana/grafana/issues/25367
13+ if [ " $( id -nu) " == " root" ]; then
14+ # cd is necessary, because grafana-cli will access `$PWD`. if executed as
15+ # root, `$PWD` may point to `/root` and the grafana user has no permissions
16+ # to access that.
17+ sudo -u grafana bash -c " cd; $COMMAND "
18+ exit 0
19+ fi
20+ if [ " $( id -nu) " == " grafana" ]; then
21+ $COMMAND
22+ exit 0
23+ fi
24+ echo " ERROR: This script hast to be executed as root or grafana user"
25+ exit 1
You can’t perform that action at this time.
0 commit comments