Skip to content

Commit

Permalink
Merge pull request #2 from wazo-communication/update-script
Browse files Browse the repository at this point in the history
Update script
  • Loading branch information
fouille authored Feb 22, 2021
2 parents 4843eb0 + f8f5ae4 commit 38bb1f3
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 144 deletions.
9 changes: 9 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This is the official list of Wazo authors for copyright purposes.

# Names should be added to this file as one of
# Organization's name
# Individual's name <email address>

# Please keep the list sorted.

Wazo Communication Inc.
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
# Wazo modify Mail configuration
If you want modify the SMTP origin parameter (default : exemple.wazo.community) to your personal parameter <br>
Or Domain, relayHost / fallback relayHost and Canical.<br>
Autogenered edited file /etc/xivo/common.conf<br>
Genered file /etc/mailname<br>
and insert to database.<br>

If you want modify the SMTP origin parameter (default : exemple.wazo.community) to your personal parameter or Domain, relayHost/fallback relayHost and Canical.

This script do:

* Auto-generated edited file /etc/xivo/common.conf
* Generated file /etc/mailname
* And insert to database.

# Wazo version
Wazo version >= 19.12<br>

# Installation
Wazo version >= 19.12

# Installation

Connect to your stack and get the root.

apt install wazo-plugind-cli
wazo-plugind-cli -c "install git https://github.com/wazo-communication/wazo-update-smtp-origin"

# Usage

```console
foo@bar:~$ cd /tmp/
foo@bar:/tmp$ wget https://raw.githubusercontent.com/fouille/wazo_update_smtp_origin/master/update_smtp_origin.sh
foo@bar:/tmp$ chmod +x update_smtp_origin.sh
foo@bar:/tmp$ ./update_smtp_origin.sh
```
wazo-update-smtp-origin

Read instruction into dialog box
131 changes: 0 additions & 131 deletions update_smtp_origin.sh

This file was deleted.

134 changes: 134 additions & 0 deletions wazo-update-smtp-origin
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
10 changes: 10 additions & 0 deletions wazo/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: wazo-smtp-configuration
namespace: official
version: 1.0.0
author: Wazo Support
display_name: SMTP configuration
min_wazo_version: 20.01
tags:
- support
- mail
homepage: http://support.wazo.io
25 changes: 25 additions & 0 deletions wazo/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0+


case "$1" in
build)
;;

package)
chmod +x wazo-update-smtp-origin
mkdir -p ${pkgdir}/usr/local/bin
cp wazo-update-smtp-origin ${pkgdir}/usr/local/bin/
;;

install)
;;

uninstall)
;;

*)
echo "$0 called with unknown argument '$1'" >&2
exit 1
;;
esac

0 comments on commit 38bb1f3

Please sign in to comment.