convert_templates.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #!/bin/bash
  2. # Check version
  3. source /usr/local/vesta/conf/vesta.conf
  4. if [ "$VERSION" != '0.9.7' ]; then
  5. exit
  6. fi
  7. # Rename web system service
  8. sed -i "s/apache/httpd/g" /usr/local/vesta/conf/vesta.conf
  9. # Rename dns system service
  10. sed -i "s/bind/named/g" /usr/local/vesta/conf/vesta.conf
  11. # Rename nginx config
  12. mv /etc/nginx/conf.d/vesta_users.conf /etc/nginx/conf.d/vesta.conf 2>/dev/null
  13. rm -f /etc/nginx/conf.d/vesta_ip.conf 2>/dev/null
  14. # Update user packages
  15. PKG=/usr/local/vesta/data/packages
  16. for package in $(ls $PKG); do
  17. default=$(grep "^TEMPLATE='" $PKG/$package | cut -f2 -d \')
  18. if [ ! -z "$default" ]; then
  19. tpl="WEB_TEMPLATE='$default'"
  20. tpl="$tpl\nPROXY_TEMPLATE='default'"
  21. tpl="$tpl\nDNS_TEMPLATE='default'"
  22. sed -i "s/^TEMPLATE=.*/$tpl/g" $PKG/$package
  23. fi
  24. done
  25. # Update users
  26. USR=/usr/local/vesta/data/users
  27. for user in $(ls $USR); do
  28. default=$(grep "^TEMPLATE='" $USR/$user/user.conf | cut -f2 -d \')
  29. if [ ! -z "$default" ]; then
  30. tpl="WEB_TEMPLATE='$default'"
  31. tpl="$tpl\nPROXY_TEMPLATE='default'"
  32. tpl="$tpl\nDNS_TEMPLATE='default'"
  33. sed -i "s/^TEMPLATE=.*/$tpl/g" $USR/$user/user.conf
  34. fi
  35. done
  36. # Rename NGINX to PROXY key
  37. sed -i "s/NGINX/PROXY/g" /usr/local/vesta/data/users/*/web.conf
  38. # Check template structure
  39. TPL='/usr/local/vesta/data/templates/web'
  40. if [ -e "$TPL/apache" ]; then
  41. mv $TPL/apache $TPL/httpd
  42. fi
  43. # Remove unused email template
  44. if [ -e $TPL/email_reset_password.tpl ]; then
  45. rm -f $TPL/email_reset_password.tpl
  46. fi
  47. # Update httpd templates
  48. if [ ! -z "$(ls $TPL | grep apache_)" ]; then
  49. mkdir -p $TPL/httpd
  50. mv $TPL/apache_* $TPL/httpd/
  51. for template in $(ls $TPL/httpd); do
  52. new_name=$(echo $template | sed -e "s/apache_//")
  53. mv -f $TPL/httpd/$template $TPL/httpd/$new_name
  54. done
  55. fi
  56. if [ -e "$TPL/httpd" ]; then
  57. sed -i -e "s/%elog%//g" \
  58. -e "s/%cgi%//g" \
  59. -e "s/%cgi_option%/+ExecCGI/g" $TPL/httpd/*
  60. fi
  61. # Update nginx templates
  62. if [ ! -z "$(ls $TPL/| grep nginx_)" ];then
  63. mkdir -p $TPL/nginx
  64. mv $TPL/nginx_* $TPL/nginx/
  65. for template in $(ls $TPL/nginx/); do
  66. new_name=$(echo $template |sed -e "s/nginx_//")
  67. mv -f $TPL/nginx/$template $TPL/nginx/$new_name
  68. done
  69. fi
  70. if [ -e "$TPL/ngingx.ip.tpl" ]; then
  71. mv $TPL/ngingx.ip.tpl $TPL/nginx/proxy_ip.tpl
  72. fi
  73. if [ -e "$TPL/nginx/ip.tpl" ]; then
  74. mv $TPL/nginx/ip.tpl $TPL/nginx/proxy_ip.tpl
  75. fi
  76. if [ -e "$TPL/nginx" ]; then
  77. sed -i -e "s/%elog%//g" \
  78. -e "s/nginx_extentions/proxy_extentions/g" $TPL/nginx/*
  79. fi
  80. # Move Awstats templates
  81. if [ -e "$TPL/awstats.tpl" ]; then
  82. mkdir -p $TPL/awstats
  83. mv $TPL/awstats.tpl $TPL/awstats
  84. mv $TPL/awstats_index.tpl $TPL/awstats/index.tpl
  85. mv $TPL/awstats_nav.tpl $TPL/awstats/nav.tpl
  86. fi
  87. # Move Webalizer templates
  88. if [ -e "$TPL/webalizer.tpl" ]; then
  89. mkdir -p $TPL/webalizer
  90. mv $TPL/webalizer.tpl $TPL/webalizer
  91. fi
  92. # Update proxy ip configuration
  93. for ip in $(ls /usr/local/vesta/data/ips); do
  94. cat $TPL/nginx/proxy_ip.tpl |\
  95. sed -e "s/%ip%/$ip/g" \
  96. -e "s/%web_port%/8080/g" \
  97. -e "s/%proxy_port%/80/g" \
  98. > /etc/nginx/conf.d/$ip.conf
  99. done
  100. # Remove broken symlink protection
  101. sed -i '/Symlinks protection/d' /etc/nginx/nginx.conf
  102. sed -i '/disable_symlinks.*/d' /etc/nginx/nginx.conf
  103. # Update version
  104. sed -i 's/0.9.7/0.9.8/' /usr/local/vesta/conf/vesta.conf
  105. exit