#!/bin/bash
# info: Restore system configuration
# options: [SYSTEM]
#
# example: v-repair-sys-config
#
# This function repairs or restores the system configuration file.

mode=$1

# 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

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

if [ "$mode" = "restore" ]; then
	syshealth_restore_system_config
fi

if [ "$mode" = "repair" ]; then
	# load config file
	source_conf "$HESTIA/conf/hestia.conf"
	syshealth_repair_system_config
fi

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

$BIN/v-log-action "system" "Info" "System" "Executed $mode operation on system configuration."
log_event "$OK" "$ARGUMENTS"
