#!/bin/bash
# info: delete web terminal
# options: NONE
#
# example: v-delete-sys-web-terminal
#
# This function disables the web terminal.

#----------------------------------------------------------#
#                Variables & Functions                     #
#----------------------------------------------------------#

# Includes
# shellcheck source=/etc/hestiacp/hestia.conf
source /etc/hestiacp/hestia.conf
# shellcheck source=/usr/local/hestia/func/main.sh
source $HESTIA/func/main.sh
# load config file
source_conf "$HESTIA/conf/hestia.conf"

#----------------------------------------------------------#
#                    Verifications                         #
#----------------------------------------------------------#

if [ -z "$WEB_TERMINAL" ]; then
	exit
fi

# Perform verification if read-only mode is enabled
check_hestia_demo_mode

#----------------------------------------------------------#
#                       Action                             #
#----------------------------------------------------------#

# Updating WEB_TERMINAL value
$BIN/v-change-sys-config-value "WEB_TERMINAL" "false"

# Stopping web terminal websocket server
$BIN/v-stop-service "hestia-web-terminal"
systemctl disable hestia-web-terminal

#----------------------------------------------------------#
#                       Hestia                             #
#----------------------------------------------------------#

# Logging
$BIN/v-log-action "system" "Warning" "Web Terminal" "Web terminal disabled."
log_event "$OK" "$ARGUMENTS"

exit
