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