v-update-sys-vesta 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. # info: update vesta package/configs
  3. # options: PACKAGE [VERSION]
  4. #
  5. # The function runs as rpm update trigger. It pulls shell script from vesta
  6. # server and runs it.
  7. #----------------------------------------------------------#
  8. # Variable&Function #
  9. #----------------------------------------------------------#
  10. # Argument defenition
  11. package=$1
  12. # Importing system enviroment
  13. source /etc/profile
  14. # Includes
  15. source $VESTA/func/main.sh
  16. source $VESTA/conf/vesta.conf
  17. #----------------------------------------------------------#
  18. # Verifications #
  19. #----------------------------------------------------------#
  20. # Checking arg number
  21. check_args '1' "$#" 'PACKAGE'
  22. #----------------------------------------------------------#
  23. # Action #
  24. #----------------------------------------------------------#
  25. if [ -e "/etc/redhat-release" ]; then
  26. # Clean yum chache
  27. yum -q clean all
  28. # Define yum cmd
  29. yum="yum -q -y --noplugins --disablerepo=* --enablerepo=vesta"
  30. # Update vesta package
  31. $yum update $package > /dev/null 2>&1
  32. if [ $? -ne 0 ]; then
  33. echo "Error: $package update failed"
  34. log_event "$E_UPDATE" "$EVENT"
  35. exit $E_UPDATE
  36. fi
  37. else
  38. # Update repo
  39. apt-get update -o Dir::Etc::sourcelist="sources.list.d/vesta.list" \
  40. -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" -qq
  41. # Update vesta package
  42. apt-get install $package -qq > /dev/null 2>&1
  43. if [ $? -ne 0 ]; then
  44. echo "Error: $package update failed"
  45. log_event "$E_UPDATE" "$EVENT"
  46. exit $E_UPDATE
  47. fi
  48. fi
  49. #----------------------------------------------------------#
  50. # Vesta #
  51. #----------------------------------------------------------#
  52. # Logging
  53. log_event "$OK" "$EVENT"
  54. exit