Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mediaserver
envsetup
Commits
df23ae84
Commit
df23ae84
authored
7 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Configure sender address in postfix (refs
#22099
).
parent
26cb5431
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
2.Common_services/1.Postfix/0_setup.py
+25
-9
25 additions, 9 deletions
2.Common_services/1.Postfix/0_setup.py
2.Common_services/1.Postfix/main.cf
+1
-0
1 addition, 0 deletions
2.Common_services/1.Postfix/main.cf
with
26 additions
and
9 deletions
2.Common_services/1.Postfix/0_setup.py
+
25
−
9
View file @
df23ae84
...
@@ -12,25 +12,41 @@ def setup(interactive=True):
...
@@ -12,25 +12,41 @@ def setup(interactive=True):
else
:
else
:
raise
Exception
(
'
Failed to get hostname.
'
)
raise
Exception
(
'
Failed to get hostname.
'
)
# Install and configure postfix
# Install and configure postfix
server
=
utils
.
get_conf
(
'
EMAIL_SMTP_SERVER
'
,
''
)
if
not
server
:
# with relayless cases emails are not always delivered to google mailing lists unless mailname is ubicast.eu and DNS spf records are set
mailname
=
'
ubicast.eu
'
else
:
mailname
=
utils
.
get_conf
(
'
MS_SERVER_NAME
'
,
hostname
)
dir_path
=
utils
.
get_dir
(
__file__
)
dir_path
=
utils
.
get_dir
(
__file__
)
server
=
utils
.
get_conf
(
'
EMAIL_SMTP_SERVER
'
,
''
)
cmds
=
[
cmds
=
[
'
DEBIAN_FRONTEND=noninteractive apt-get install -y postfix mailutils
'
,
'
DEBIAN_FRONTEND=noninteractive apt-get install -y postfix mailutils
'
,
'
echo
"
Replacing /etc/postfix/main.cf
"'
,
dict
(
line
=
'
write
'
,
template
=
'
%s/main.cf
'
%
dir_path
,
target
=
'
/etc/postfix/main.cf
'
,
params
=
(
dict
(
line
=
'
write
'
,
template
=
'
%s/main.cf
'
%
dir_path
,
target
=
'
/etc/postfix/main.cf
'
,
params
=
(
(
'
{{ hostname }}
'
,
hostname
),
(
'
{{ hostname }}
'
,
hostname
),
(
'
{{ smtp }}
'
,
server
),
(
'
{{ smtp }}
'
,
server
),
)),
)),
]
# Configure mail aliases
if
not
server
:
# with relayless cases emails are not always delivered to google mailing lists unless mailname is ubicast.eu and DNS spf records are set
mailname
=
'
ubicast.eu
'
else
:
mailname
=
utils
.
get_conf
(
'
MS_SERVER_NAME
'
)
if
not
mailname
or
mailname
==
'
mediaserver
'
:
mailname
=
hostname
cmds
.
extend
([
'
echo
"
%s
"
> /etc/mailname
'
%
mailname
,
'
echo
"
%s
"
> /etc/mailname
'
%
mailname
,
'
rgrep
"
root:
"
/etc/aliases || echo
"
root: sysadmin@ubicast.eu
"
>> /etc/aliases
'
,
'
rgrep
"
root:
"
/etc/aliases || echo
"
root: sysadmin@ubicast.eu
"
>> /etc/aliases
'
,
'
service postfix restart
'
,
'
newaliases
'
,
'
newaliases
'
,
]
])
# Configure mail sender
sender
=
utils
.
get_conf
(
'
EMAIL_SENDER
'
,
''
)
sender_domain
=
sender
.
split
(
'
@
'
)[
-
1
]
if
sender_domain
:
if
sender_domain
==
'
ubicast.eu
'
and
utils
.
get_conf
(
'
MS_SERVER_NAME
'
,
''
)
not
in
(
''
,
'
mediaserver
'
):
sender_domain
=
utils
.
get_conf
(
'
MS_SERVER_NAME
'
)
cmds
.
extend
([
'
rm -f /etc/postfix/generic
'
,
'
echo
"
root@localhost %s@%s
"
>> /etc/postfix/generic
'
%
(
hostname
,
sender_domain
),
'
echo
"
root@%s %s@%s
"
>> /etc/postfix/generic
'
%
(
hostname
,
hostname
,
sender_domain
),
'
postmap hash:/etc/postfix/generic
'
,
])
cmds
.
append
(
'
service postfix restart
'
)
utils
.
run_commands
(
cmds
)
utils
.
run_commands
(
cmds
)
# Setup authentication if any
# Setup authentication if any
user
=
utils
.
get_conf
(
'
EMAIL_SMTP_USER
'
)
user
=
utils
.
get_conf
(
'
EMAIL_SMTP_USER
'
)
...
...
This diff is collapsed.
Click to expand it.
2.Common_services/1.Postfix/main.cf
+
1
−
0
View file @
df23ae84
...
@@ -40,3 +40,4 @@ inet_protocols = ipv4
...
@@ -40,3 +40,4 @@ inet_protocols = ipv4
default_transport = smtp
default_transport = smtp
relay_transport = smtp
relay_transport = smtp
disable_vrfy_command = yes
disable_vrfy_command = yes
smtp_generic_maps = hash:/etc/postfix/generic
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment