Skip to content

Commit

Permalink
Create tmp dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Rupert Bedford committed May 19, 2016
1 parent 1150e04 commit 2638b40
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ def deploy(archive=None, name='radar-client'):
archive = sorted(x for x in os.listdir('.') if x.endswith('.tar.gz'))[-1]

version = re.search('-([^-]+)\.tar\.gz$', archive).group(1)

remote_archive = '/tmp/{name}.tar.gz'.format(name=name)
put(archive, remote_archive)

current_version = '/srv/{name}/current'.format(name=name)
new_version = '/srv/{name}/{version}'.format(name=name, version=version)

tmp = '/tmp/deploy-{0}'.format(os.urandom(20).encode('hex'))
run('mkdir {0}'.format(tmp))
remote_archive = '{0}/radar-client.tar.gz'.format(tmp)
put(archive, remote_archive)

run('rm -rf {0} && mkdir -p {0}'.format(new_version))

with cd(new_version):
run('tar --strip-components=1 -xzf {}'.format(remote_archive))

run('ln -sfn {0} {1}'.format(new_version, current_version))
run('rm -rf {0}'.format(remote_archive))
run('rm -rf {0}'.format(tmp))

0 comments on commit 2638b40

Please sign in to comment.