-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroadie
executable file
·60 lines (47 loc) · 1.03 KB
/
roadie
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
#!/usr/bin/ruby -w
module Local
class << self
VHOST = %q(<VirtualHost *:80>
ServerName :host.local
ServerAlias :host.roy.test.rodimedia.nl
DocumentRoot :pwd/public
<Directory ":pwd/public">
Options FollowSymlinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
)
def host
@host ||= File.split(`pwd`).last.strip
end
def pwd
`pwd`.strip
end
def open
`open http://#{host}.local`
end
def add
add_to_hosts
add_to_vhosts
end
def add_to_hosts
`sudo sh -c 'echo "127.0.0.1 #{host}.local" >> /etc/hosts'`
end
def add_to_vhosts
vhost = VHOST.gsub(":host", host).gsub(":pwd", pwd)
`sudo sh -c 'echo "#{vhost}" >> /etc/apache2/extra/httpd-vhosts.conf'`
`sudo apachectl restart`
end
def delete
puts "deleting: #{host}"
end
end
end
method = ARGV[0]
unless %w(add delete open).include? method
puts "only open, add and delete are supported"
exit
end
Local.send(method)