summaryrefslogtreecommitdiffstats
path: root/fabfile.py
diff options
context:
space:
mode:
Diffstat (limited to 'fabfile.py')
-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))