Última atividade 1 month ago

Revisão e7c1f6279de70a852184dac35475f4a1542d6a83

updater-netdata.sh Bruto
1
2#!/bin/bash
3#
4# Script Updater for netdata
5#
6# - Dependencies: Wring package (NPM)
7#
8# By Erreur32 - 2018
9#
10
11
12service=netdata
13releasehub=https://github.com/netdata/netdata/releases
14
15VERT="\\033[1;32m"
16NORMAL="\\033[0;39m"
17ROUGE="\\033[1;31m"
18ROSE="\\033[1;35m"
19BLEU="\\033[1;34m"
20BLANC="\\033[0;02m"
21BLANCLAIR="\\033[1;08m"
22JAUNE="\\033[1;33m"
23CYAN="\\033[1;36m"
24NOC=$(tput sgr0)
25NC=$(tput sgr0)
26
27
28## Check if wring is installed
29if [ -f "/usr/bin/wring" ] || [ -f "/usr/local/bin/wring" ]
30 then
31 echo -e "\n\e[34m - Wring package \e[0m>> founded.\e[0m\n"
32 else
33 echo -e "\n\e[92m - Install Wring with NPM \e[0m\n"
34 npm install --global wring && echo "Success install Wring" || echo "failure to install Wring"
35 echo -e "\n\e[34m - .\e[0m\n"
36 fi
37
38# need to check in other way... /usr/sbin/netdata -V | cut -c"9-" | cut -c "1-6"
39VersionInstalled="$(/usr/sbin/netdata -v | cut -c"9-" | cut -c "1-6")"
40VersionAvailable="$(curl -s $releasehub | wring text - '.css-truncate-target' | sed -n 5p)"
41
42echo -e "$ROSE Checking $service version ... "
43echo -e "$JAUNE Version installed = v$VersionInstalled"
44echo -e "$JAUNE Version Available = $VersionAvailable"
45echo ""
46
47
48if [ -z "$VersionInstalled" ]
49then
50 echo -e "$service is not installed "
51 echo -e "To install it, type: $JAUNE wget https://my-netdata.io/kickstart.sh -O /opt/netdata-last-installer.sh $NC && /opt/netdata-last-installer.sh "
52 echo -e "- exit -"
53 exit
54fi
55
56if [[ "$VersionAvailable" = "v$VersionInstalled" ]]
57then
58 echo -e "$service is already up-to-date (version $VersionInstalled) ... Bye! "
59 exit
60fi
61
62
63echo -e "$VERT Start install New Updater from Netdata $NC"
64if [ -f "/opt/netdata-last-installer.sh" ]
65 then
66 rm /opt/netdata-last-installer.sh -f
67 wget https://my-netdata.io/kickstart.sh -O /opt/netdata-last-installer.sh --no-verbose && echo -e "$CYAN Get success last installer " || echo "failure"
68 chmod +x /opt/netdata-last-installer.sh
69 else
70 wget https://my-netdata.io/kickstart.sh -O /opt/netdata-last-installer.sh --no-verbose && echo -e "$CYAN Get success last installer " || echo "failure"
71 chmod +x /opt/netdata-last-installer.sh
72 fi
73echo -e " $NC"
74echo -e "$JAUNE Start Updating Netdata..."
75/bin/bash /opt/netdata-last-installer.sh && echo -e " Updating Netdata Successfully!" || echo "failure"
76echo ""
77echo -e " $VERT Update ✔ Netdata..."
78echo -e " $NC"
79