-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwazo-update-smtp-origin
executable file
·134 lines (93 loc) · 3.76 KB
/
wazo-update-smtp-origin
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
# Copyright 2021 The Wazo Authors (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later
bye() {
whiptail --title "Hello Wazo HELP / Modify SMTP Origin" --msgbox "Your SMTP origin has been modified\nHave a nice day :-) Wazo Support." 10 60
}
update_smtp_origin() {
SMTP_Origin=$(whiptail --title "Hello Wazo HELP / Modify SMTP Origin" --inputbox "Please write your new SMTP Origin Domain (ex.: domain.tld):" 13 60 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
{
echo -e "XXX\n0\nAdd in DB, Please Wait... \nXXX"
sudo -u postgres psql asterisk -c "UPDATE mail SET origin='$SMTP_Origin';";
echo -e "XXX\n50\nAdd $SMTP_Origin in DB... Done.\nXXX"
sleep 0.5
} | whiptail --gauge "Wait Please" 6 60 0
fi
update_domain
}
update_domain() {
domain=$(whiptail --title "Hello Wazo HELP / Modify Domain" \
--inputbox "Please write your Domain (ex.: domain.tdl):" 13 60 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
{
echo -e "XXX\n0\nAdd in DB, Please Wait... \nXXX"
sudo -u postgres psql asterisk -c "UPDATE mail SET mydomain='$domain';";
echo -e "XXX\n50\nAdd in DB... Done.\nXXX"
sleep 0.5
} | whiptail --gauge "Wait Please" 6 60 0
fi
update_canonical
}
update_canonical() {
Canonical=$(whiptail --title "Hello Wazo HELP / Modify Canonical" \
--inputbox "Please write user part from your mail for Canonical (mail user part ex.: noreply):" 13 60 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
{
echo -e "XXX\n0\nAdd in DB, Please Wait... \nXXX"
sudo -u postgres psql asterisk -c "UPDATE mail SET canonical='root $Canonical\nasterisk $Canonical\nwazo-agid $Canonical\nwazo-auth $Canonical\nwazo-amid $Canonical\nmunin $Canonical\nwazo $Canonical';";
echo -e "XXX\n50\nAdd in DB... Done.\nXXX"
sleep 0.5
} | whiptail --gauge "Wait Please" 6 60 0
fi
update_relayhost
}
update_relayhost() {
Relayhost=$(whiptail --title "Hello Wazo HELP / Modify relayhost" \
--inputbox "Please write Relay Host (ex.: smtp.domain.tld | no relay? leave empty):" 13 60 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
{
echo -e "XXX\n0\nAdd in DB, Please Wait... \nXXX"
sudo -u postgres psql asterisk -c "UPDATE mail SET relayhost='$Relayhost';";
echo -e "XXX\n50\nAdd in DB... Done.\nXXX"
sleep 0.5
} | whiptail --gauge "Wait Please" 6 60 0
fi
update_fallback_relayhost
}
update_fallback_relayhost() {
fallback_relayhost=$(whiptail --title "Hello Wazo HELP / Modify fallback_relayhost" \
--inputbox "Please write fallback relay host (ex.: smtp2.domain.tld | no fallback relay? leave empty):" 13 60 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
{
echo -e "XXX\n0\nAdd in DB, Please Wait... \nXXX"
sudo -u postgres psql asterisk -c "UPDATE mail SET fallback_relayhost='$fallback_relayhost';";
echo -e "XXX\n50\nAdd in DB... Done.\nXXX"
sleep 0.5
} | whiptail --gauge "Wait Please" 6 60 0
fi
final_step
}
final_step() {
exitstatus=$?
if [ $exitstatus = 0 ]; then
{
echo -e "XXX\n50\nCreate new config... \nXXX"
xivo-create-config
echo -e "XXX\n100\nCreate Config... Done.\nXXX"
sleep 0.5
echo -e "XXX\n50\nUpdate new config... \nXXX"
xivo-update-config
echo -e "XXX\n100\nUpdate Config... Done.\nXXX"
sleep 0.5
} | whiptail --gauge "Wait Please" 6 60 0
bye
fi
}
# Main
update_smtp_origin