forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv-change-mail-domain-sslcert
More file actions
executable file
·76 lines (57 loc) · 2.16 KB
/
v-change-mail-domain-sslcert
File metadata and controls
executable file
·76 lines (57 loc) · 2.16 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
68
69
70
71
72
73
74
75
76
#!/bin/bash
# info: change domain ssl certificate
# options: USER DOMAIN SSL_DIR [RESTART]
# labels: hestia
#
# The function changes SSL domain certificate and the key. If ca file present
# it will be replaced as well.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument definition
user=$1
domain=$2
domain_idn=$2
restart=$3
# Includes
# shellcheck source=/usr/local/hestia/func/main.sh
source $HESTIA/func/main.sh
# shellcheck source=/usr/local/hestia/func/domain.sh
source $HESTIA/func/domain.sh
# shellcheck source=/usr/local/hestia/conf/hestia.conf
source $HESTIA/conf/hestia.conf
# Additional argument formatting
format_domain
format_domain_idn
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '3' "$#" 'USER DOMAIN SSL_DIR [RESTART]'
is_format_valid 'user' 'domain' 'ssl_dir'
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain_idn"
is_object_unsuspended 'mail' 'DOMAIN' "$domain_idn"
is_object_value_empty 'mail' 'DOMAIN' "$domain_idn" '$SSL'
is_web_domain_cert_valid
# Perform verification if read-only mode is enabled
check_hestia_demo_mode
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Remove old configuration
del_mail_ssl_config
# Create new configuration
add_mail_ssl_config
#----------------------------------------------------------#
# Hestia #
#----------------------------------------------------------#
# Restarting mail server
$BIN/v-restart-mail $restart
check_result $? "Mail restart failed" >/dev/null
# Logging
$BIN/v-log-action "$user" "Info" "Web" "Changed SSL certificate (Domain: $domain)."
log_history "changed ssl certificate for $domain"
log_event "$OK" "$ARGUMENTS"
exit