forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv-change-sys-language
More file actions
executable file
·67 lines (50 loc) · 1.79 KB
/
v-change-sys-language
File metadata and controls
executable file
·67 lines (50 loc) · 1.79 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
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# info: change sys language
# options: LANGUAGE
#
# The function for changing system language.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument definition
language=$1
update_users=$2
# Includes
source $HESTIA/func/main.sh
source $HESTIA/conf/hestia.conf
is_language_valid() {
if [ ! -d "$HESTIA/web/locale/$language" ]; then
echo "Error: language file $language doesn't exist"
log_event "$E_NOTEXIST $ARGUMENTS"
exit $E_NOTEXIST
fi
}
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '1' "$#" 'LANGUAGE'
is_format_valid 'language'
is_language_valid $language
# Perform verification if read-only mode is enabled
check_hestia_demo_mode
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Change language
if [ -z "$(grep LANGUAGE $HESTIA/conf/hestia.conf)" ]; then
echo "LANGUAGE='$language'" >> $HESTIA/conf/hestia.conf
else
sed -i "s/LANGUAGE=.*/LANGUAGE='$language'/g" $HESTIA/conf/hestia.conf
fi
# Update language for all existing users if specified
if [ "$update_users" = "yes" ]; then
for user in $($HESTIA/bin/v-list-sys-users plain); do
$BIN/v-change-user-language $user $language
done
fi
#----------------------------------------------------------#
# Hestia #
#----------------------------------------------------------#
# Logging
log_event "$OK" "$ARGUMENTS"
exit