Loading

updater-netdata.sh

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

Comments