Something went wrong on our end
-
Stéphane Diemer authoredStéphane Diemer authored
0_setup.py 1.00 KiB
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import utils
def setup(interactive=True):
# Get hostname
utils.log('Getting system hostname.')
code, out = utils.exec_cmd(['hostname'], get_out=True)
if code == 0:
hostname = out
utils.log('Hostname is %s.' % hostname)
else:
raise Exception('Failed to get hostname.')
# Install and configure postfix
dir_path = utils.get_dir(__file__)
cmds = [
'DEBIAN_FRONTEND=noninteractive apt-get -y install postfix mailutils',
'echo "Replacing /etc/postfix/main.cf"',
dict(line='write', template='%s/main.cf' % dir_path, target='/etc/postfix/main.cf', params=(
('{{ hostname }}', hostname),
('{{ smtp }}', utils.get_conf('EMAIL_SMTP_SERVER', '')),
)),
'echo "%s" > /etc/mailname' % hostname,
'rgrep root /etc/aliases || echo "root: sysadmin@ubicast.eu" >> /etc/aliases',
'service postfix restart',
'newaliases',
]
utils.run_commands(cmds)