-
Notifications
You must be signed in to change notification settings - Fork 1
/
fabfile.py
executable file
·61 lines (45 loc) · 1.28 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from fabric.api import *
from fabric.contrib.console import confirm
env.hosts = []
env.user = 'root'
env.user_home = '/root'
def test():
run('touch hello_world.py')
def init():
_apt_get('make')
_apt_get('git')
github('stardust')
def adduser():
user = raw_input('Username: ')
cmd = '~/stardust/bin/staradduser -s %s' % user
dir = '/home/%s/stardust' % user
# get stardust
run(cmd)
github('stardust', dir=dir)
# give user ownership
cmd = 'chown -R %s:%s %s' % (user, user, dir)
run(cmd)
def github(project, dir=''):
cmd = 'git clone https://github.com/tspxyz/%s.git' % project
if dir:
cmd = '%s %s' % (cmd, dir)
run(cmd)
# utilities
def _apt_get(package):
"""
Install a single package on the remote server with Apt.
"""
sudo('apt-get install -y %s' % package)
def _easy_install(package):
"""
Install a single package on the remote server with easy_install.
"""
sudo('easy_install %s' % package)
def _virtualenv(command):
"""
Executes a command in this project's virtual environment.
"""
if not ENVS_PATH or not PROJECT:
print('ERROR: project vars not set. exiting virtialenv')
return False
run('source %s/%s/bin/activate && %s' % (ENVS_PATH, PROJECT, command))