This repository has been archived by the owner on Jan 26, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
fabfile.py
36 lines (31 loc) · 1.5 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Fabric file that connects to a fresh virtual machine, sets up build
# dependencies, runs the build, and copies out the product and any
# error messages.
#
# During development, run with the IP address of the virtual machine
# in the -H parameter. Example: fab -H 192.168.194.177 build
#
from fabric.api import env, settings, run, put, get
from fabric.decorators import with_settings
env.user = "cpbuild"
@with_settings(user="root")
def set_up_user(username):
home = '/home/' + username
d = dict(home=home, username=username)
run("""test -d {home} || adduser {username}""".format(**d))
run("""test -d {home}/.ssh || sudo -u {username} mkdir -m 700 {home}/.ssh""".format(**d))
put("id_rsa.pub", "{home}/.ssh/authorized_keys".format(**d), mode=0600)
run("""chown {username}:{username} {home}/.ssh/authorized_keys""".format(**d))
run("""echo '{username} ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers""".format(**d))
def build():
set_up_user("cpbuild")
put("build_cellprofiler.sh", "~", mode=0755)
run("./build_cellprofiler.sh")
get("cellprofiler.tar.gz")
def test():
set_up_user("johndoe")
with settings(user="root"):
run("yum -y install gtk2-devel mesa-libGL mesa-libGL-devel blas atlas lapack blas-devel atlas-devel lapack-devel xorg-x11-xauth* xorg-x11-xkb-utils* qt-devel openssl openssl-devel xclock *Xvfb* svn")
put("cellprofiler.tar.gz")
run("tar xzf cellprofiler.tar.gz -C /")
run("/usr/CellProfiler/src/CellProfiler/shortcuts/cellprofiler -t")