mirror of
https://github.com/myvesta/vesta
synced 2025-08-14 18:49:21 -07:00
system configuration change tool
This commit is contained in:
parent
78ddc14c6b
commit
7e5f0883bd
1 changed files with 51 additions and 0 deletions
51
bin/v_change_sys_config_value
Executable file
51
bin/v_change_sys_config_value
Executable file
|
@ -0,0 +1,51 @@
|
|||
#!/bin/bash
|
||||
# info: changing sysconfig value
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
key=$(echo "$1" | tr '[:lower:]' '[:upper:]' )
|
||||
value=${2// /%spc%}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.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_KEY_INVALID $V_EVENT"
|
||||
exit $E_KEY_INVALID
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Updating conf
|
||||
sed -i "s/$key=.*/$key='$value'/g" /tmp/vesta.conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit
|
Loading…
Add table
Add a link
Reference in a new issue