v-update-web-templates 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/bash
  2. # info: updates web templates
  3. # options: [RESTART]
  4. #
  5. # The function for obtaining updated pack of web templates.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument defenition
  10. restart=$1
  11. # Includes
  12. source $VESTA/func/main.sh
  13. source $VESTA/conf/vesta.conf
  14. #----------------------------------------------------------#
  15. # Action #
  16. #----------------------------------------------------------#
  17. # Find out OS name
  18. if [ -e "/etc/redhat-release" ]; then
  19. os="rhel"
  20. else
  21. os="ubuntu"
  22. fi
  23. # Get new archive
  24. tmpdir=$(mktemp -d --dry-run)
  25. mkdir $tmpdir
  26. cd $tmpdir
  27. wget http://c.vestacp.com/$VERSION/$os/templates.tar.gz -q
  28. if [ "$?" -ne 0 ]; then
  29. echo "Error: can't download template.tar.gz"
  30. log_event "$E_CONNECT" "$EVENT"
  31. rm -rf $tmpdir
  32. exit $E_CONNECT
  33. fi
  34. # Update templates
  35. tar -xzpf templates.tar.gz -C $VESTA/data/ templates/web
  36. # Replace includes for apache2.4
  37. if [ "$os" = 'ubuntu' ]; then
  38. if [ ! -z "$(apache2 -v|grep 'Apache/2.4')" ]; then
  39. sed -i "s/Include /IncludeOptional /g" \
  40. $VESTA/data/templates/web/apache2/*tpl
  41. fi
  42. fi
  43. # Rebuild 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. # Restart web server
  51. if [ "$restart" != 'no' ]; then
  52. $BIN/v-restart-web
  53. if [ $? -ne 0 ]; then
  54. exit E_RESTART
  55. fi
  56. $BIN/v-restart-proxy
  57. if [ $? -ne 0 ]; then
  58. exit E_RESTART
  59. fi
  60. fi
  61. # Delete tmpdir
  62. rm -rf $tmpdir
  63. exit