Files
VestaCP/bin/v_change_sys_config_value
2012-01-03 21:46:07 +02:00

58 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# info: change sysconfig value
# options: key value
#
# The function is for changing main config settings such as COMPANY_NAME or
# COMPANY_EMAIL and so on.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
key=$(echo "$1" | tr '[:lower:]' '[:upper:]' )
value=${2// /%spc%}
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking args
check_args '2' "$#" 'key value'
# Checking argument format
format_validation 'key'
# Checking key existance
check_ckey=$(grep "^$key='" $V_CONF/vesta.conf)
if [ -z "$check_ckey" ]; then
echo "Error: key not found"
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Updating conf
sed -i "s/$key=.*/$key='$value'/g" $V_CONF/vesta.conf
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
exit