Explorar o código

Move to web-server package

Ernesto Nicolás Carrea %!s(int64=5) %!d(string=hai) anos
pai
achega
9b22a9aaf6

+ 0 - 6
bin/module/web/help.inc

@@ -1,6 +0,0 @@
-#!/bin/bash
-
-hestia_module_web_help() {
-    echo "Usage:"
-    echo "  hestia module web integrate"
-}

+ 0 - 89
bin/module/web/integrate.inc

@@ -1,89 +0,0 @@
-#!/bin/bash
-
-hestia_module_web_integrate() {
-    source $HESTIA/bin/module/func.inc
-
-    osal_service_stop $OSAL_SERVICE_NGINX > /dev/null 2>&1
-    osal_service_stop $OSAL_SERVICE_APACHE > /dev/null 2>&1
-
-    local apache_installed=$(hestia_module_isinstalled apache && echo 1)
-    local nginx_installed=$(hestia_module_isinstalled nginx && echo 1)
-
-    if [ "$apache_installed" ] && [ ! "$nginx_installed" ] ; then
-        echo "Setup Web module (Apache only)..."
-        osal_kv_write $HESTIA/conf/hestia.conf  'WEB_SYSTEM' $OSAL_PKG_APACHE
-        osal_kv_write $HESTIA/conf/hestia.conf  'WEB_RGROUPS' $OSAL_USER_APACHE_DATA
-        osal_kv_write $HESTIA/conf/hestia.conf  'WEB_PORT' '80'
-        osal_kv_write $HESTIA/conf/hestia.conf  'WEB_SSL_PORT' '443'
-        osal_kv_write $HESTIA/conf/hestia.conf  'WEB_SSL' 'mod_ssl'
-        osal_kv_write $HESTIA/conf/hestia.conf 'PROXY_SYSTEM' ''
-        osal_kv_delete $HESTIA/conf/hestia.conf 'PROXY_PORT'
-        osal_kv_delete $HESTIA/conf/hestia.conf 'PROXY_SSL_PORT'
-
-        osal_kv_write $HESTIA_CONF_MODULES/apache.conf 'service_name' $OSAL_SERVICE_APACHE
-    elif [ "$apache_installed" ] && [ "$nginx_installed" ] ; then
-        echo "Setup Web module (Apache + Nginx)..."
-        osal_kv_write $HESTIA/conf/hestia.conf  'WEB_SYSTEM' $OSAL_PKG_APACHE
-        osal_kv_write $HESTIA/conf/hestia.conf  'WEB_RGROUPS' $OSAL_USER_APACHE_DATA
-        osal_kv_write $HESTIA/conf/hestia.conf  'WEB_PORT' '8080'
-        osal_kv_write $HESTIA/conf/hestia.conf  'WEB_SSL_PORT' '8443'
-        osal_kv_write $HESTIA/conf/hestia.conf  'WEB_SSL' 'mod_ssl'
-        osal_kv_write $HESTIA/conf/hestia.conf  'PROXY_SYSTEM' 'nginx'
-        osal_kv_write $HESTIA/conf/hestia.conf  'PROXY_PORT' '80'
-        osal_kv_write $HESTIA/conf/hestia.conf  'PROXY_SSL_PORT' '443'
-
-        osal_kv_write $HESTIA_CONF_MODULES/apache.conf 'service_name' $OSAL_SERVICE_APACHE
-        osal_kv_write $HESTIA_CONF_MODULES/nginx.conf 'service_name' $OSAL_SERVICE_NGINX
-    elif [ ! "$apache_installed" ] && [ "$nginx_installed" ]; then
-        echo "Setup Web module (Nginx only)..."
-        osal_kv_write $HESTIA/conf/hestia.conf  'WEB_SYSTEM' 'nginx'
-        osal_kv_delete $HESTIA/conf/hestia.conf 'WEB_RGROUPS'
-        osal_kv_write $HESTIA/conf/hestia.conf  'WEB_PORT' '80'
-        osal_kv_write $HESTIA/conf/hestia.conf  'WEB_SSL_PORT' '443'
-        osal_kv_write $HESTIA/conf/hestia.conf  'WEB_SSL' 'openssl'
-        osal_kv_write $HESTIA/conf/hestia.conf 'PROXY_SYSTEM' ''
-        osal_kv_delete $HESTIA/conf/hestia.conf 'PROXY_PORT'
-        osal_kv_delete $HESTIA/conf/hestia.conf 'PROXY_SSL_PORT'
-
-        osal_kv_write $HESTIA_CONF_MODULES/nginx.conf 'service_name' $OSAL_SERVICE_NGINX
-    else
-        echo "Remove Web module setup..."
-        osal_kv_write $HESTIA/conf/hestia.conf  'WEB_SYSTEM' ''
-        osal_kv_delete $HESTIA/conf/hestia.conf 'WEB_RGROUPS'
-        osal_kv_delete $HESTIA/conf/hestia.conf 'WEB_PORT' '80'
-        osal_kv_delete $HESTIA/conf/hestia.conf 'WEB_SSL_PORT' '443'
-        osal_kv_delete $HESTIA/conf/hestia.conf 'WEB_SSL' 'openssl'
-        osal_kv_write $HESTIA/conf/hestia.conf 'PROXY_SYSTEM' ''
-        osal_kv_delete $HESTIA/conf/hestia.conf 'PROXY_PORT'
-        osal_kv_delete $HESTIA/conf/hestia.conf 'PROXY_SSL_PORT'
-    fi
-
-    if [ "$apache_installed" ] || [ "$nginx_installed" ] ; then
-        # Install default success page
-        mkdir -p /var/www/html
-        mkdir -p /var/www/document_errors
-        if [ ! -f /var/www/html/index.html ]; then
-            cp -rf $HESTIA_INSTALL_DIR/templates/web/unassigned/index.html /var/www/html/
-            cp -rf $HESTIA_INSTALL_DIR/templates/web/skel/document_errors/* /var/www/document_errors/
-        fi
-
-        hestia module web setup-ips
-        # Rebuild domains
-        echo "Rebuilding web domains"
-        for user in $($HESTIA/bin/v-list-sys-users plain); do
-            $BIN/v-rebuild-web-domains $user 'no' > /dev/null 2>&1
-        done
-
-        if [ "$apache_installed" ]; then
-            osal_service_enable $OSAL_SERVICE_APACHE
-            osal_service_start $OSAL_SERVICE_APACHE
-            check_result $? "Apache start failed"
-        fi
-
-        if [ "$nginx_installed" ]; then
-            osal_service_enable $OSAL_SERVICE_NGINX
-            osal_service_start $OSAL_SERVICE_NGINX
-            check_result $? "Nginx start failed"
-        fi
-    fi
-}

+ 0 - 71
bin/module/web/setup-ip.inc

@@ -1,71 +0,0 @@
-#!/bin/bash
-
-hestia_module_web_setup-ip() {
-    source $HESTIA/bin/module/func.inc
-
-    ip=$1
-
-    echo "Configuring web for IP address $ip"
-
-    # Web support
-    if [ ! -z "$WEB_SYSTEM" ]; then
-        web_conf="/etc/$WEB_SYSTEM/conf.d/$ip.conf"
-        hestia_safe_rm $web_conf
-
-        if [ "$WEB_SYSTEM" = 'httpd' ] || [ "$WEB_SYSTEM" = 'apache2' ]; then
-            if [ -z "$(/usr/sbin/apachectl -v | grep Apache/2.4)" ]; then
-                # FIXME: this will break with Apache > 2.4
-                echo "NameVirtualHost $ip:$WEB_PORT" >  $web_conf
-            fi
-            echo "Listen $ip:$WEB_PORT" >> $web_conf
-            cat $HESTIA_INSTALL_DIR/$WEB_SYSTEM/unassigned.conf >> $web_conf
-            sed -i 's/directIP/'$ip'/g' $web_conf
-            sed -i 's/directPORT/'$WEB_PORT'/g' $web_conf
-        elif [ "$WEB_SYSTEM" = 'nginx' ]; then
-            cp -f $HESTIA_INSTALL_DIR/nginx/unassigned.inc $web_conf
-            sed -i 's/directIP/'$ip'/g' $web_conf
-        fi
-
-        if [ "$WEB_SSL" = 'mod_ssl' ]; then
-            if [ -z "$(/usr/sbin/apachectl -v | grep Apache/2.4)" ]; then
-                # FIXME: this will break with Apache > 2.4
-                sed -i "1s/^/NameVirtualHost $ip:$WEB_SSL_PORT\n/" $web_conf
-            fi
-            sed -i "1s/^/Listen $ip:$WEB_SSL_PORT\n/" $web_conf
-            sed -i 's/directSSLPORT/'$WEB_SSL_PORT'/g' $web_conf
-        fi
-    fi
-
-    # Proxy support
-    if [ ! -z "$PROXY_SYSTEM" ]; then
-        cat $WEBTPL/$PROXY_SYSTEM/proxy_ip.tpl |\
-            sed -e "s/%ip%/$ip/g" \
-                -e "s/%web_port%/$WEB_PORT/g" \
-                -e "s/%proxy_port%/$PROXY_PORT/g" \
-            > /etc/$PROXY_SYSTEM/conf.d/$ip.conf
-
-        # mod_extract_forwarded
-        fw_conf="$OSAL_PATH_APACHE_CONF_D/mod_extract_forwarded.conf"
-        if [ -e "$fw_conf" ]; then
-            ips=$(grep 'MEFaccept ' $fw_conf | grep -v '#' | head -n1)
-            sed -i "s/$ips/$ips $ip/g" $fw_conf
-        fi
-
-        # mod_rpaf
-        rpaf_conf="$OSAL_PATH_APACHE_MODS_ENABLED/rpaf.conf"
-        if [ -e "$rpaf_conf" ]; then
-            rpaf_str=$(grep RPAFproxy_ips $rpaf_conf)
-            [ -z "$rpaf_str" ] && sed -i 's|</IfModule>|RPAFproxy_ips\n</IfModule>|' $rpaf_conf && rpaf_str='RPAFproxy_ips'
-            rpaf_str="$rpaf_str $ip"
-            sed -i "s/.*RPAFproxy_ips.*/$rpaf_str/" $rpaf_conf
-        fi
-
-        #mod_remoteip
-        remoteip_conf="$OSAL_PATH_APACHE_MODS_ENABLED/remoteip.conf"
-        if [ -e "$remoteip_conf" ]; then
-            if [ $( grep -ic "$ip" $remoteip_conf ) -eq 0 ]; then
-                sed -i "s/<\/IfModule>/RemoteIPInternalProxy $ip\n<\/IfModule>/g" $remoteip_conf
-            fi
-        fi
-    fi
-}

