Skip to content

Commit 7e5f088

Browse files
committed
system configuration change tool
1 parent 78ddc14 commit 7e5f088

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

bin/v_change_sys_config_value

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
# info: changing sysconfig value
3+
4+
#----------------------------------------------------------#
5+
# Variable&Function #
6+
#----------------------------------------------------------#
7+
8+
# Argument defenition
9+
key=$(echo "$1" | tr '[:lower:]' '[:upper:]' )
10+
value=${2// /%spc%}
11+
12+
# Importing variables
13+
source $VESTA/conf/vars.conf
14+
source $V_FUNC/shared.func
15+
16+
17+
#----------------------------------------------------------#
18+
# Verifications #
19+
#----------------------------------------------------------#
20+
21+
# Checking args
22+
check_args '2' "$#" 'key value'
23+
24+
# Checking argument format
25+
format_validation 'key'
26+
27+
# Checking key existance
28+
check_ckey=$(grep "^$key='" $V_CONF/vesta.conf)
29+
if [ -z "$check_ckey" ]; then
30+
echo "Error: key not found"
31+
log_event 'debug' "$E_KEY_INVALID $V_EVENT"
32+
exit $E_KEY_INVALID
33+
fi
34+
35+
36+
#----------------------------------------------------------#
37+
# Action #
38+
#----------------------------------------------------------#
39+
40+
# Updating conf
41+
sed -i "s/$key=.*/$key='$value'/g" /tmp/vesta.conf
42+
43+
44+
#----------------------------------------------------------#
45+
# Vesta #
46+
#----------------------------------------------------------#
47+
48+
# Logging
49+
log_event 'system' "$V_EVENT"
50+
51+
exit

0 commit comments

Comments
 (0)