mybot 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Botfile +9 -9
- data/CHANGELOG.md +7 -0
- data/README.md +294 -18
- data/lib/mybot.rb +3 -0
- data/lib/mybot/cli.rb +2 -1
- data/lib/mybot/command.rb +23 -4
- data/lib/mybot/commands.rb +5 -5
- data/lib/mybot/core-ext/kernel.rb +21 -0
- data/lib/mybot/fmt.rb +3 -7
- data/lib/mybot/lib.rb +9 -0
- data/lib/mybot/messages.rb +12 -6
- data/lib/mybot/node.rb +62 -68
- data/lib/mybot/recipes.rb +4 -2
- data/lib/mybot/tasks.rb +2 -1
- data/lib/mybot/version.rb +1 -1
- data/mybot.gemspec +1 -1
- data/vendor/lib/{mybot → core}/.gitkeep +0 -0
- data/vendor/lib/core/fs.rb +185 -0
- data/vendor/lib/core/osx/git.rb +31 -0
- data/vendor/lib/core/ubuntu/apache.rb +42 -0
- data/vendor/lib/core/ubuntu/apt.rb +40 -0
- data/vendor/lib/core/ubuntu/git.rb +36 -0
- data/vendor/lib/core/ubuntu/mysql.rb +83 -0
- data/vendor/lib/core/ubuntu/passenger.rb +55 -0
- data/vendor/lib/core/ubuntu/ruby.rb +165 -0
- data/vendor/lib/core/ubuntu/service.rb +30 -0
- data/vendor/lib/core/ubuntu/users.rb +76 -0
- data/vendor/lib/core/ubuntu/vim.rb +31 -0
- data/vendor/{tasks → recipes}/.gitkeep +0 -0
- data/vendor/tpl/{mybot → core}/.gitkeep +0 -0
- data/vendor/tpl/core/ubuntu/apache/apache2.conf.erb +80 -0
- metadata +21 -6
@@ -0,0 +1,30 @@
|
|
1
|
+
module Core
|
2
|
+
module Ubuntu
|
3
|
+
class Service < Mybot::Lib
|
4
|
+
def initialize(node)
|
5
|
+
@node = node
|
6
|
+
end
|
7
|
+
|
8
|
+
def start(options = {})
|
9
|
+
error "service is required" unless options[:service]
|
10
|
+
|
11
|
+
options[:cmd] = "service #{options[:service]} start"
|
12
|
+
@node.run(options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def stop(options = {})
|
16
|
+
error "service is required" unless options[:service]
|
17
|
+
|
18
|
+
options[:cmd] = "service #{options[:service]} stop"
|
19
|
+
@node.run(options)
|
20
|
+
end
|
21
|
+
|
22
|
+
def restart(options = {})
|
23
|
+
error "service is required" unless options[:service]
|
24
|
+
|
25
|
+
options[:cmd] = "service #{options[:service]} restart"
|
26
|
+
@node.run(options)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Core
|
2
|
+
module Ubuntu
|
3
|
+
class Users < Mybot::Lib
|
4
|
+
def initialize(node)
|
5
|
+
@node = node
|
6
|
+
end
|
7
|
+
|
8
|
+
def list(options = {})
|
9
|
+
options[:cmd] = "cat /etc/passwd | cut -d: -f1"
|
10
|
+
out = @node.run(options)
|
11
|
+
out.split("\r\n")
|
12
|
+
end
|
13
|
+
|
14
|
+
def exists?(options = {})
|
15
|
+
error "username is required" unless options[:username]
|
16
|
+
|
17
|
+
list(options).include?(options[:username])
|
18
|
+
end
|
19
|
+
|
20
|
+
def create(options = {})
|
21
|
+
error "username is required" unless options[:username]
|
22
|
+
error "password is required" unless options[:password]
|
23
|
+
|
24
|
+
options[:cmd] = "adduser #{options[:username]}"
|
25
|
+
options[:fullname] ||= ""
|
26
|
+
options[:room_number] ||= ""
|
27
|
+
options[:work_phone] ||= ""
|
28
|
+
options[:home_phone] ||= ""
|
29
|
+
|
30
|
+
@node.run(options) do |cmd|
|
31
|
+
cmd.on "Enter new UNIX password:" do
|
32
|
+
cmd.write options[:password]
|
33
|
+
end
|
34
|
+
|
35
|
+
cmd.on "Retype new UNIX password:" do
|
36
|
+
cmd.write options[:password]
|
37
|
+
end
|
38
|
+
|
39
|
+
cmd.on "Full Name []:" do
|
40
|
+
cmd.write options[:fullname]
|
41
|
+
end
|
42
|
+
|
43
|
+
cmd.on "Room Number []:" do
|
44
|
+
cmd.write options[:room_number]
|
45
|
+
end
|
46
|
+
|
47
|
+
cmd.on "Work Phone []:" do
|
48
|
+
cmd.write options[:work_phone]
|
49
|
+
end
|
50
|
+
|
51
|
+
cmd.on "Home Phone []:" do
|
52
|
+
cmd.write options[:home_phone]
|
53
|
+
end
|
54
|
+
|
55
|
+
cmd.on "Other []:" do
|
56
|
+
cmd.write "user created by mybot"
|
57
|
+
end
|
58
|
+
|
59
|
+
cmd.on "Is the information correct? [Y/n]" do
|
60
|
+
cmd.write "Y"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def remove(options = {})
|
66
|
+
error "username is required" unless options[:username]
|
67
|
+
|
68
|
+
options[:cmd] = "userdel #{options[:username]}"
|
69
|
+
@node.run(options)
|
70
|
+
|
71
|
+
options[:cmd] = "rm -rf /home/#{options[:username]}"
|
72
|
+
@node.run(options)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Core
|
2
|
+
module Ubuntu
|
3
|
+
class Vim < Mybot::Lib
|
4
|
+
def initialize(node)
|
5
|
+
@node = node
|
6
|
+
@node.use [
|
7
|
+
"core/fs",
|
8
|
+
"core/ubuntu/apt"
|
9
|
+
]
|
10
|
+
end
|
11
|
+
|
12
|
+
def installed?(options = {})
|
13
|
+
options[:file] = "/usr/bin/vim"
|
14
|
+
@node.fs.exists?(options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def install(options = {})
|
18
|
+
options[:pkg] = "vim"
|
19
|
+
@node.apt.install(options)
|
20
|
+
end
|
21
|
+
|
22
|
+
def remove(options = {})
|
23
|
+
options[:pkg] = "vim"
|
24
|
+
@node.apt.remove(options)
|
25
|
+
end
|
26
|
+
|
27
|
+
def reconfigure(options = {})
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,80 @@
|
|
1
|
+
LockFile ${APACHE_LOCK_DIR}/accept.lock
|
2
|
+
PidFile ${APACHE_PID_FILE}
|
3
|
+
Timeout 300
|
4
|
+
KeepAlive On
|
5
|
+
MaxKeepAliveRequests 100
|
6
|
+
KeepAliveTimeout 5
|
7
|
+
|
8
|
+
<IfModule mpm_prefork_module>
|
9
|
+
StartServers 5
|
10
|
+
MinSpareServers 5
|
11
|
+
MaxSpareServers 10
|
12
|
+
MaxClients 150
|
13
|
+
MaxRequestsPerChild 0
|
14
|
+
</IfModule>
|
15
|
+
|
16
|
+
<IfModule mpm_worker_module>
|
17
|
+
StartServers 2
|
18
|
+
MinSpareThreads 25
|
19
|
+
MaxSpareThreads 75
|
20
|
+
ThreadLimit 64
|
21
|
+
ThreadsPerChild 25
|
22
|
+
MaxClients 150
|
23
|
+
MaxRequestsPerChild 0
|
24
|
+
</IfModule>
|
25
|
+
|
26
|
+
<IfModule mpm_event_module>
|
27
|
+
StartServers 2
|
28
|
+
MinSpareThreads 25
|
29
|
+
MaxSpareThreads 75
|
30
|
+
ThreadLimit 64
|
31
|
+
ThreadsPerChild 25
|
32
|
+
MaxClients 150
|
33
|
+
MaxRequestsPerChild 0
|
34
|
+
</IfModule>
|
35
|
+
|
36
|
+
User ${APACHE_RUN_USER}
|
37
|
+
Group ${APACHE_RUN_GROUP}
|
38
|
+
AccessFileName .htaccess
|
39
|
+
|
40
|
+
<Files ~ "^\.ht">
|
41
|
+
Order allow,deny
|
42
|
+
Deny from all
|
43
|
+
Satisfy all
|
44
|
+
</Files>
|
45
|
+
|
46
|
+
DefaultType None
|
47
|
+
HostnameLookups Off
|
48
|
+
ErrorLog ${APACHE_LOG_DIR}/error.log
|
49
|
+
LogLevel warn
|
50
|
+
|
51
|
+
Include mods-enabled/*.load
|
52
|
+
Include mods-enabled/*.conf
|
53
|
+
Include ports.conf
|
54
|
+
|
55
|
+
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
|
56
|
+
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
|
57
|
+
LogFormat "%h %l %u %t \"%r\" %>s %O" common
|
58
|
+
LogFormat "%{Referer}i -> %U" referer
|
59
|
+
LogFormat "%{User-agent}i" agent
|
60
|
+
|
61
|
+
Include conf.d/
|
62
|
+
|
63
|
+
<% if passenger[:enabled] %>
|
64
|
+
LoadModule passenger_module <%= passenger[:rbenv_root] %>/versions/<%= passenger[:ruby_version] %>/lib/ruby/gems/<%= passenger[:ruby_system_version] %>/gems/passenger-<%= passenger[:version] %>/libout/apache2/mod_passenger.so
|
65
|
+
PassengerRoot <%= passenger[:rbenv_root] %>/versions/<%= passenger[:ruby_version] %>/lib/ruby/gems/<%= passenger[:ruby_system_version] %>/gems/passenger-<%= passenger[:version] %>
|
66
|
+
PassengerDefaultRuby <%= passenger[:rbenv_root] %>/versions/<%= passenger[:ruby_version] %>/bin/ruby
|
67
|
+
<% end %>
|
68
|
+
|
69
|
+
<% apps.each do |name, app| %>
|
70
|
+
<% if app[:type] == "rails" %>
|
71
|
+
<VirtualHost *:80>
|
72
|
+
ServerName <%= app[:server_name] %>
|
73
|
+
DocumentRoot <%= app[:path] %>/public
|
74
|
+
<Directory <%= app[:path] %>/public>
|
75
|
+
AllowOverride all
|
76
|
+
Options -MultiViews
|
77
|
+
</Directory>
|
78
|
+
</VirtualHost>
|
79
|
+
<% end %>
|
80
|
+
<% end %>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mybot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -101,6 +101,7 @@ extra_rdoc_files: []
|
|
101
101
|
files:
|
102
102
|
- .gitignore
|
103
103
|
- Botfile
|
104
|
+
- CHANGELOG.md
|
104
105
|
- Gemfile
|
105
106
|
- LICENSE.txt
|
106
107
|
- README.md
|
@@ -111,7 +112,9 @@ files:
|
|
111
112
|
- lib/mybot/cli.rb
|
112
113
|
- lib/mybot/command.rb
|
113
114
|
- lib/mybot/commands.rb
|
115
|
+
- lib/mybot/core-ext/kernel.rb
|
114
116
|
- lib/mybot/fmt.rb
|
117
|
+
- lib/mybot/lib.rb
|
115
118
|
- lib/mybot/messages.rb
|
116
119
|
- lib/mybot/node.rb
|
117
120
|
- lib/mybot/recipes.rb
|
@@ -119,9 +122,21 @@ files:
|
|
119
122
|
- lib/mybot/template.rb
|
120
123
|
- lib/mybot/version.rb
|
121
124
|
- mybot.gemspec
|
122
|
-
- vendor/lib/
|
123
|
-
- vendor/
|
124
|
-
- vendor/
|
125
|
+
- vendor/lib/core/.gitkeep
|
126
|
+
- vendor/lib/core/fs.rb
|
127
|
+
- vendor/lib/core/osx/git.rb
|
128
|
+
- vendor/lib/core/ubuntu/apache.rb
|
129
|
+
- vendor/lib/core/ubuntu/apt.rb
|
130
|
+
- vendor/lib/core/ubuntu/git.rb
|
131
|
+
- vendor/lib/core/ubuntu/mysql.rb
|
132
|
+
- vendor/lib/core/ubuntu/passenger.rb
|
133
|
+
- vendor/lib/core/ubuntu/ruby.rb
|
134
|
+
- vendor/lib/core/ubuntu/service.rb
|
135
|
+
- vendor/lib/core/ubuntu/users.rb
|
136
|
+
- vendor/lib/core/ubuntu/vim.rb
|
137
|
+
- vendor/recipes/.gitkeep
|
138
|
+
- vendor/tpl/core/.gitkeep
|
139
|
+
- vendor/tpl/core/ubuntu/apache/apache2.conf.erb
|
125
140
|
homepage: https://github.com/sebastiansito/mybot
|
126
141
|
licenses:
|
127
142
|
- MIT
|
@@ -146,5 +161,5 @@ rubyforge_project:
|
|
146
161
|
rubygems_version: 1.8.23
|
147
162
|
signing_key:
|
148
163
|
specification_version: 3
|
149
|
-
summary:
|
164
|
+
summary: mybot, my personal bot
|
150
165
|
test_files: []
|