Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mailinabox
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mailinabox
Commits
49d55619
Commit
49d55619
authored
Jul 06, 2014
by
Joshua Tauberer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
when adding/removing mail addresses also update nginx's config
parent
c8856f10
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
17 deletions
+34
-17
nginx.conf
conf/nginx.conf
+4
-1
dns_update.py
management/dns_update.py
+2
-2
mailconfig.py
management/mailconfig.py
+18
-11
web_update.py
management/web_update.py
+10
-3
No files found.
conf/nginx.conf
View file @
49d55619
## NOTE: This file is automatically generated by Mail-in-a-Box.
## Do not edit this file. It will be replaced each time
## Mail-in-a-Box needs up update the web configuration.
# Redirect all HTTP to HTTPS.
# Redirect all HTTP to HTTPS.
server
{
server
{
listen
80
;
listen
80
;
...
@@ -9,7 +13,6 @@ server {
...
@@ -9,7 +13,6 @@ server {
}
}
# The secure HTTPS server.
# The secure HTTPS server.
server
{
server
{
listen
443
ssl
;
listen
443
ssl
;
...
...
management/dns_update.py
View file @
49d55619
...
@@ -118,10 +118,10 @@ def do_dns_update(env):
...
@@ -118,10 +118,10 @@ def do_dns_update(env):
shell
(
'check_call'
,
[
"/usr/sbin/service"
,
"opendkim"
,
"restart"
])
shell
(
'check_call'
,
[
"/usr/sbin/service"
,
"opendkim"
,
"restart"
])
if
len
(
updated_domains
)
==
0
:
if
len
(
updated_domains
)
==
0
:
# if nothing was updated (except maybe
DKIM
), don't show any output
# if nothing was updated (except maybe
OpenDKIM's files
), don't show any output
return
""
return
""
else
:
else
:
return
"updated: "
+
","
.
join
(
updated_domains
)
+
"
\n
"
return
"updated
DNS
: "
+
","
.
join
(
updated_domains
)
+
"
\n
"
########################################################################
########################################################################
...
...
management/mailconfig.py
View file @
49d55619
...
@@ -91,9 +91,8 @@ def add_mail_user(email, pw, env):
...
@@ -91,9 +91,8 @@ def add_mail_user(email, pw, env):
shutil
.
copyfile
(
utils
.
CONF_DIR
+
"/dovecot_sieve.txt"
,
user_mail_dir
+
"/.dovecot.sieve"
)
shutil
.
copyfile
(
utils
.
CONF_DIR
+
"/dovecot_sieve.txt"
,
user_mail_dir
+
"/.dovecot.sieve"
)
os
.
chown
(
user_mail_dir
+
"/.dovecot.sieve"
,
maildirstat
.
st_uid
,
maildirstat
.
st_gid
)
os
.
chown
(
user_mail_dir
+
"/.dovecot.sieve"
,
maildirstat
.
st_uid
,
maildirstat
.
st_gid
)
# Update DNS in case any new domains are added.
# Update DNS/web in case any new domains are added.
from
dns_update
import
do_dns_update
return
kick
(
env
,
"mail user added"
)
return
do_dns_update
(
env
)
def
set_mail_password
(
email
,
pw
,
env
):
def
set_mail_password
(
email
,
pw
,
env
):
# hash the password
# hash the password
...
@@ -114,9 +113,8 @@ def remove_mail_user(email, env):
...
@@ -114,9 +113,8 @@ def remove_mail_user(email, env):
return
(
"That's not a user (
%
s)."
%
email
,
400
)
return
(
"That's not a user (
%
s)."
%
email
,
400
)
conn
.
commit
()
conn
.
commit
()
# Update DNS in case any domains are removed.
# Update DNS/web in case any domains are removed.
from
dns_update
import
do_dns_update
return
kick
(
env
,
"mail user removed"
)
return
do_dns_update
(
env
)
def
add_mail_alias
(
source
,
destination
,
env
):
def
add_mail_alias
(
source
,
destination
,
env
):
if
not
validate_email
(
source
,
False
):
if
not
validate_email
(
source
,
False
):
...
@@ -129,9 +127,8 @@ def add_mail_alias(source, destination, env):
...
@@ -129,9 +127,8 @@ def add_mail_alias(source, destination, env):
return
(
"Alias already exists (
%
s)."
%
source
,
400
)
return
(
"Alias already exists (
%
s)."
%
source
,
400
)
conn
.
commit
()
conn
.
commit
()
# Update DNS in case any new domains are added.
# Update DNS/web in case any new domains are added.
from
dns_update
import
do_dns_update
return
kick
(
env
,
"alias added"
)
return
do_dns_update
(
env
)
def
remove_mail_alias
(
source
,
env
):
def
remove_mail_alias
(
source
,
env
):
conn
,
c
=
open_database
(
env
,
with_connection
=
True
)
conn
,
c
=
open_database
(
env
,
with_connection
=
True
)
...
@@ -140,9 +137,19 @@ def remove_mail_alias(source, env):
...
@@ -140,9 +137,19 @@ def remove_mail_alias(source, env):
return
(
"That's not an alias (
%
s)."
%
source
,
400
)
return
(
"That's not an alias (
%
s)."
%
source
,
400
)
conn
.
commit
()
conn
.
commit
()
# Update DNS in case any domains are removed.
# Update DNS and nginx in case any domains are removed.
return
kick
(
env
,
"alias removed"
)
def
kick
(
env
,
mail_result
):
# Update DNS and nginx in case any domains are added/removed.
from
dns_update
import
do_dns_update
from
dns_update
import
do_dns_update
return
do_dns_update
(
env
)
from
web_update
import
do_web_update
results
=
[
do_dns_update
(
env
),
mail_result
+
"
\n
"
,
do_web_update
(
env
),
]
return
""
.
join
(
s
for
s
in
results
if
s
!=
""
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
import
sys
import
sys
...
...
management/web_update.py
View file @
49d55619
...
@@ -31,14 +31,21 @@ def do_web_update(env):
...
@@ -31,14 +31,21 @@ def do_web_update(env):
for
domain
in
get_web_domains
(
env
):
for
domain
in
get_web_domains
(
env
):
nginx_conf
+=
make_domain_config
(
domain
,
template
,
env
)
nginx_conf
+=
make_domain_config
(
domain
,
template
,
env
)
# Did the file change? If not, don't bother writing & restarting nginx.
nginx_conf_fn
=
"/etc/nginx/conf.d/local.conf"
if
os
.
path
.
exists
(
nginx_conf_fn
):
with
open
(
nginx_conf_fn
)
as
f
:
if
f
.
read
()
==
nginx_conf
:
return
""
# Save the file.
# Save the file.
with
open
(
"/etc/nginx/conf.d/local.conf"
,
"w"
)
as
f
:
with
open
(
nginx_conf_fn
,
"w"
)
as
f
:
f
.
write
(
nginx_conf
)
f
.
write
(
nginx_conf
)
#
N
ick nginx.
#
K
ick nginx.
shell
(
'check_call'
,
[
"/usr/sbin/service"
,
"nginx"
,
"restart"
])
shell
(
'check_call'
,
[
"/usr/sbin/service"
,
"nginx"
,
"restart"
])
return
"
OK
"
return
"
web updated
\n
"
def
make_domain_config
(
domain
,
template
,
env
):
def
make_domain_config
(
domain
,
template
,
env
):
# How will we configure this domain.
# How will we configure this domain.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment