summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2016-03-07 07:49:03 +0100
committerJohannes Löthberg <johannes@kyriasis.com>2016-03-07 07:49:03 +0100
commit99b7343ed08ba879b383db34db7b12e8a8ccbced (patch)
tree87c42c5947335f02e71dd09893ef580c6933b84a
parent2caad1713e1dd64a7f4db9a27984b4762a0694b5 (diff)
downloadsmtpd-conf-99b7343ed08ba879b383db34db7b12e8a8ccbced.tar.xz
fabfile: stuff..HEADmaster
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
-rw-r--r--fabfile.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/fabfile.py b/fabfile.py
index cfaa33e..e246ae4 100644
--- a/fabfile.py
+++ b/fabfile.py
@@ -4,6 +4,11 @@ env.hosts = ['theos.kyriasis.com', 'lucifer.kyriasis.com']
def checksum_match(local_file, remote_file):
+ from fabric.contrib.files import exists
+
+ if not exists(remote_file):
+ return False
+
md5 = '/usr/bin/md5sum {}'
local_sum = local(md5.format(local_file), capture=True).split()[0]
remote_sum = run(md5.format(remote_file)).split()[0]
@@ -13,8 +18,9 @@ def checksum_match(local_file, remote_file):
@task
def deploy():
- upload_users()
upload_conf()
+ upload_table('users', 'common/users')
+ upload_table('senders', 'common/senders')
@task
@@ -31,13 +37,13 @@ def upload_conf():
@task
-def upload_users():
+def upload_table(table_name, local_path):
from fabric.colors import green
- local_file = 'common/users'
+ remote_path = '/etc/smtpd/' + table_name
- if not checksum_match(local_file, '/etc/smtpd/users'):
- print(green('==> Users changed, uploading new file...'))
- put(local_path=local_file, remote_path='/etc/smtpd/users',
- use_sudo=True)
- sudo('smtpctl update table users')
+ if not checksum_match(local_path, remote_path):
+ print(green('==> Table {} changed, uploading new one...'
+ .format(table_name)))
+ put(local_path=local_path, remote_path=remote_path, use_sudo=True)
+ sudo('smtpctl update table {}'.format(table_name))