#!/bin/bash
# info: update default key database
# options: [SYSTEM]
#
# example: v-update-sys-defaults
# example: v-update-sys-defaults user
#
# This function updates the known key/value pair database

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

system=$1

# Includes
# shellcheck source=/etc/tuliocp/tulio.conf
source /etc/tuliocp/tulio.conf
# shellcheck source=/usr/local/tulio/func/main.sh
source $TULIO/func/main.sh
# shellcheck source=/usr/local/tulio/func/syshealth.sh
source $TULIO/func/syshealth.sh
# load config file
source_conf "$TULIO/conf/tulio.conf"

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

if [ -n "$system" ]; then
	syshealth_update_${system}_config_format
else
	syshealth_update_web_config_format
	syshealth_update_mail_config_format
	syshealth_update_dns_config_format
	syshealth_update_db_config_format
	syshealth_update_user_config_format
fi

#----------------------------------------------------------#
#                        Tulio                            #
#----------------------------------------------------------#

log_event "$OK" "$ARGUMENTS"
