forked from outroll/vesta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv-change-user-template
executable file
·56 lines (42 loc) · 1.63 KB
/
v-change-user-template
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
#!/bin/bash
# info: change user default template
# options: USER TYPE TEMPLATE
#
# The function changes default user web template.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
type=$(echo "$2" | tr '[:lower:]' '[:upper:]')
template=$3
# Includes
source $VESTA/func/main.sh
source $VESTA/func/domain.sh
source $VESTA/conf/vesta.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '3' "$#" 'USER TYPE TEMPLATE'
validate_format 'user' 'template'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
case $type in
WEB) is_web_template_valid;
update_user_value "$user" '$WEB_TEMPLATE' "$template";;
PROXY) is_proxy_template_valid;
update_user_value "$user" '$PROXY_TEMPLATE' "$template";;
DNS) is_dns_template_valid;
update_user_value "$user" '$DNS_TEMPLATE' "$template";;
*) check_args '1' '0' 'USER TYPE TEMPLATE'
esac
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_history "changed $type template to $template"
log_event "$OK" "$EVENT"
exit