forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv-change-sys-config-value
More file actions
executable file
·57 lines (41 loc) · 1.51 KB
/
v-change-sys-config-value
File metadata and controls
executable file
·57 lines (41 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/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 definition
key=$(echo "$1" | tr '[:lower:]' '[:upper:]' )
value=$2
# Includes
source $HESTIA/func/main.sh
source $HESTIA/conf/hestia.conf
PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'KEY VALUE'
is_format_valid 'key'
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Updating conf
check_ckey=$(grep "^$key='" $HESTIA/conf/hestia.conf)
if [ -z "$check_ckey" ]; then
echo "$key='$value'" >> $HESTIA/conf/hestia.conf
else
sed -i "s|$key=.*|$key='$value'|g" $HESTIA/conf/hestia.conf
fi
if [ "$key" = "BACKUP" ] && [ "$value" != '/backup' ]; then
rm /backup
ln -s $value /backup
fi
#----------------------------------------------------------#
# Hestia #
#----------------------------------------------------------#
# Logging
log_event "$OK" "$ARGUMENTS"
exit