Suspension logic

When I suspend user, why does website is not suspended? Only when I explicitly suspend website within that user I receive " This site is currently suspended" message when visiting website in question.

Because probally it is a bug but currently busy with other paying projects… so can’t dedicate all my days on Hestia

Hello @culibine,

Are you the same user of this issue?

If you are not, are you using Apache too?

I tested it in my own install and it is working fine, it is suspending the user and the web domains of the user but I’m not using Apache so I can’t test whether that is affecting the suspension.

If you want to test… I would test it myself but I can’t reproduce the bug in my installation using only Nginx and I’m a bit busy to install a new Hestia with Apache to just test it.

Create file /usr/local/hestia/bin/t-suspend-user with this content:

#!/bin/bash
user=$1
restart=$2
source /etc/hestiacp/hestia.conf
source $HESTIA/func/main.sh
source_conf "$HESTIA/conf/hestia.conf"

check_args '1' "$#" 'USER [RESTART]'.

is_format_valid 'user'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
if [ "$user" = 'admin' ]; then
        exit
fi

if [ -n "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
        echo "Executing $BIN/t-suspend-web-domains "$user" "no""
        echo ""
        $BIN/t-suspend-web-domains "$user" "no"
fi

Create file /usr/local/hestia/bin/t-suspend-web-domains with this content:

#!/bin/bash
user=$1
source /etc/hestiacp/hestia.conf
source $HESTIA/func/main.sh
source $HESTIA/func/domain.sh
source_conf "$HESTIA/conf/hestia.conf"

check_args '1' "$#" 'USER [RESTART]'
is_format_valid 'user'
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"

for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do
        echo "$BIN/t-suspend-web-domain "$user" "$domain" 'no'"
        echo ""
        $BIN/t-suspend-web-domain "$user" "$domain" 'no'
        echo "##################################################"
        echo ""
done

Create file /usr/local/hestia/bin/t-suspend-web-domain with this content:

#!/bin/bash
user=$1
domain=$2
domain_idn=$2
restart=$3

source /etc/hestiacp/hestia.conf
source $HESTIA/func/main.sh
source $HESTIA/func/domain.sh
source $HESTIA/func/ip.sh
source_conf "$HESTIA/conf/hestia.conf"

format_domain
format_domain_idn

check_args '2' "$#" 'USER DOMAIN [RESTART]'
is_format_valid 'user' 'domain'
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain"

get_domain_values 'web'
SUSPENDED='yes'
local_ip=$(get_real_ip $IP)

prepare_web_domain_values

echo "del_web_config "$WEB_SYSTEM" "$TPL.tpl""
echo "add_web_config "$WEB_SYSTEM" "$TPL.tpl""
if [ "$SSL" = 'yes' ]; then
        echo "del_web_config "$WEB_SYSTEM" "$TPL.stpl""
        echo "add_web_config "$WEB_SYSTEM" "$TPL.stpl""
fi

if [ -n "$PROXY_SYSTEM" ] && [ -n "$PROXY" ]; then
        echo "del_web_config "$PROXY_SYSTEM" "$PROXY.tpl""
        echo "add_web_config "$PROXY_SYSTEM" "$PROXY.tpl""
        if [ "$SSL" = 'yes' ]; then
                echo "del_web_config "$PROXY_SYSTEM" "$PROXY.stpl""
                echo "add_web_config "$PROXY_SYSTEM" "$PROXY.stpl""
        fi
fi
echo "update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'yes'"
echo "increase_user_value "$user" '$SUSPENDED_WEB'"
echo "$BIN/v-rebuild-web-domain "$user" "$domain" 'no'"
echo "$BIN/v-restart-web "$restart""
echo "$BIN/v-restart-proxy "$restart""

Give execution perms to the three files:

chmod +x /usr/local/hestia/bin/t-suspend*

And execute script t-suspend-user changing YourUser by the real user you want to suspend.

/usr/local/hestia/bin/t-susppend-user YourUser

And show the output.

Note: Those scripts won’t suspend neither the user nor domains, the test scripts will modify nothing, they will only show the commands that would be executed when used.

Cheers,
sahsanu

Yes, I’am using Apache and nginx. Seems it is not bug, but a feature (?):

If I do not explicitly pass ā€œyesā€ to v-susppend-user changes are not visible, because default behavior is ā€œnoā€ to restart. So:

v-susppend-user john yes

And everything works as it should be.

v-suspend-user requires restart of the nignx / apache2…

And by default we set it to no…

And

But if it is never set it will never restart. Even empty string should mean reload …

Should fix the issue

For v-suspend-user make sure to use the restart flag set to yes if you want to suspend.

Or restart services when done multiple suspending actions…

1 Like