From 99b7343ed08ba879b383db34db7b12e8a8ccbced Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Mon, 7 Mar 2016 07:49:03 +0100 Subject: fabfile: stuff.. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Johannes Löthberg --- fabfile.py | 22 ++++++++++++++-------- 1 file 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)) -- cgit v1.2.3-70-g09d2