marhan_cli 0.0.6 → 0.0.7
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 +6 -1
- data/README.md +7 -0
- data/lib/marhan_cli/app/true_crypt_app.rb +15 -5
- data/lib/marhan_cli/command.rb +13 -1
- data/lib/marhan_cli/commands/network.rb +1 -1
- data/lib/marhan_cli/commands/true_crypt.rb +20 -6
- data/lib/marhan_cli/version.rb +1 -1
- data/marhan_cli.gemspec +1 -0
- metadata +18 -2
data/Changelog.md
CHANGED
@@ -22,4 +22,9 @@
|
|
22
22
|
## v0.0.6
|
23
23
|
|
24
24
|
* TrueCrypt command added.
|
25
|
-
* Mount and unmount commands for private hard disk added.
|
25
|
+
* Mount and unmount commands for private hard disk added.
|
26
|
+
|
27
|
+
## v0.0.7
|
28
|
+
|
29
|
+
* TrueCrypt command for unmount all devices added.
|
30
|
+
* Expect configuration file '.marhan_cli.yaml' in home directory to define encrypted devices and mount folder.
|
data/README.md
CHANGED
@@ -22,6 +22,13 @@ Ater installation of the gem type `mcli` to get a list of possible commands
|
|
22
22
|
|
23
23
|
$ mcli
|
24
24
|
|
25
|
+
Configuration file `~/.marhan_cli.yml` is used for several commands
|
26
|
+
|
27
|
+
crypt:
|
28
|
+
mount_folder: /Volumes
|
29
|
+
encrypted_devices:
|
30
|
+
enc1: /dev/rdisk1s2
|
31
|
+
|
25
32
|
## Contributing
|
26
33
|
|
27
34
|
1. Fork it
|
@@ -1,19 +1,29 @@
|
|
1
|
-
|
1
|
+
# encoding: utf-8
|
2
2
|
|
3
3
|
module MarhanCli
|
4
4
|
class TrueCryptApp
|
5
5
|
|
6
|
-
def initialize()
|
6
|
+
def initialize(mount_folder = nil)
|
7
7
|
@binary = "/Applications/TrueCrypt.app/Contents/MacOS/TrueCrypt"
|
8
8
|
raise ArgumentError, "No installation of TrueCrypt found!" unless File.exist? @binary
|
9
|
+
@mount_folder = mount_folder
|
9
10
|
end
|
10
11
|
|
11
|
-
def mount_command()
|
12
|
-
"#{@binary} --mount
|
12
|
+
def mount_command(encrypted_devices)
|
13
|
+
"#{@binary} --mount #{encrypted_devices[:enc1]} #{mount_folder}/#{:enc1.to_s}"
|
13
14
|
end
|
14
15
|
|
15
16
|
def unmount_command()
|
16
|
-
"#{@binary} -d /
|
17
|
+
"#{@binary} -d #{mount_folder}/enc1"
|
18
|
+
end
|
19
|
+
|
20
|
+
def mount_folder
|
21
|
+
raise ArgumentError, "No mount folder defined! Don't know where to mount!" unless @mount_folder
|
22
|
+
@mount_folder
|
23
|
+
end
|
24
|
+
|
25
|
+
def unmount_all_command()
|
26
|
+
"#{@binary} -d"
|
17
27
|
end
|
18
28
|
|
19
29
|
end
|
data/lib/marhan_cli/command.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "thor"
|
3
|
+
require "ambience"
|
3
4
|
|
4
5
|
module MarhanCli
|
5
6
|
class Command < Thor
|
@@ -7,10 +8,21 @@ module MarhanCli
|
|
7
8
|
|
8
9
|
protected
|
9
10
|
|
10
|
-
|
11
|
+
CONFIG_FILE = ".marhan_cli.yml"
|
12
|
+
|
13
|
+
def exit_with_error(message)
|
11
14
|
say message, :red
|
12
15
|
exit(1)
|
13
16
|
end
|
14
17
|
|
18
|
+
def load_config
|
19
|
+
config_file_path = File.join(File.expand_path("~/"), CONFIG_FILE)
|
20
|
+
unless File.exists?(config_file_path)
|
21
|
+
raise "Stop processing! Command needs the configuration file '#{CONFIG_FILE}' in you're home directory."
|
22
|
+
end
|
23
|
+
say "I will use the '#{CONFIG_FILE}' configuration file in you're home directory.", :cyan
|
24
|
+
config = Ambience.create(config_file_path)
|
25
|
+
config.to_mash
|
26
|
+
end
|
15
27
|
end
|
16
28
|
end
|
@@ -42,7 +42,7 @@ module MarhanCli
|
|
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
|
-
|
45
|
+
exit_with_error("copying of id file to remote machine failed: #{e}")
|
46
46
|
end
|
47
47
|
|
48
48
|
protected
|
@@ -11,23 +11,37 @@ module MarhanCli
|
|
11
11
|
|
12
12
|
def mount
|
13
13
|
begin
|
14
|
-
|
15
|
-
|
14
|
+
config = load_config
|
15
|
+
@app = TrueCryptApp.new(config.crypt.mount_folder)
|
16
|
+
run @app.mount_command(config.crypt[:encrypted_devices])
|
16
17
|
say "finished", :green
|
17
18
|
rescue Exception => e
|
18
|
-
|
19
|
+
exit_with_error(e)
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
22
|
-
desc "crypt:
|
23
|
+
desc "crypt:umount", "Unmounts encrypted disk with TrueCrypt"
|
23
24
|
|
24
25
|
def unmount
|
25
26
|
begin
|
26
|
-
|
27
|
+
config = load_config
|
28
|
+
@app = TrueCryptApp.new(config.crypt.mount_folder)
|
27
29
|
run @app.unmount_command
|
28
30
|
say "finished", :green
|
29
31
|
rescue Exception => e
|
30
|
-
|
32
|
+
exit_with_error(e)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "crypt:umount_all", "Unmounts all encrypted disk with TrueCrypt"
|
37
|
+
|
38
|
+
def umount_all
|
39
|
+
begin
|
40
|
+
@app = TrueCryptApp.new
|
41
|
+
run @app.unmount_all_command
|
42
|
+
say "finished", :green
|
43
|
+
rescue Exception => e
|
44
|
+
exit_with_error(e)
|
31
45
|
end
|
32
46
|
end
|
33
47
|
|
data/lib/marhan_cli/version.rb
CHANGED
data/marhan_cli.gemspec
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.7
|
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-
|
12
|
+
date: 2012-12-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 2.6.1
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: ambience
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.0.0
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.0.0
|
46
62
|
description:
|
47
63
|
email: me@markushanses.de
|
48
64
|
executables:
|