-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup_blackfire.py
More file actions
executable file
·79 lines (58 loc) · 1.88 KB
/
setup_blackfire.py
File metadata and controls
executable file
·79 lines (58 loc) · 1.88 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/python
import os, sys
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8)
path_installation = os.path.dirname(os.path.realpath(__file__))
path_vagrant = path_installation + '/vagrant'
path_config = path_vagrant + '/puphpet/config.yaml'
def say(text, colour=CYAN):
print "\x1b[1;%dm" % (30 + colour) + text + "\x1b[0m"
def ask(text, colour=MAGENTA):
return raw_input("\x1b[1;%dm" % (30 + colour) + text + "\x1b[0m")
intro = """
This script is going to setup the BlackFire profiler in your VirtualBox.
In order to do this we are going to need your BlackFire's server and client ID and Token
These information are retrievable from your profile [https://blackfire.io/account/credentials]
If you don't have a BlackFire account yet, its free just give it a try ;)
"""
say(intro)
shall_we_start = ask("Are we ready to start [Yes/no]?") or 'Yes'
if (shall_we_start != 'Yes'):
quit("Quite the process")
# client_id = ask("What's your BlackFire's client ID? ")
# client_token = ask("What's your BlackFire's Client Token? ")
server_id = ask("What's your BlackFire's Server ID? ")
server_token = ask("What's your BlackFire's Server Token? ")
cmd_replace_install = """sed -i -e "
/blackfire/ {
N
/.*install:.*/ {
s/install:.*/install: '1'/
}
}" %s""" % (path_config)
cmd_replace_server_id = """sed -i -e "
/blackfire/ {
N
N
N
/.*server_id:.*/ {
s/server_id:.*/server_id: '%s'/
}
}" %s""" % (server_id, path_config)
cmd_replace_server_token = """sed -i -e "
/blackfire/ {
N
N
N
N
/.*server_token:.*/ {
s/server_token:.*/server_token: '%s'/
}
}" %s""" % (server_token, path_config)
os.system(cmd_replace_install)
os.system(cmd_replace_server_id)
os.system(cmd_replace_server_token)
os.chdir(path_vagrant)
os.system('vagrant provision')
os.system('vagrant ssh -c "blackfire config"')
os.system('vagrant ssh -c "sudo /etc/init.d/blackfire-agent restart"')
os.system('vagrant reload')