v-update-web-templates 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/bash
  2. # info: update web templates
  3. # options: [RESTART]
  4. #
  5. # The function for obtaining updated pack of web templates.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. restart=$1
  11. # Includes
  12. source $VESTA/func/main.sh
  13. source $VESTA/conf/vesta.conf
  14. #----------------------------------------------------------#
  15. # Action #
  16. #----------------------------------------------------------#
  17. # Defining config host
  18. chost='c.vestacp.com'
  19. # Detcing OS
  20. case $(head -n1 /etc/issue |cut -f 1 -d ' ') in
  21. Debian) version="debian" ;;
  22. Ubuntu) version="ubuntu" ;;
  23. *) version="rhel" ;;
  24. esac
  25. # Detecting release
  26. if [ "$version" = 'rhel' ]; then
  27. release=$(grep -o "[0-9]" /etc/redhat-release |head -n1)
  28. fi
  29. if [ "$version" = 'ubuntu' ]; then
  30. release=$(lsb_release -r |awk '{print $2}')
  31. fi
  32. if [ "$version" = 'debian' ]; then
  33. release=$(cat /etc/issue|grep -o [0-9]|head -n1)
  34. fi
  35. # Defining download url
  36. vestacp="http://$chost/$version/$release"
  37. # Downloading template archive
  38. cd $(mktemp -d)
  39. wget $vestacp/templates.tar.gz -q
  40. check_result $? "can't download template.tar.gz" $E_CONNECT
  41. # Updating templates
  42. tar -xzpf templates.tar.gz -C $VESTA/data/ templates/web
  43. # Rebuilding web domains
  44. for user in $($BIN/v-list-sys-users plain); do
  45. $BIN/v-rebuild-web-domains $user no
  46. done
  47. #----------------------------------------------------------#
  48. # Vesta #
  49. #----------------------------------------------------------#
  50. # Restarting web server
  51. $BIN/v-restart-web $restart
  52. check_result $? "restart" >/dev/null 2>&1
  53. $BIN/v-restart-proxy $restart
  54. check_result $? "restart" >/dev/null 2>&1
  55. $BIN/v-restart-proxy $restart
  56. check_result $? "restart" >/dev/null 2>&1
  57. exit