forked from dinger1986/TRMM-Grafana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateg.sh
58 lines (47 loc) · 2.09 KB
/
updateg.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
#### Just scripted up to work from @Yasd and @sebcashmag on Discord forum
#check if running on ubuntu 20.04, Debian or Raspbian
osname=$(lsb_release -si); osname=${osname^}
osname=$(echo "$osname" | tr '[A-Z]' '[a-z]')
fullrel=$(lsb_release -sd)
codename=$(lsb_release -sc)
relno=$(lsb_release -sr | cut -d. -f1)
fullrelno=$(lsb_release -sr)
# Fallback if lsb_release -si returns anything else than Ubuntu, Debian or Raspbian
if [ ! "$osname" = "ubuntu" ] && [ ! "$osname" = "debian" ]; then
osname=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
osname=${osname^}
fi
# determine system
if ([ "$osname" = "ubuntu" ] && [ "$fullrelno" = "20.04" ]) || ([ "$osname" = "debian" ] && [ $relno -ge 10 ]); then
echo $fullrel
else
echo $fullrel
echo -ne "${RED}Only Ubuntu release 20.04 and Debian 10 and later, are supported\n"
echo -ne "Your system does not appear to be supported${NC}\n"
exit 1
fi
if [ $EUID -eq 0 ]; then
echo -ne "${RED}Do NOT run this script as root. Exiting.${NC}\n"
exit 1
fi
#check if running as root
if [ $EUID -eq 0 ]; then
echo -ne "\033[0;31mDo NOT run this script as root. Exiting.\e[0m\n"
exit 1
fi
#Username
echo -ne "Enter your created username if you havent done this please do it now, use ctrl+c to cancel this script and do it${NC}: "
read username
#Get Dashboards
sudo mkdir /var/lib/grafana/dashboards
sudo mv /var/lib/grafana/dashboards/sebdash.json /var/lib/grafana/dashboards/sebdash.json.back
sudo mv /var/lib/grafana/dashboards/tvdash.json /var/lib/grafana/dashboards/tvdash.json.back
sudo mv /var/lib/grafana/dashboards/mapdash.json /var/lib/grafana/dashboards/mapdash.json.back
sudo mv /var/lib/grafana/dashboards/default.json /var/lib/grafana/dashboards/default.json.back
sudo chown -R ${username}:${username} /var/lib/grafana/dashboards
cd /var/lib/grafana/dashboards
wget https://raw.githubusercontent.com/dinger1986/TRMM-Grafana/main/dashboards/agentdash.json
wget https://raw.githubusercontent.com/dinger1986/TRMM-Grafana/main/dashboards/clientdash.json
wget https://raw.githubusercontent.com/dinger1986/TRMM-Grafana/main/dashboards/clientmap.json
cd ~/