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