convert-templates.sh 3.0 KB

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