integrate.inc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/bash
  2. hestia_module_web_integrate() {
  3. source $HESTIA/bin/module/func.inc
  4. osal_service_stop $OSAL_SERVICE_NGINX > /dev/null 2>&1
  5. osal_service_stop $OSAL_SERVICE_APACHE > /dev/null 2>&1
  6. local apache_installed=$(hestia_module_isinstalled apache && echo 1)
  7. local nginx_installed=$(hestia_module_isinstalled nginx && echo 1)
  8. if [ "$apache_installed" ] && [ ! "$nginx_installed" ] ; then
  9. echo "Setup Web module (Apache only)..."
  10. osal_kv_write $HESTIA/conf/hestia.conf 'WEB_SYSTEM' $OSAL_PKG_APACHE
  11. osal_kv_write $HESTIA/conf/hestia.conf 'WEB_RGROUPS' $OSAL_USER_APACHE_DATA
  12. osal_kv_write $HESTIA/conf/hestia.conf 'WEB_PORT' '80'
  13. osal_kv_write $HESTIA/conf/hestia.conf 'WEB_SSL_PORT' '443'
  14. osal_kv_write $HESTIA/conf/hestia.conf 'WEB_SSL' 'mod_ssl'
  15. osal_kv_delete $HESTIA/conf/hestia.conf 'PROXY_SYSTEM'
  16. osal_kv_delete $HESTIA/conf/hestia.conf 'PROXY_PORT'
  17. osal_kv_delete $HESTIA/conf/hestia.conf 'PROXY_SSL_PORT'
  18. osal_kv_write $HESTIA_CONF_MODULES/apache.conf 'service_name' $OSAL_SERVICE_APACHE
  19. elif [ "$apache_installed" ] && [ "$nginx_installed" ] ; then
  20. echo "Setup Web module (Apache + Nginx)..."
  21. osal_kv_write $HESTIA/conf/hestia.conf 'WEB_SYSTEM' $OSAL_PKG_APACHE
  22. osal_kv_write $HESTIA/conf/hestia.conf 'WEB_RGROUPS' $OSAL_USER_APACHE_DATA
  23. osal_kv_write $HESTIA/conf/hestia.conf 'WEB_PORT' '8080'
  24. osal_kv_write $HESTIA/conf/hestia.conf 'WEB_SSL_PORT' '8443'
  25. osal_kv_write $HESTIA/conf/hestia.conf 'WEB_SSL' 'mod_ssl'
  26. osal_kv_write $HESTIA/conf/hestia.conf 'PROXY_SYSTEM' 'nginx'
  27. osal_kv_write $HESTIA/conf/hestia.conf 'PROXY_PORT' '80'
  28. osal_kv_write $HESTIA/conf/hestia.conf 'PROXY_SSL_PORT' '443'
  29. osal_kv_write $HESTIA_CONF_MODULES/apache.conf 'service_name' $OSAL_SERVICE_APACHE
  30. osal_kv_write $HESTIA_CONF_MODULES/nginx.conf 'service_name' $OSAL_SERVICE_NGINX
  31. elif [ ! "$apache_installed" ] && [ "$nginx_installed" ]; then
  32. echo "Setup Web module (Nginx only)..."
  33. osal_kv_write $HESTIA/conf/hestia.conf 'WEB_SYSTEM' 'nginx'
  34. osal_kv_delete $HESTIA/conf/hestia.conf 'WEB_RGROUPS'
  35. osal_kv_write $HESTIA/conf/hestia.conf 'WEB_PORT' '80'
  36. osal_kv_write $HESTIA/conf/hestia.conf 'WEB_SSL_PORT' '443'
  37. osal_kv_write $HESTIA/conf/hestia.conf 'WEB_SSL' 'openssl'
  38. osal_kv_delete $HESTIA/conf/hestia.conf 'PROXY_SYSTEM'
  39. osal_kv_delete $HESTIA/conf/hestia.conf 'PROXY_PORT'
  40. osal_kv_delete $HESTIA/conf/hestia.conf 'PROXY_SSL_PORT'
  41. osal_kv_write $HESTIA_CONF_MODULES/nginx.conf 'service_name' $OSAL_SERVICE_NGINX
  42. else
  43. echo "Remove Web module setup..."
  44. osal_kv_write $HESTIA/conf/hestia.conf 'WEB_SYSTEM' ''
  45. osal_kv_delete $HESTIA/conf/hestia.conf 'WEB_RGROUPS'
  46. osal_kv_delete $HESTIA/conf/hestia.conf 'WEB_PORT' '80'
  47. osal_kv_delete $HESTIA/conf/hestia.conf 'WEB_SSL_PORT' '443'
  48. osal_kv_delete $HESTIA/conf/hestia.conf 'WEB_SSL' 'openssl'
  49. osal_kv_delete $HESTIA/conf/hestia.conf 'PROXY_SYSTEM'
  50. osal_kv_delete $HESTIA/conf/hestia.conf 'PROXY_PORT'
  51. osal_kv_delete $HESTIA/conf/hestia.conf 'PROXY_SSL_PORT'
  52. fi
  53. if [ "$apache_installed" ] || [ "$nginx_installed" ] ; then
  54. hestia module web setup-ips
  55. # Rebuild domains
  56. echo "Rebuilding web domains"
  57. for user in $($HESTIA/bin/v-list-sys-users plain); do
  58. $BIN/v-rebuild-web-domains $user 'no' > /dev/null 2>&1
  59. done
  60. if [ "$apache_installed" ]; then
  61. osal_service_enable $OSAL_SERVICE_APACHE
  62. osal_service_start $OSAL_SERVICE_APACHE
  63. check_result $? "Apache start failed"
  64. fi
  65. if [ "$nginx_installed" ]; then
  66. osal_service_enable $OSAL_SERVICE_NGINX
  67. osal_service_start $OSAL_SERVICE_NGINX
  68. check_result $? "Nginx start failed"
  69. fi
  70. fi
  71. }