Skip to content

Commit ec626c8

Browse files
committed
Add script to install latest version of this plugin
1 parent 67bab3f commit ec626c8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

utils/install_latest.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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

0 commit comments

Comments
 (0)