+ 0 - 50
bin/module/web/setup-ips.inc

@@ -1,50 +0,0 @@
-#!/bin/bash
-
-hestia_module_web_setup-ips() {
-    source $HESTIA/bin/module/func.inc
-
-    if [ "$OS_BASE" = 'debian' ]; then
-        remoteip_conf=$OSAL_PATH_APACHE_MODS_AVAILABLE/remoteip.conf
-    else
-        remoteip_conf=$OSAL_PATH_APACHE_CONF_D/remoteip.conf
-    fi
-
-    # Get main IP
-    local_ip=$(ip addr|grep 'inet '|grep global|head -n1|awk '{print $2}'|cut -f1 -d/)
-    pub_ip=$(curl --ipv4 -s https://ip.hestiacp.com/)
-
-    echo "Configuring web IP addresses (local: $local_ip, public: $pub_ip)"
-
-    # FIXME: the following line should be: if WEB_SYSTEM is apache and PROXY_SYSTEM is something (i.e. not [ null or 'no' ])
-    if ( [ "$WEB_SYSTEM" = 'apache2' ] || [ "$WEB_SYSTEM" = 'httpd' ] ) && [ "$PROXY_SYSTEM" = 'nginx' ]; then
-        echo "Configuring remoteip apache module"
-        # If we are using web server and proxy server, configure mod_remoteip
-        echo "<IfModule mod_remoteip.c>" > $remoteip_conf
-        echo "  RemoteIPHeader X-Real-IP" >> $remoteip_conf
-        if [ "$local_ip" != "127.0.0.1" ] && [ "$pub_ip" != "127.0.0.1" ]; then
-            echo "  RemoteIPInternalProxy 127.0.0.1" >> $remoteip_conf
-        fi
-        if [ ! -z "$local_ip" ] && [ "$local_ip" != "$pub_ip" ]; then
-            echo "  RemoteIPInternalProxy $local_ip" >> $remoteip_conf
-        fi
-        if [ ! -z "$pub_ip" ]; then
-            echo "  RemoteIPInternalProxy $pub_ip" >> $remoteip_conf
-        fi
-        echo "</IfModule>" >> $remoteip_conf
-
-        sed -i "s/LogFormat \"%h/LogFormat \"%a/g" $OSAL_PATH_APACHE_CONF/${OSAL_PKG_APACHE}.conf
-    else
-        # Unconfigure remoteip
-        [ -f $remoteip_conf ] && rm $remoteip_conf
-        sed -i "s/LogFormat \"%a/LogFormat \"%h/g" $OSAL_PATH_APACHE_CONF/${OSAL_PKG_APACHE}.conf
-    fi
-
-    if [ "$OS_BASE" = 'debian' ]; then
-        osal_apache_module_enable remoteip
-    fi
-    
-    for ip_conf in $HESTIA/data/ips/*; do
-        ip=$(basename $ip_conf)
-        hestia module web setup-ip "$ip"
-    done
-}