forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv-add-sys-smtp-relay
More file actions
63 lines (49 loc) · 1.83 KB
/
v-add-sys-smtp-relay
File metadata and controls
63 lines (49 loc) · 1.83 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
#!/bin/bash
# info: add system wide smtp relay support
# options: HOST USERNAME PASSWORD [PORT]
# labels: hestia
#
# example: v-add-sys-smtp-relay srv.smtprelay.tld uname123 pass12345
#
# this function adds system wide smtp relay support.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument definition
host=$1
username=$2
password=$3
port=${4-587}
# Includes
# shellcheck source=/usr/local/hestia/func/main.sh
source $HESTIA/func/main.sh
# shellcheck source=/usr/local/hestia/conf/hestia.conf
source $HESTIA/conf/hestia.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '3' "$#" 'HOST USERNAME PASSWORD'
is_format_valid 'port'
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
# Perform verification if read-only mode is enabled
check_hestia_demo_mode
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
$BIN/v-change-sys-config-value SMTP_RELAY 'true'
$BIN/v-change-sys-config-value SMTP_RELAY_HOST $host
$BIN/v-change-sys-config-value SMTP_RELAY_PORT $port
$BIN/v-change-sys-config-value SMTP_RELAY_USER $username
cat >/etc/exim4/smtp_relay.conf << EOL
host:$host
port:$port
user:$username
pass:$password
EOL
#----------------------------------------------------------#
# Hestia #
#----------------------------------------------------------#
# Logging
$BIN/v-log-action "system" "Info" "Mail" "Server-wide SMTP Relay enabled (Host: $host, Port: $port)."
log_event "$OK" "$ARGUMENTS"
exit