cknife 1.3.0 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/Gemfile +3 -2
- data/Gemfile.lock +85 -65
- data/README.md +17 -68
- data/VERSION +1 -1
- data/bin/cknifewcdir +1 -1
- data/cknife.gemspec +19 -50
- data/lib/cknife/cknife_mysql.rb +33 -1
- data/lib/cknife/cknife_pg.rb +2 -1
- data/lib/cknife/command_line.rb +72 -18
- metadata +24 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fdcff4a4d17b6e4f7c13f4d02cc0cc215076a0ad8074b9bf87bc411772262d4b
|
4
|
+
data.tar.gz: f93a80481e4032e069a63ae953114da26118df9696e990cf565a02efb77181c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3ff2f0c86206b4abd5b1386fe153df515132e20d94bee75171db2a0bcaeec701c841345ec5d08de82e20a12824fc5921350a1fad48af9768bdbb9f39c715eef
|
7
|
+
data.tar.gz: fb31871c49220d49eb6a919886ffd40dc509d95ffccb7cb9db31538dcae16594f71ebfbbca1f664cbec149cf45ce3bba06c790407b3eb919dbdb2a1bd1af141a
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.3.0
|
data/Gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
3
|
gem "rest-client", '>= 1.8.0', '~> 1'
|
4
|
-
gem "nokogiri",
|
4
|
+
gem "nokogiri", ">= 1.10.4", '~> 1'
|
5
5
|
gem "i18n", '>= 0.6.6'
|
6
6
|
gem "activesupport", '>= 4.2.9'
|
7
7
|
gem "actionpack", '>= 4.2.9'
|
@@ -11,12 +11,13 @@ gem "builder", '~> 3.0'
|
|
11
11
|
gem "fog-aws", '< 3.0'
|
12
12
|
gem "unf", '>= 0.1', '~> 0'
|
13
13
|
gem "daemons"
|
14
|
+
gem 'loofah', '~> 2.2.3'
|
14
15
|
|
15
16
|
# Add dependencies to develop your gem here.
|
16
17
|
# Include everything needed to run rake, tests, features, etc.
|
17
18
|
group :development do
|
18
19
|
# gem "cknife", :path => "." # this arguably makes it easier to test quickly, locally.
|
19
|
-
gem "bundler", "~>
|
20
|
+
gem "bundler", "~> 2.0"
|
20
21
|
gem "jeweler", "~> 2.1"
|
21
22
|
end
|
22
23
|
|
data/Gemfile.lock
CHANGED
@@ -1,35 +1,35 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
actionpack (
|
5
|
-
actionview (=
|
6
|
-
activesupport (=
|
7
|
-
rack (~>
|
8
|
-
rack-test (
|
9
|
-
rails-dom-testing (~>
|
10
|
-
rails-html-sanitizer (~> 1.0, >= 1.0
|
11
|
-
actionview (
|
12
|
-
activesupport (=
|
4
|
+
actionpack (7.0.8.1)
|
5
|
+
actionview (= 7.0.8.1)
|
6
|
+
activesupport (= 7.0.8.1)
|
7
|
+
rack (~> 2.0, >= 2.2.4)
|
8
|
+
rack-test (>= 0.6.3)
|
9
|
+
rails-dom-testing (~> 2.0)
|
10
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
11
|
+
actionview (7.0.8.1)
|
12
|
+
activesupport (= 7.0.8.1)
|
13
13
|
builder (~> 3.1)
|
14
|
-
|
15
|
-
rails-dom-testing (~>
|
16
|
-
rails-html-sanitizer (~> 1.
|
17
|
-
activesupport (
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
tzinfo (~>
|
14
|
+
erubi (~> 1.4)
|
15
|
+
rails-dom-testing (~> 2.0)
|
16
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
17
|
+
activesupport (7.0.8.1)
|
18
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
|
+
i18n (>= 1.6, < 2)
|
20
|
+
minitest (>= 5.1)
|
21
|
+
tzinfo (~> 2.0)
|
22
22
|
addressable (2.4.0)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
base64 (0.2.0)
|
24
|
+
builder (3.2.4)
|
25
|
+
concurrent-ruby (1.2.3)
|
26
|
+
crass (1.0.6)
|
27
|
+
daemons (1.4.1)
|
27
28
|
descendants_tracker (0.0.4)
|
28
29
|
thread_safe (~> 0.3, >= 0.3.1)
|
29
|
-
domain_name (0.
|
30
|
-
|
31
|
-
|
32
|
-
excon (0.62.0)
|
30
|
+
domain_name (0.6.20240107)
|
31
|
+
erubi (1.12.0)
|
32
|
+
excon (0.110.0)
|
33
33
|
faraday (0.9.2)
|
34
34
|
multipart-post (>= 1.2, < 3)
|
35
35
|
fog-aws (2.0.1)
|
@@ -44,11 +44,12 @@ GEM
|
|
44
44
|
fog-json (1.2.0)
|
45
45
|
fog-core
|
46
46
|
multi_json (~> 1.10)
|
47
|
-
fog-xml (0.1.
|
47
|
+
fog-xml (0.1.4)
|
48
48
|
fog-core
|
49
49
|
nokogiri (>= 1.5.11, < 2.0.0)
|
50
|
-
formatador (0.
|
51
|
-
git (1.
|
50
|
+
formatador (0.3.0)
|
51
|
+
git (1.11.0)
|
52
|
+
rchardet (~> 1.8)
|
52
53
|
github_api (0.16.0)
|
53
54
|
addressable (~> 2.4.0)
|
54
55
|
descendants_tracker (~> 0.0.4)
|
@@ -56,11 +57,11 @@ GEM
|
|
56
57
|
hashie (>= 3.4)
|
57
58
|
mime-types (>= 1.16, < 3.0)
|
58
59
|
oauth2 (~> 1.0)
|
59
|
-
hashie (
|
60
|
-
highline (
|
61
|
-
http-cookie (1.0.
|
60
|
+
hashie (5.0.0)
|
61
|
+
highline (3.0.1)
|
62
|
+
http-cookie (1.0.5)
|
62
63
|
domain_name (~> 0.5)
|
63
|
-
i18n (
|
64
|
+
i18n (1.14.4)
|
64
65
|
concurrent-ruby (~> 1.0)
|
65
66
|
ipaddress (0.8.3)
|
66
67
|
jeweler (2.3.9)
|
@@ -74,76 +75,95 @@ GEM
|
|
74
75
|
rake
|
75
76
|
rdoc
|
76
77
|
semver2
|
77
|
-
jwt (
|
78
|
-
|
78
|
+
jwt (2.8.1)
|
79
|
+
base64
|
80
|
+
loofah (2.2.3)
|
79
81
|
crass (~> 1.0.2)
|
80
82
|
nokogiri (>= 1.5.9)
|
81
83
|
mail (2.5.5)
|
82
84
|
mime-types (~> 1.16)
|
83
85
|
treetop (~> 1.4.8)
|
84
86
|
mime-types (1.25.1)
|
85
|
-
|
86
|
-
|
87
|
-
multi_json (1.13.1)
|
87
|
+
minitest (5.22.3)
|
88
|
+
multi_json (1.15.0)
|
88
89
|
multi_xml (0.6.0)
|
89
|
-
multipart-post (2.
|
90
|
+
multipart-post (2.4.0)
|
90
91
|
netrc (0.11.0)
|
91
|
-
nokogiri (1.
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
92
|
+
nokogiri (1.16.3-aarch64-linux)
|
93
|
+
racc (~> 1.4)
|
94
|
+
nokogiri (1.16.3-arm-linux)
|
95
|
+
racc (~> 1.4)
|
96
|
+
nokogiri (1.16.3-arm64-darwin)
|
97
|
+
racc (~> 1.4)
|
98
|
+
nokogiri (1.16.3-x86-linux)
|
99
|
+
racc (~> 1.4)
|
100
|
+
nokogiri (1.16.3-x86_64-darwin)
|
101
|
+
racc (~> 1.4)
|
102
|
+
nokogiri (1.16.3-x86_64-linux)
|
103
|
+
racc (~> 1.4)
|
104
|
+
oauth2 (1.4.8)
|
105
|
+
faraday (>= 0.8, < 3.0)
|
106
|
+
jwt (>= 1.0, < 3.0)
|
96
107
|
multi_json (~> 1.3)
|
97
108
|
multi_xml (~> 0.5)
|
98
109
|
rack (>= 1.2, < 3)
|
99
110
|
polyglot (0.3.5)
|
100
|
-
psych (
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
rails-dom-testing (
|
107
|
-
activesupport (>=
|
108
|
-
|
109
|
-
|
110
|
-
rails-html-sanitizer (1.0
|
111
|
+
psych (5.1.2)
|
112
|
+
stringio
|
113
|
+
racc (1.7.3)
|
114
|
+
rack (2.2.9)
|
115
|
+
rack-test (2.1.0)
|
116
|
+
rack (>= 1.3)
|
117
|
+
rails-dom-testing (2.2.0)
|
118
|
+
activesupport (>= 5.0.0)
|
119
|
+
minitest
|
120
|
+
nokogiri (>= 1.6)
|
121
|
+
rails-html-sanitizer (1.2.0)
|
111
122
|
loofah (~> 2.2, >= 2.2.2)
|
112
|
-
rake (
|
113
|
-
|
123
|
+
rake (13.2.1)
|
124
|
+
rchardet (1.8.0)
|
125
|
+
rdoc (6.6.3.1)
|
126
|
+
psych (>= 4.0.0)
|
114
127
|
rest-client (1.8.0)
|
115
128
|
http-cookie (>= 1.0.2, < 2.0)
|
116
129
|
mime-types (>= 1.16, < 3.0)
|
117
130
|
netrc (~> 0.7)
|
118
131
|
semver2 (3.4.2)
|
119
|
-
|
132
|
+
stringio (3.1.0)
|
133
|
+
thor (0.20.3)
|
120
134
|
thread_safe (0.3.6)
|
121
135
|
treetop (1.4.15)
|
122
136
|
polyglot
|
123
137
|
polyglot (>= 0.3.1)
|
124
|
-
tzinfo (
|
125
|
-
|
126
|
-
unf (0.1.
|
138
|
+
tzinfo (2.0.6)
|
139
|
+
concurrent-ruby (~> 1.0)
|
140
|
+
unf (0.1.4)
|
127
141
|
unf_ext
|
128
|
-
unf_ext (0.0.
|
142
|
+
unf_ext (0.0.9.1)
|
129
143
|
|
130
144
|
PLATFORMS
|
131
|
-
|
145
|
+
aarch64-linux
|
146
|
+
arm-linux
|
147
|
+
arm64-darwin
|
148
|
+
x86-linux
|
149
|
+
x86_64-darwin
|
150
|
+
x86_64-linux
|
132
151
|
|
133
152
|
DEPENDENCIES
|
134
153
|
actionpack (>= 4.2.9)
|
135
154
|
activesupport (>= 4.2.9)
|
136
155
|
builder (~> 3.0)
|
137
|
-
bundler (~>
|
156
|
+
bundler (~> 2.0)
|
138
157
|
daemons
|
139
158
|
fog-aws (< 3.0)
|
140
159
|
i18n (>= 0.6.6)
|
141
160
|
jeweler (~> 2.1)
|
161
|
+
loofah (~> 2.2.3)
|
142
162
|
mail (~> 2.5.5)
|
143
|
-
nokogiri (~> 1, >= 1.
|
163
|
+
nokogiri (~> 1, >= 1.10.4)
|
144
164
|
rest-client (~> 1, >= 1.8.0)
|
145
165
|
thor (~> 0, >= 0.14)
|
146
166
|
unf (~> 0, >= 0.1)
|
147
167
|
|
148
168
|
BUNDLED WITH
|
149
|
-
|
169
|
+
2.5.6
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/cknife.svg)](https://badge.fury.io/rb/cknife)
|
3
|
+
|
2
4
|
# Quickstart
|
3
5
|
|
4
6
|
cknife is a set of command line tools. They...do different things.
|
@@ -21,66 +23,13 @@ named `your-bucket-name`.
|
|
21
23
|
|
22
24
|
> cknifeaws afew my-bucket --count=50
|
23
25
|
|
24
|
-
That will show you 50 of them.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
[
|
30
|
-
|
31
|
-
yet you still find it silly to be going to the same [old documentation
|
32
|
-
websites](https://www.postgresql.org/docs/9.5/static/backup-dump.html)
|
33
|
-
for things you are certain you once knew how to do?
|
34
|
-
|
35
|
-
Well, you can write a script in something other than
|
36
|
-
bash to automate the precise command line invocation
|
37
|
-
that you used to accomplish a task. But when you
|
38
|
-
move to a different project, how can you take your
|
39
|
-
scripts with you? Why not design your scripts
|
40
|
-
to be robust enough so that they are conventional?
|
41
|
-
|
42
|
-
Why can't a [Stackoverflow](https://stackoverflow.com) question's
|
43
|
-
answer be captured in a form that can be configured and called by you
|
44
|
-
(or someone who was in your position before), so that you don't have
|
45
|
-
to enter the same question into
|
46
|
-
[google.com](https://www.google.com/?q=LOL%20HALP%20ME%20CODE) again
|
47
|
-
later down the road?
|
48
|
-
|
49
|
-
Why make a browser bookmark if you can skip the browser entirely?
|
50
|
-
It's not like the browser bookmark can compile the answer into machine
|
51
|
-
code for you, anyway.
|
52
|
-
|
53
|
-
If someone turns the answer into a programmed tool, what if your IDE
|
54
|
-
is no better than the command line when it comes to invoking it?
|
55
|
-
|
56
|
-
I created cknife to have a set of scripts to fall back on when
|
57
|
-
confronted with the above encounter I've been having for years. cknife
|
58
|
-
is a toolset that encapsulates common command line expressions that
|
59
|
-
developers use when at work.
|
60
|
-
|
61
|
-
I've never used [chef](https://www.chef.io), but were I to grow
|
62
|
-
cknife, I wouldn't be surprised to see it overlap with it.
|
63
|
-
|
64
|
-
cknife currently has some wrappers around Amazon's EC2 and S3
|
65
|
-
services. It has others around MySQL and PostgreSQL. It has a trivial
|
66
|
-
one around [du](http://man7.org/linux/man-pages/man1/du.1.html). The
|
67
|
-
`cknifemon` tool, meanwhile, is a daemon that can launch PUT HTTP
|
68
|
-
requests to an endpoint you configure, on a schedule.
|
69
|
-
|
70
|
-
It can be used for system administration, but it can be also be used
|
71
|
-
to aid developers as they acclimate themselves to a piece of
|
72
|
-
technology with which they may not be familiar, and for which
|
73
|
-
documentation may be a little scattered. It can be used
|
74
|
-
to bang on a piece of technology for the sake of your own
|
75
|
-
learning, too.
|
76
|
-
|
77
|
-
To be precise, cknife consists of command line executables. These
|
78
|
-
tools often require more information from the user, which can be put
|
79
|
-
into a configuration file, `cknife.yml`, in YAML format, and found by
|
80
|
-
cknife in the current working directory ($CWD) when it is invoked.
|
81
|
-
|
82
|
-
See the [Wiki](https://github.com/mikedll/cknife/wiki) for
|
83
|
-
details on the tools cknife has.
|
26
|
+
That will show you 50 of them. You can see the help for this command, too.
|
27
|
+
|
28
|
+
> cknifeaws help
|
29
|
+
|
30
|
+
See the
|
31
|
+
[Wiki](https://github.com/mikedll/cknife/wiki) for details on the
|
32
|
+
tools cknife has. A complete list of the tools is below under 'usage'.
|
84
33
|
|
85
34
|
# Requirements
|
86
35
|
|
@@ -118,14 +67,14 @@ these two places, in order:
|
|
118
67
|
|
119
68
|
Here are the command line executables:
|
120
69
|
|
121
|
-
- cknifeaws
|
122
|
-
-
|
123
|
-
-
|
124
|
-
-
|
125
|
-
-
|
126
|
-
-
|
127
|
-
-
|
128
|
-
-
|
70
|
+
- cknifeaws - AWS wrappers.
|
71
|
+
- cknifemail - SMTP email sender.
|
72
|
+
- cknifemon - Daemon that sends heartbeat signals to a place of your choosing.
|
73
|
+
- cknifemysql - MySQL utilities.
|
74
|
+
- cknifepg - PostgreSQL utilities.
|
75
|
+
- cknifewcdir - Lines-of-code calculator.
|
76
|
+
- cknifedub - Spot directories that are particularly space-consuming.
|
77
|
+
- cknifenowtimestamp - Get a now() timestamp string.
|
129
78
|
|
130
79
|
You can invoke any of them like this:
|
131
80
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.4.2
|
data/bin/cknifewcdir
CHANGED
@@ -31,7 +31,7 @@ class CKnifeWcdir < Thor
|
|
31
31
|
def count(*patterns)
|
32
32
|
start_point = options[:start].empty? ? "." : options[:start].chomp('/')
|
33
33
|
|
34
|
-
pattern_s = "\\( " + patterns.map { |p| "-name #{p}" }.join(' -
|
34
|
+
pattern_s = "\\( " + patterns.map { |p| "-name '#{p}'" }.join(' -or ') + " \\) "
|
35
35
|
skip_s = options[:skip].empty? ? "" : "-type d \\( " + options[:skip].map { |dir| "-path #{start_point}/#{dir.chomp('/')}" }.join(' -o ') + " \\) -prune -o "
|
36
36
|
|
37
37
|
# note patterns must go after the skips (after the -prune -o)
|
data/cknife.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: cknife 1.
|
5
|
+
# stub: cknife 1.4.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "cknife".freeze
|
9
|
-
s.version = "1.
|
9
|
+
s.version = "1.4.2".freeze
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Michael Rivera".freeze]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2024-04-10"
|
15
15
|
s.description = "A collection of command line tools, especially for popular API services.".freeze
|
16
16
|
s.email = "soymrmike@gmail.com".freeze
|
17
17
|
s.executables = ["cknifeaws".freeze, "cknifedub".freeze, "cknifemail".freeze, "cknifemon".freeze, "cknifemysql".freeze, "cknifenowtimestamp".freeze, "cknifepg".freeze, "cknifewcdir".freeze]
|
@@ -51,55 +51,24 @@ Gem::Specification.new do |s|
|
|
51
51
|
]
|
52
52
|
s.homepage = "http://github.com/mikedll/cknife".freeze
|
53
53
|
s.licenses = ["".freeze]
|
54
|
-
s.rubygems_version = "
|
54
|
+
s.rubygems_version = "3.5.3".freeze
|
55
55
|
s.summary = "CKnife".freeze
|
56
56
|
|
57
|
-
|
58
|
-
s.specification_version = 4
|
57
|
+
s.specification_version = 4
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
else
|
75
|
-
s.add_dependency(%q<rest-client>.freeze, [">= 1.8.0", "~> 1"])
|
76
|
-
s.add_dependency(%q<nokogiri>.freeze, [">= 1.8.2", "~> 1"])
|
77
|
-
s.add_dependency(%q<i18n>.freeze, [">= 0.6.6"])
|
78
|
-
s.add_dependency(%q<activesupport>.freeze, [">= 4.2.9"])
|
79
|
-
s.add_dependency(%q<actionpack>.freeze, [">= 4.2.9"])
|
80
|
-
s.add_dependency(%q<mail>.freeze, ["~> 2.5.5"])
|
81
|
-
s.add_dependency(%q<thor>.freeze, [">= 0.14", "~> 0"])
|
82
|
-
s.add_dependency(%q<builder>.freeze, ["~> 3.0"])
|
83
|
-
s.add_dependency(%q<fog-aws>.freeze, ["< 3.0"])
|
84
|
-
s.add_dependency(%q<unf>.freeze, [">= 0.1", "~> 0"])
|
85
|
-
s.add_dependency(%q<daemons>.freeze, [">= 0"])
|
86
|
-
s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
87
|
-
s.add_dependency(%q<jeweler>.freeze, ["~> 2.1"])
|
88
|
-
end
|
89
|
-
else
|
90
|
-
s.add_dependency(%q<rest-client>.freeze, [">= 1.8.0", "~> 1"])
|
91
|
-
s.add_dependency(%q<nokogiri>.freeze, [">= 1.8.2", "~> 1"])
|
92
|
-
s.add_dependency(%q<i18n>.freeze, [">= 0.6.6"])
|
93
|
-
s.add_dependency(%q<activesupport>.freeze, [">= 4.2.9"])
|
94
|
-
s.add_dependency(%q<actionpack>.freeze, [">= 4.2.9"])
|
95
|
-
s.add_dependency(%q<mail>.freeze, ["~> 2.5.5"])
|
96
|
-
s.add_dependency(%q<thor>.freeze, [">= 0.14", "~> 0"])
|
97
|
-
s.add_dependency(%q<builder>.freeze, ["~> 3.0"])
|
98
|
-
s.add_dependency(%q<fog-aws>.freeze, ["< 3.0"])
|
99
|
-
s.add_dependency(%q<unf>.freeze, [">= 0.1", "~> 0"])
|
100
|
-
s.add_dependency(%q<daemons>.freeze, [">= 0"])
|
101
|
-
s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
102
|
-
s.add_dependency(%q<jeweler>.freeze, ["~> 2.1"])
|
103
|
-
end
|
59
|
+
s.add_runtime_dependency(%q<rest-client>.freeze, [">= 1.8.0".freeze, "~> 1".freeze])
|
60
|
+
s.add_runtime_dependency(%q<nokogiri>.freeze, [">= 1.10.4".freeze, "~> 1".freeze])
|
61
|
+
s.add_runtime_dependency(%q<i18n>.freeze, [">= 0.6.6".freeze])
|
62
|
+
s.add_runtime_dependency(%q<activesupport>.freeze, [">= 4.2.9".freeze])
|
63
|
+
s.add_runtime_dependency(%q<actionpack>.freeze, [">= 4.2.9".freeze])
|
64
|
+
s.add_runtime_dependency(%q<mail>.freeze, ["~> 2.5.5".freeze])
|
65
|
+
s.add_runtime_dependency(%q<thor>.freeze, [">= 0.14".freeze, "~> 0".freeze])
|
66
|
+
s.add_runtime_dependency(%q<builder>.freeze, ["~> 3.0".freeze])
|
67
|
+
s.add_runtime_dependency(%q<fog-aws>.freeze, ["< 3.0".freeze])
|
68
|
+
s.add_runtime_dependency(%q<unf>.freeze, [">= 0.1".freeze, "~> 0".freeze])
|
69
|
+
s.add_runtime_dependency(%q<daemons>.freeze, [">= 0".freeze])
|
70
|
+
s.add_runtime_dependency(%q<loofah>.freeze, ["~> 2.2.3".freeze])
|
71
|
+
s.add_development_dependency(%q<bundler>.freeze, ["~> 2.0".freeze])
|
72
|
+
s.add_development_dependency(%q<jeweler>.freeze, ["~> 2.1".freeze])
|
104
73
|
end
|
105
74
|
|
data/lib/cknife/cknife_mysql.rb
CHANGED
@@ -6,6 +6,8 @@ require 'cknife/command_line'
|
|
6
6
|
module CKnife
|
7
7
|
class CKnifeMysql < Thor
|
8
8
|
|
9
|
+
class_option :verbose, :default => false, :type => :boolean, :desc => "Show which commands are invoked, any input given to them, and any output they give back."
|
10
|
+
|
9
11
|
no_tasks do
|
10
12
|
def config
|
11
13
|
@config ||= Config
|
@@ -30,8 +32,38 @@ module CKnife
|
|
30
32
|
end
|
31
33
|
|
32
34
|
def command_line
|
33
|
-
@command_line ||= CommandLine.new(option_file, "[client]\npassword=\"#{conf[:password]}\"", self)
|
35
|
+
@command_line ||= CommandLine.new(option_file, "[client]\npassword=\"#{conf[:password]}\"", self, options)
|
36
|
+
end
|
37
|
+
|
38
|
+
def mysql_easy
|
39
|
+
"mysql #{connection_options} #{conf[:database]}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "console", "Launch mysql console."
|
44
|
+
method_option :myfile, :type => :boolean, :default => false, :desc => "Write my.cnf file if it doesn't exist."
|
45
|
+
def console
|
46
|
+
if !File.exists?(option_file)
|
47
|
+
if !options[:myfile]
|
48
|
+
say("You must prepare a #{option_file} file for this command, or use --myfile to have this tool create it for you. Alternatively, you can create a #{option_file} file with the myfile command and delete it later with the dmyfile command.")
|
49
|
+
return
|
50
|
+
end
|
51
|
+
|
52
|
+
command_line.write_option_file
|
34
53
|
end
|
54
|
+
|
55
|
+
dc(mysql_easy) if options[:verbose]
|
56
|
+
exec(mysql_easy)
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "myfile", "Write a my.cnf file in $CWD. Useful for starting a mysql session on your own."
|
60
|
+
def myfile
|
61
|
+
command_line.create_opt_file("Connect command: #{mysql_easy}")
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "dmyfile", "Delete the my.cnf file in $CWD, assuming it exactly matches what would be generated by this tool."
|
65
|
+
def dmyfile
|
66
|
+
command_line.delete_opt_file
|
35
67
|
end
|
36
68
|
|
37
69
|
desc "capture", "Capture a dump of the database to db(current timestamp).sql."
|
data/lib/cknife/cknife_pg.rb
CHANGED
@@ -36,6 +36,7 @@ class CKnifePg < Thor
|
|
36
36
|
@pg_pass_file = ".pgpass"
|
37
37
|
end
|
38
38
|
|
39
|
+
# dump command?
|
39
40
|
def dc(cmd)
|
40
41
|
puts "PGPASSFILE=#{pg_pass_file} #{cmd}"
|
41
42
|
end
|
@@ -304,7 +305,7 @@ AND
|
|
304
305
|
return
|
305
306
|
end
|
306
307
|
|
307
|
-
|
308
|
+
write_pg_pass_file
|
308
309
|
say("Wrote #{pg_pass_file} to $CWD.")
|
309
310
|
say(connect_msg)
|
310
311
|
say("Remember to delete the .pgpass file when you are finished.")
|
data/lib/cknife/command_line.rb
CHANGED
@@ -1,31 +1,76 @@
|
|
1
1
|
module CKnife
|
2
2
|
class CommandLine
|
3
3
|
|
4
|
-
attr_accessor :option_file, :option_file_contents, :thor_output
|
4
|
+
attr_accessor :option_file, :option_file_contents, :thor_output, :options
|
5
5
|
|
6
|
-
def initialize(f, s, o)
|
6
|
+
def initialize(f, s, o, opts)
|
7
7
|
self.option_file = f
|
8
8
|
self.option_file_contents = s
|
9
9
|
self.thor_output = o
|
10
|
+
self.options = opts
|
11
|
+
end
|
12
|
+
|
13
|
+
# dump command?
|
14
|
+
def dc(cmd)
|
15
|
+
puts "PGPASSFILE=#{pg_pass_file} #{cmd}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def write_option_file
|
19
|
+
File.open(option_file, "w", 0600) { |f| f.write option_file_contents }
|
20
|
+
end
|
21
|
+
|
22
|
+
def delete_opt_file
|
23
|
+
if !File.exists?(option_file)
|
24
|
+
thor_output.say("No #{option_file} file to delete.")
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
s = File.read(option_file)
|
29
|
+
if s == option_file_contents
|
30
|
+
File.unlink(option_file)
|
31
|
+
thor_output.say("Deleted #{option_file} file.")
|
32
|
+
else
|
33
|
+
thor_output.say("The #{option_file} file's contents do not match what this tool would have generated. Assuming you are trying to delete a #{option_file} file that this tool did not generate, please inspect the file to ensure it contains what you expect, and then delete it yourself.", :red)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def create_opt_file(connect_msg)
|
38
|
+
if File.exists?(option_file)
|
39
|
+
thor_output.say("A #{option_file} file is already present.")
|
40
|
+
thor_output.say(connect_msg)
|
41
|
+
return
|
42
|
+
end
|
43
|
+
|
44
|
+
write_option_file
|
45
|
+
thor_output.say("Wrote #{option_file} to $CWD.")
|
46
|
+
thor_output.say(connect_msg)
|
47
|
+
thor_output.say("Remember to delete the #{option_file} file when you are finished.")
|
10
48
|
end
|
11
49
|
|
12
50
|
def execute(cmd, input = nil)
|
13
51
|
return if !@session_ok
|
14
|
-
|
52
|
+
dc(cmd) if options[:verbose]
|
15
53
|
stdin, stdout, stderr, wait_thread = Open3.popen3(cmd)
|
16
54
|
if input
|
17
|
-
puts input
|
55
|
+
puts input if options[:verbose]
|
18
56
|
stdin.write input
|
19
57
|
stdin.close
|
20
58
|
end
|
21
59
|
output = stdout.read
|
22
60
|
output += stderr.read
|
23
|
-
$stdout.write output
|
61
|
+
$stdout.write output if options[:verbose]
|
24
62
|
stdout.close
|
25
63
|
stderr.close
|
26
64
|
result = wait_thread.value.to_i
|
27
|
-
|
28
|
-
|
65
|
+
|
66
|
+
if result != 0
|
67
|
+
@session_ok = false
|
68
|
+
msg = "An error occurred."
|
69
|
+
msg += " If the --verbose flag is available for this command, you may try turning it on." if !options[:verbose]
|
70
|
+
thor_output.say(msg, :red)
|
71
|
+
end
|
72
|
+
|
73
|
+
yield if block_given?
|
29
74
|
output
|
30
75
|
end
|
31
76
|
|
@@ -37,24 +82,33 @@ module CKnife
|
|
37
82
|
@session_live = true
|
38
83
|
@session_ok = true
|
39
84
|
|
85
|
+
existing_option_file = false
|
40
86
|
if File.exists?(option_file)
|
41
|
-
|
42
|
-
|
87
|
+
existing_option_file = true
|
88
|
+
s = File.read(option_file)
|
89
|
+
if s != option_file_contents
|
90
|
+
thor_output.say("A #{option_file} file is present, but it does not match your database configuration. The contents of the #{option_file} file must exactly match what this tool would generate. Please reconcile the #{option_file} file with your configuration, and then try again. You can also delete the #{option_file} file since this tool generates one in order to do its job (and removes it after finishing).", :red)
|
91
|
+
return
|
92
|
+
end
|
43
93
|
end
|
44
94
|
|
45
|
-
|
46
|
-
|
47
|
-
result = yield self
|
95
|
+
write_option_file
|
48
96
|
|
49
|
-
|
50
|
-
|
51
|
-
|
97
|
+
result = nil
|
98
|
+
begin
|
99
|
+
result = yield self # don't know what we're planning to do with the result here...
|
100
|
+
ensure
|
101
|
+
if !existing_option_file
|
102
|
+
FileUtils.rm(option_file)
|
103
|
+
if File.exists?(option_file)
|
104
|
+
thor_output.say("Failed to remove #{option_file} file. Please remove it for your infrastructure's security.")
|
105
|
+
end
|
106
|
+
else
|
107
|
+
thor_output.say("Left existing #{option_file} file on disk.", :yellow)
|
108
|
+
end
|
52
109
|
end
|
53
110
|
|
54
|
-
thor_output.say
|
55
|
-
thor_output.say("Command failed.", :red) if !@session_ok
|
56
111
|
@session_live = false
|
57
|
-
|
58
112
|
result
|
59
113
|
end
|
60
114
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cknife
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Rivera
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -36,7 +36,7 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 1.
|
39
|
+
version: 1.10.4
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '1'
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 1.
|
49
|
+
version: 1.10.4
|
50
50
|
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '1'
|
@@ -188,20 +188,34 @@ dependencies:
|
|
188
188
|
- - ">="
|
189
189
|
- !ruby/object:Gem::Version
|
190
190
|
version: '0'
|
191
|
+
- !ruby/object:Gem::Dependency
|
192
|
+
name: loofah
|
193
|
+
requirement: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
195
|
+
- - "~>"
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: 2.2.3
|
198
|
+
type: :runtime
|
199
|
+
prerelease: false
|
200
|
+
version_requirements: !ruby/object:Gem::Requirement
|
201
|
+
requirements:
|
202
|
+
- - "~>"
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: 2.2.3
|
191
205
|
- !ruby/object:Gem::Dependency
|
192
206
|
name: bundler
|
193
207
|
requirement: !ruby/object:Gem::Requirement
|
194
208
|
requirements:
|
195
209
|
- - "~>"
|
196
210
|
- !ruby/object:Gem::Version
|
197
|
-
version: '
|
211
|
+
version: '2.0'
|
198
212
|
type: :development
|
199
213
|
prerelease: false
|
200
214
|
version_requirements: !ruby/object:Gem::Requirement
|
201
215
|
requirements:
|
202
216
|
- - "~>"
|
203
217
|
- !ruby/object:Gem::Version
|
204
|
-
version: '
|
218
|
+
version: '2.0'
|
205
219
|
- !ruby/object:Gem::Dependency
|
206
220
|
name: jeweler
|
207
221
|
requirement: !ruby/object:Gem::Requirement
|
@@ -264,7 +278,7 @@ homepage: http://github.com/mikedll/cknife
|
|
264
278
|
licenses:
|
265
279
|
- ''
|
266
280
|
metadata: {}
|
267
|
-
post_install_message:
|
281
|
+
post_install_message:
|
268
282
|
rdoc_options: []
|
269
283
|
require_paths:
|
270
284
|
- lib
|
@@ -279,9 +293,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
279
293
|
- !ruby/object:Gem::Version
|
280
294
|
version: '0'
|
281
295
|
requirements: []
|
282
|
-
|
283
|
-
|
284
|
-
signing_key:
|
296
|
+
rubygems_version: 3.5.3
|
297
|
+
signing_key:
|
285
298
|
specification_version: 4
|
286
299
|
summary: CKnife
|
287
300
|
test_files: []
|