diff options
author | Johannes Löthberg <johannes@kyriasis.com> | 2016-03-07 07:49:03 +0100 |
---|---|---|
committer | Johannes Löthberg <johannes@kyriasis.com> | 2016-03-07 07:49:03 +0100 |
commit | 99b7343ed08ba879b383db34db7b12e8a8ccbced (patch) | |
tree | 87c42c5947335f02e71dd09893ef580c6933b84a | |
parent | 2caad1713e1dd64a7f4db9a27984b4762a0694b5 (diff) | |
download | smtpd-conf-master.tar.xz |
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
-rw-r--r-- | fabfile.py | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -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)) |