-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathupgrade-plugins.sh
More file actions
47 lines (42 loc) · 1 KB
/
upgrade-plugins.sh
File metadata and controls
47 lines (42 loc) · 1 KB
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
#!/bin/bash
# bash <(curl -s https://raw.githubusercontent.com/KnoAll/cacti-template/dev/upgrade-plugins.sh) dev
green=$(tput setaf 2)
red=$(tput setaf 1)
tan=$(tput setaf 3)
reset=$(tput sgr0)
branch=master
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): $@"
}
#ingest options
if [[ "$#" > 0 ]]; then
for var in "$@"; do
case $var in
debug|-debug|--debug)
trap 'echo cmd: "$BASH_COMMAND" on line $LINENO exited with code: $?' DEBUG
;;
dev|-dev|--dev)
branch="dev"
;;
esac
done
fi
cd /var/www/html/cacti/plugins
for dir in ./*/; do
cd ${dir}
git status >/dev/null 2>&1
# check if exit status of above was 0, indicating we're in a git repo
[ $(echo $?) -eq 0 ] && printinfo "Updating ${dir%*/}..." && git pull
cd ..
done
printinfo