marhan_cli 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changelog.md +4 -0
- data/README.md +5 -3
- data/lib/marhan_cli/app/true_crypt_app.rb +20 -0
- data/lib/marhan_cli/command.rb +7 -0
- data/lib/marhan_cli/commands/network.rb +16 -9
- data/lib/marhan_cli/commands/true_crypt.rb +35 -0
- data/lib/marhan_cli/{server → network}/errors.rb +0 -0
- data/lib/marhan_cli/{server → network}/remote_machine.rb +0 -0
- data/lib/marhan_cli/version.rb +1 -1
- metadata +6 -4
data/Changelog.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# MarhanCli
|
1
|
+
# MarhanCli [](https://codeclimate.com/github/marhan/marhan_cli)
|
2
2
|
|
3
|
-
This gem is a
|
3
|
+
This gem is a console tool for my own needs.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,9 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
Ater installation of the gem type `mcli` to get a list of possible commands
|
22
|
+
|
23
|
+
$ mcli
|
22
24
|
|
23
25
|
## Contributing
|
24
26
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'marhan_cli/helper/constraint'
|
2
|
+
|
3
|
+
module MarhanCli
|
4
|
+
class TrueCryptApp
|
5
|
+
|
6
|
+
def initialize()
|
7
|
+
@binary = "/Applications/TrueCrypt.app/Contents/MacOS/TrueCrypt"
|
8
|
+
raise ArgumentError, "No installation of TrueCrypt found!" unless File.exist? @binary
|
9
|
+
end
|
10
|
+
|
11
|
+
def mount_command()
|
12
|
+
"#{@binary} --mount /dev/rdisk1s2 /Volumes/enc1"
|
13
|
+
end
|
14
|
+
|
15
|
+
def unmount_command()
|
16
|
+
"#{@binary} -d /Volumes/enc1"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
data/lib/marhan_cli/command.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require 'marhan_cli/
|
2
|
+
require 'marhan_cli/network/remote_machine'
|
3
3
|
require 'marhan_cli/command'
|
4
4
|
|
5
5
|
module MarhanCli
|
@@ -32,23 +32,30 @@ module MarhanCli
|
|
32
32
|
:desc => "Path of id file"
|
33
33
|
|
34
34
|
def add_ssh_key
|
35
|
-
host =
|
36
|
-
user =
|
37
|
-
password =
|
38
|
-
id_file =
|
39
|
-
port =
|
35
|
+
host = get_or_ask(:host)
|
36
|
+
user = get_or_ask(:user)
|
37
|
+
password = get_or_ask(:password)
|
38
|
+
id_file = get(:file)
|
39
|
+
port = get(:port)
|
40
40
|
|
41
41
|
remote_machine = RemoteMachine.new(host, port)
|
42
42
|
remote_machine.add_id_to_authorized_keys(user, password, id_file)
|
43
43
|
say "successfully copied #{id_file} to #{host}", :green
|
44
44
|
rescue Exception => e
|
45
|
-
|
46
|
-
exit(1)
|
45
|
+
exit_command("copying of id file to remote machine failed: #{e}")
|
47
46
|
end
|
48
47
|
|
49
48
|
protected
|
50
49
|
|
51
|
-
def
|
50
|
+
def get(option_name)
|
51
|
+
options[option_name]
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_or_ask(option_name)
|
55
|
+
options[option_name] || ask_for_option(:host)
|
56
|
+
end
|
57
|
+
|
58
|
+
def ask_for_option(option)
|
52
59
|
value = ask("Please enter #{option}:")
|
53
60
|
raise Thor::Error, "You must enter a value for that field." if value.empty?
|
54
61
|
value
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'marhan_cli/command'
|
3
|
+
require 'marhan_cli/app/true_crypt_app'
|
4
|
+
|
5
|
+
module MarhanCli
|
6
|
+
class TrueCrypt < MarhanCli::Command
|
7
|
+
|
8
|
+
namespace :crypt
|
9
|
+
|
10
|
+
desc "crypt:mount", "Mounts encrypted disk with TrueCrypt"
|
11
|
+
|
12
|
+
def mount
|
13
|
+
begin
|
14
|
+
@app = TrueCryptApp.new
|
15
|
+
run @app.mount_command
|
16
|
+
say "finished", :green
|
17
|
+
rescue Exception => e
|
18
|
+
exit_command("Failed: #{e}")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "crypt:unmount", "Unmounts encrypted disk with TrueCrypt"
|
23
|
+
|
24
|
+
def unmount
|
25
|
+
begin
|
26
|
+
@app = TrueCryptApp.new
|
27
|
+
run @app.unmount_command
|
28
|
+
say "finished", :green
|
29
|
+
rescue Exception => e
|
30
|
+
exit_command("Failed: #{e}")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
File without changes
|
File without changes
|
data/lib/marhan_cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marhan_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
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: 2012-11-
|
12
|
+
date: 2012-11-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -59,12 +59,14 @@ files:
|
|
59
59
|
- Rakefile
|
60
60
|
- bin/mcli
|
61
61
|
- lib/marhan_cli.rb
|
62
|
+
- lib/marhan_cli/app/true_crypt_app.rb
|
62
63
|
- lib/marhan_cli/command.rb
|
63
64
|
- lib/marhan_cli/commands/network.rb
|
65
|
+
- lib/marhan_cli/commands/true_crypt.rb
|
64
66
|
- lib/marhan_cli/commands/web.rb
|
65
67
|
- lib/marhan_cli/helper/constraint.rb
|
66
|
-
- lib/marhan_cli/
|
67
|
-
- lib/marhan_cli/
|
68
|
+
- lib/marhan_cli/network/errors.rb
|
69
|
+
- lib/marhan_cli/network/remote_machine.rb
|
68
70
|
- lib/marhan_cli/version.rb
|
69
71
|
- marhan_cli.gemspec
|
70
72
|
homepage: https://github.com/marhan/marhan_cli
|