-
Notifications
You must be signed in to change notification settings - Fork 6
/
bootstrap.sh
50 lines (45 loc) · 1.08 KB
/
bootstrap.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
#!/bin/bash
# bash <(curl -s https://raw.githubusercontent.com/KnoAll/cacti-template/dev/bootstrap.sh)
green=$(tput setaf 2)
red=$(tput setaf 1)
tan=$(tput setaf 3)
reset=$(tput sgr0)
printinfo() {
if [ -z "$1" ]; then
printf "${tan}::: ${green}%s${reset}\n" "$@"
else
printf "${tan}::: ${green}%s${reset}\n" "$(date +%a_%R): $@"
fi
}
printwarn() {
printf "${tan}*** WARNING: %s${reset}\n" "$(date +%a_%R): $@"
}
printerror() {
printf "${red}!!! ERROR: %s${reset}\n" "$(date +%a_%R): $@"
}
case $(whoami) in
root)
printerror "You ran me as root! Do not run me as root!"
exit 1
;;
pi)
printerror "You ran me as pi user! Do not run me as pi!"
exit 1
;;
cacti)
printinfo
;;
*)
printerror "Uh-oh. You are not logged in as the cacti user. Exiting..."
exit 1
;;
esac
if [ -f ~/cacti-upgrade.sh ]
then
printinfo ""
else
printinfo "Downloading cacti-upgrade.sh..."
wget -q https://raw.githubusercontent.com/KnoAll/cacti-template/master/cacti-upgrade.sh
chmod +x cacti-upgrade.sh
fi
./cacti-upgrade.sh