storazzo 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f27732afb2b636a54136fdd1db2270c163addc37dc85d35585cee8c4c946b090
4
- data.tar.gz: a7fe6fbc15aedbef4578662418f1b8d67073d45865d7485efa6816ae14421611
3
+ metadata.gz: b20663eda1cb6d0a43c4391e3c50a111802c4ddbdfdfe28c0f99fd3a12af2d9f
4
+ data.tar.gz: 7efd0bf78085f676796c91f24fece24621e18477ca67d0b002536b6c13492fe7
5
5
  SHA512:
6
- metadata.gz: 7cb68f6675345a08f6a619b3ff0ef0dadc2455c5bc10aecc9f9e8b245f2d271b72a0b0531f4c6149f41cde81bfeb154345a7bc2388d1beca7ac41db25018dd7b
7
- data.tar.gz: 610059ea7c57e7d303c945104a106935310b141e5322f9096683bc6bbf2dd7f4ec4257ed02c6ebfa1acf24fdb891a6eceb886d6225565424a43fb7087e90a955
6
+ metadata.gz: 17baa0e81ee526a21bf5a4129b66d51f04db26cecb3215288fd410468a0d8212aba2f22b1163a9be89f20d4e79791e778f74f7a7d965fcbff0c67f1f7054c43e
7
+ data.tar.gz: d2d208632520d5f65bf9a0292f336271eaef1c1b88ee605222f1970d3127e47cb1229add34d310bed8af74d536a1a520b8c3dc290dc24be46037a9e740ab50ce
data/Gemfile CHANGED
@@ -1 +1,5 @@
1
- # useless now
1
+ # useless now
2
+
3
+
4
+ # to troubleshoot/debug things
5
+ gem 'rubocop'
data/Makefile CHANGED
@@ -29,14 +29,18 @@ test:
29
29
  #bin/ricdisk-magic Ciao-da-Makefile
30
30
  echo 3. run rake test.. ont configured yet just a memo for the future.
31
31
  RUBYOPT="-W0" rake test
32
+ echo 4. Prove I can include local gem in irb and play around. Similarly to rails console without reload.
33
+ make irb-test
32
34
  @echo 'OK: ALL TESTS PASSED. #STIKA'
33
35
 
36
+ # RicDisk test
34
37
  mounts:
35
- echo "Storazzo::Main.all_mounts " | irb -Ilib -rstorazzo
36
-
38
+ echo "Storazzo::Main.all_mounts ; nil" | irb -Ilib -rstorazzo
37
39
 
38
40
  irb:
39
41
  irb -Ilib -rstorazzo
42
+ irb-test:
43
+ ./irb-test.sh
40
44
 
41
45
  watch-test:
42
46
  watch -c make test
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2.0
data/bin/ricdisk-magic CHANGED
@@ -6,46 +6,18 @@
6
6
  # placeholder until i make it work..
7
7
  # https://guides.rubygems.org/make-your-own-gem/#adding-an-executable
8
8
  require 'storazzo'
9
- #require 'lib/storazzo'
9
+ require 'yaml'
10
+ require 'socket'
11
+ require 'optparse' # http://ruby.about.com/od/advancedruby/a/optionparser.htm
12
+
13
+ #require_relative '../lib/storazzo'
14
+
10
15
  puts "First I need to figure out how to bring in all the libraries in here.."
11
16
  puts Storazzo::Main.hi(ARGV[0])
12
17
  exit(0)
13
18
  ############# ############# ############# ############# ############# ############# ############# #############
14
19
 
15
20
 
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
- #require 'google/protobuf'
44
- #require_relative '../etc/protos/out/ricdisk_pb'
45
- require 'yaml'
46
- require 'socket'
47
- require 'optparse' # http://ruby.about.com/od/advancedruby/a/optionparser.htm
48
-
49
21
  # I believe this is wrong
50
22
  #require 'storazzo'
51
23
  # required to have methods wiothout self.
@@ -91,8 +63,8 @@ $myconf = {
91
63
  :media_dirs => %w{ /media/riccardo/ /Volumes/ /mnt/ ~/git/storazzo/var/test/ /sobenme/giusto/per/imparare/ad/ammutolire/gli/errori/ },
92
64
  :mount_types => %w{ vfat ntfs },
93
65
  }
94
- $stats_file = "ricdisk_stats_v11.rds"
95
- $gcs_bucket = 'palladius'
66
+ $stats_file = "ricdisk_stats_v11.rds" # => RicDiskStatsFile
67
+ $gcs_bucket = 'TODO-CHANGE-CONFIG-palladius'
96
68
 
97
69
  # This template from scripta.rb. from 2.1.0 removed aby ric gem dependency.
98
70
  # 2022-04-26 2.1.1 Added more colors
@@ -142,26 +114,30 @@ def real_program
142
114
  puts white("Hello world from #{$myconf[:app_name]}!")
143
115
  puts "Description: '''#{white $myconf[:description] }'''"
144
116
 
145
- if ARGV == [] # empty -> ALL
146
- dirs = RicDisk.find_active_dirs()
147
- dirs.each {|dir|
148
- RicDisk.sbrodola_ricdisk(dir)
149
- RicDisk.calculate_stats_files(dir) # dir is inutile
150
- } # TODO refactor in option sbrodola_afterwards=true. :)
151
- else
152
- deb "I consider ARGV come la lista di directories da parsare :)"
153
- dirs = RicDisk.find_active_dirs()
154
- ARGV.each{ |dir|
155
- dir = File.expand_path(dir)
156
- if dirs.include?(dir)
157
- deb "Legit dir: #{green dir}"
158
- RicDisk.sbrodola_ricdisk(dir)
159
- RicDisk.calculate_stats_files(dir) # dir is inutile
160
- else
161
- deb "Figghiu ri buttana: doesnt exist #{red dir}"
162
- end
163
- }
164
- end
117
+
118
+ config = RicDiskConfig.auto_sbrodola(ARGV)
119
+
120
+ # if ARGV == [] # empty -> ALL
121
+ # dirs = RicDisk.find_active_dirs()
122
+ # dirs.each {|dir|
123
+ # RicDisk.sbrodola_ricdisk(dir)
124
+ # RicDisk.calculate_stats_files(dir) # dir is inutile
125
+ # } # TODO refactor in option sbrodola_afterwards=true. :)
126
+ # else
127
+ # deb "I consider ARGV come la lista di directories da parsare :)"
128
+ # dirs = RicDisk.find_active_dirs()
129
+ # ARGV.each{ |dir|
130
+ # dir = File.expand_path(dir)
131
+ # if dirs.include?(dir)
132
+ # deb "Legit dir: #{green dir}"
133
+ # RicDisk.sbrodola_ricdisk(dir)
134
+ # RicDisk.calculate_stats_files(dir) # dir is inutile
135
+ # else
136
+ # deb "Figghiu ri buttana: doesnt exist #{red dir}"
137
+ # end
138
+ # }
139
+ # end #/if aRGV
140
+
165
141
  end
166
142
 
167
143
  def main(filename)
@@ -6,7 +6,7 @@ module Storazzo
6
6
  end
7
7
 
8
8
  module Storazzo::Colors
9
- #class Storazzo::Colors1
9
+
10
10
  PREPEND_ME = "[Storazzo::Colors] "
11
11
 
12
12
  def deb(s); puts "#DEB #{gray(s)}" if $DEBUG; end
@@ -0,0 +1,12 @@
1
+ # Ric common stuff! :)
2
+
3
+
4
+ module Storazzo::Common
5
+
6
+
7
+ def deb(str)
8
+ puts "[DEB] #{str}"
9
+ end
10
+
11
+
12
+ end
data/lib/storazzo/main.rb CHANGED
@@ -29,10 +29,18 @@ module Storazzo
29
29
  def self.all_mounts(opts={})
30
30
  opts_verbose = opts.fetch :verbose, true
31
31
 
32
- self.hi "Storazzo::Main.all_mounts(): BEGIN - RicDiskVersion is: #{Storazzo::RicDisk::RICDISK_VERSION}"
32
+ self.hi "Storazzo::Main.all_mounts(): BEGIN - RicDiskVersion is: #{Storazzo::RicDiskUgly::RICDISK_VERSION}"
33
33
 
34
+ pwhite("1. First I load the config in verbose mode..")
35
+ config = Storazzo::RicDiskConfig.instance
36
+ config.load
37
+ # puts config.object_id
38
+ # puts Storazzo::RicDiskConfig.instance.object_id
34
39
  pwhite "TODO(ricc): show a list of all RicDisk relevant mounts" if opts_verbose
40
+ #d = Storazzo::RicDisk.new
41
+ config.iterate_through_file_list_for_disks() # analyze_local_system
35
42
  #sbrodola_ricdisk("/Volumes/")
43
+ Storazzo::RicDisk.test
36
44
  Storazzo::RicDisk.find_active_dirs
37
45
  #Storazzo::RicDisk.sbrodola_ricdisk StorazzoMod::root + "./var/disks/"
38
46
  #sbrodola_ricdisk(StorazzoMod::root + "./var/disks/") rescue "[Storazzo::AllMount] SomeError: #{$!}"
@@ -1,102 +1,185 @@
1
-
1
+ # A RicDisk wraps a local mount/disk/folder
2
+ # it's considered interesting if there's a ".ricdisk/.ricdisk"
2
3
 
3
4
  module Storazzo
4
5
  class Storazzo::RicDisk
5
- RICDISK_VERSION = "1.0"
6
- DEFAULT_MEDIA_DIRS = %w{
7
- /media/riccardo/
8
- /Volumes/
9
- /mnt/
10
- ~/git/storazzo/var/test/disks/
11
- /wrong/on/purpose/
12
- }.append(Storazzo.root + "/var/test/disks/")
13
-
14
6
 
15
7
  include Hashify
16
8
  extend Storazzo::Colors
17
-
18
- # todo substitute wqith protobuf..
19
- attr_accessor :name, :description, :ricdisk_file, :local_mountpoint, :wr
20
-
21
- def self.interesting_mount_points(opts={})
22
- #https://unix.stackexchange.com/questions/177014/showing-only-interesting-mount-points-filtering-non-interesting-types
23
- `mount | grep -Ev 'type (proc|sysfs|tmpfs|devpts|debugfs|rpc_pipefs|nfsd|securityfs|fusectl|devtmpfs) '`.split(/\n+/)
24
- end
25
-
26
- def initialize(path, ricdisk_file)
9
+
10
+
11
+ ## Instance variables
12
+
13
+ # in order of finding, so the first will be the one we actually READ and use. I could looknat the date but cmon...
14
+ @@config_files = %W{ ricdisk.yaml .ricdisk }
15
+ @@ricdisk_version = '2.0'
16
+ @@default_gemfile_test_disks_folder = Storazzo.root + "/var/test/disks/"
17
+ # Immutable
18
+ DEFAULT_MEDIA_FOLDERS = %w{
19
+ /Volumes/
20
+ /mnt/
21
+ }.append(@@default_gemfile_test_disks_folder ).append("/media/#{ENV["USER"]}/" )
22
+
23
+ # # todo substitute with protobuf..
24
+ attr_accessor :name, :description, :ricdisk_file, :local_mountpoint, :wr, :path, :ricdisk_file_empty, :size, :active_dirs
25
+
26
+
27
+ ################################
28
+ ## INSTANCE methods
29
+ ################################
30
+
31
+
32
+ def initialize(path, opts={})
33
+ puts "[DEB] RicDisk initialize.. path=#{path}"
27
34
  @local_mountpoint = path
28
- @description = "This is an automated RicDisk description from v.#{VERSION}. Riccardo feel free to edit away with characteristicshs of this device.. Created on #{Time.now}'"
29
- @ricdisk_version = VERSION
30
- @ricdisk_file = ricdisk_file
31
- #@questo_non_esiste = :sobenme
35
+ @description = "This is an automated RicDisk description from v.#{@@ricdisk_version}. Created on #{Time.now}'"
36
+ @ricdisk_version = @@ricdisk_version
37
+ #@ricdisk_file = ricdisk_file
38
+ @ricdisk_file = RicDisk.get_ricdisk_file(path)
39
+ @ricdisk_file_empty = ricdisk_file_empty?
32
40
  @label = path.split("/").last
33
41
  @name = path.split("/").last
34
- @wr = File.writable?("#{path}/#{ricdisk_file}" ) # .writeable?
35
- @tags = 'ricdisk'
36
- find_info_from_mount(path)
37
- find_info_from_df()
42
+ #@wr = File.writable?("#{path}/#{ricdisk_file}" ) # .writeable?
43
+ @tags = ['ricdisk', 'storazzo']
44
+ @size = `du -s '#{path}'`.split(/\s/)[0] # self.size
45
+ puts :beleza
46
+ # @config = RicDiskConfig.instance.get_config
47
+ # #puts @config if @config
48
+ # find_info_from_mount(path)
49
+ # find_info_from_df()
38
50
  end
39
-
40
- def ricdisk_absolute_path
41
- @local_mountpoint + "/" + @ricdisk_file
51
+
52
+ def ricdisk_file_empty?()
53
+ File.empty?( "#{local_mountpoint}/#.ricdisk.yaml")
42
54
  end
43
-
44
- def add_tag(tag)
45
- @tags += ", #{tag}"
55
+
56
+ def ok_dir?
57
+ not @ricdisk_file.nil?
46
58
  end
59
+
60
+
61
+ def analyze_local_system()
62
+ puts :TODO
63
+ puts "1. Interesting Mounts: #{green interesting_mount_points}"
64
+ puts "2. Sbrodoling everything: :TODO"
65
+ # find_info_from_mount(path)
66
+ # find_info_from_df()
67
+ end
68
+
69
+ def path
70
+ local_mountpoint
71
+ end
72
+
73
+ def to_s
74
+ "RicDisk(paz=#{path}, writeable=#{writeable?}, size=#{size}B)"
75
+ end
76
+
77
+ # could take long..
78
+ # def size
79
+ # `du -s '#{path}'`.split(/\s/)[0]
80
+ # end
81
+
82
+ def writeable?()
83
+ :boh
84
+ end
85
+
86
+ ################################
87
+ ## CLASS methods
88
+ ################################
89
+
90
+
91
+ # All places where to find for something :)
92
+ def self.default_media_folders
93
+ DEFAULT_MEDIA_FOLDERS
94
+ end
95
+
96
+
97
+ def self.test # _localgem_disks
98
+ d = RicDisk.new( @@default_gemfile_test_disks_folder)
99
+ puts (d)
100
+ puts "do something with it: #{d}"
101
+ #d.find_active_dirs()
102
+ end
103
+
104
+
105
+
106
+
47
107
 
48
- # might have other things in the future...
49
- def find_info_from_mount(path)
50
- mount_table_lines = interesting_mount_points()
51
- mount_line = nil
52
- mount_table_lines.each do |line|
53
- next if line =~ /^map /
54
- dev, on, mount_path, mode = line.split(/ /)
55
- if mount_path==path
56
- mount_line = line
57
- else
58
- @info_from_mount = false
59
- end
108
+ def self.find_active_dirs(base_dirs=nil, also_mountpoints=true)
109
+ if base_dirs.nil?
110
+ base_dirs = default_media_folders
111
+ puts "find_active_dirs with empty input -> using default_media_folders: #{yellow default_media_folders}"
60
112
  end
61
- @info_from_mount = ! (mount_line.nil?)
62
- if @info_from_mount
63
- #@mount_line = mount_line
64
- @description += "\nMount line:\n" + mount_line
65
- @remote_mountpoint = mount_line.split(/ /)[0]
66
- @fstype = mount_line.split(/ /)[3].gsub(/[\(,]/, '')
67
- add_tag(:synology) if @remote_mountpoint.match('1.0.1.10')
113
+ active_dirs = []
114
+ base_dirs.each do |ugly_dir|
115
+ # https://stackoverflow.com/questions/1899072/getting-a-list-of-folders-in-a-directory#:~:text=Dir.chdir(%27/destination_directory%27)%0ADir.glob(%27*%27).select%20%7B%7Cf%7C%20File.directory%3F%20f%7D
116
+ dir = File.expand_path(ugly_dir)
117
+ begin
118
+ x=[]
119
+ # puts "TEST2 DIR EXISTS: #{dir} -> #{Dir.exists?(dir)}"
120
+ unless Dir.exists?(dir)
121
+ deb "Dir doesnt exist, skipping: #{dir}"
122
+ next
123
+ end
124
+ Dir.chdir(dir)
125
+ x = Dir.glob('*').select {|f| File.directory? f}
126
+ subdirs = x.map{|subdir| "#{dir}#{subdir}"}
127
+ subdirs.each{|subdir|
128
+ #puts `ls -al "#{subdir}"`
129
+ active_dirs << subdir if ok_dir? # self.ok_dir?(subdir)
130
+ }
131
+ #puts(white x)
132
+ rescue Exception => e # optionally: `rescue Exception => ex`
133
+ puts "Exception: '#{e}'"
134
+ ensure # will always get executed
135
+ #deb 'Always gets executed.'
136
+ #x = []
137
+ end
68
138
  end
69
139
  end
70
-
71
- def find_info_from_df()
72
- path = @local_mountpoint
73
- df_info = `df -h "#{path}"`
74
- @df_info = df_info
75
- lines = df_info.split(/\n+/)
76
- raise "I need exactly TWO lines! Or no info is served here..." unless lines.size == 2
77
- mount, @size_readable, used_size, avail_size, @disk_utilization, other = lines[1].split(/\s+/) # second line..
140
+
141
+
142
+ # new
143
+ def self.get_ricdisk_file(path)
144
+ puts "RICC_WARNING TODO use @@config_files instead"
145
+ return ".ricdisk.yaml" if File.exist?("#{path}/.ricdisk.yaml") #and File.empty?( "#{path}/.ricdisk.yaml")
146
+ return ".ricdisk" if File.exist?("#{path}/.ricdisk") # and File.empty?( "#{path}/.ricdisk")
147
+ return nil
78
148
  end
149
+
79
150
 
80
-
81
-
82
- def self.sbrodola_ricdisk(subdir)
151
+ def self.interesting_mount_points(opts={})
152
+ #https://unix.stackexchange.com/questions/177014/showing-only-interesting-mount-points-filtering-non-interesting-types
153
+ `mount | grep -Ev 'type (proc|sysfs|tmpfs|devpts|debugfs|rpc_pipefs|nfsd|securityfs|fusectl|devtmpfs) '`.split(/\n+/)
154
+ end
155
+
156
+ # maybe move to a RiccFile class? Maybe even INHERIT from FILE?
157
+ def self.obsolescence_seconds file_path
158
+ creation_time = File.stat(file_path).ctime
159
+ deb("[obsolescence_seconds] File #{file_path}: #{creation_time} - #{(Time.now - creation_time)} seconds ago")
160
+ (Time.now - creation_time).to_i
161
+ end
162
+ # maybe move to a RiccFile class? Maybe even INHERIT from FILE?
163
+ def self.obsolescence_days(file_path)
164
+ return obsolescence_seconds(file_path) / 86400
165
+ end
166
+
167
+
168
+ # FORMER SBRODOLA, now write_config_yaml_to_disk
169
+ def self.write_config_yaml_to_disk(subdir) # sbrodola_ricdisk(subdir)
83
170
  # given a path, if .ricdisk exists i do stuff with it..
84
171
  disk_info = nil
85
172
  unless self.ok_dir?(subdir)
86
- puts("Nothing for me here. Existing")
173
+ puts("Nothing for me here: '#{subdir}'. Existing")
87
174
  return
88
175
  end
89
176
  if File.exists?( "#{subdir}/.ricdisk") and File.empty?( "#{subdir}/.ricdisk")
90
177
  deb("Interesting1. Empty file! Now I write YAML with it.")
91
178
  disk_info = RicDisk.new(subdir, '.ricdisk')
92
- #puts(x)
93
- #puts(yellow x.to_yaml)
94
179
  end
95
180
  if File.exists?( "#{subdir}/.ricdisk.yaml") and File.empty?( "#{subdir}/.ricdisk.yaml")
96
181
  deb("Interesting2. Empty file! TODO write YAML with it.")
97
182
  disk_info = RicDisk.new(subdir, '.ricdisk.yaml')
98
- # todo write
99
- #puts(x)
100
183
  puts(yellow disk_info.to_yaml)
101
184
  end
102
185
  if disk_info
@@ -114,50 +197,22 @@ module Storazzo
114
197
  #puts(white `cat "#{subdir}/.ricdisk"`)
115
198
  end
116
199
  end
117
-
118
- # separiamo cosi usiamo meglio...
200
+
201
+ # TODO obsolete this as i should NOT be calling it from clas, but from method.
119
202
  def self.ok_dir?(subdir)
120
203
  File.exists?( "#{subdir}/.ricdisk") or File.exists?( "#{subdir}/.ricdisk.yaml")
121
204
  end
122
205
 
123
- def self.obsolescence_seconds file_path
124
- creation_time = File.stat(file_path).ctime
125
- deb("[obsolescence_seconds] File #{file_path}: #{creation_time} - #{(Time.now - creation_time)} seconds ago")
126
- (Time.now - creation_time).to_i
127
- end
128
- def self.obsolescence_days(file_path)
129
- return obsolescence_seconds(file_path) / 86400
130
- end
131
-
132
- def self.backquote_execute(cmd)
133
- # executed a command wrapped by dryrun though
134
- return "DRYRUN backquote_execute(#{cmd})" if $opts[:dryrun]
135
- `#{cmd}`
136
- end
137
-
138
- def self.upload_to_gcs(file, opts={})
139
- deb("upload_to_gcs(#{file}). TODO(ricc) after breafast upload to GCS : #{file}")
140
- mount_name = file.split('/')[-2]
141
- filename = "#{mount_name}-#{File.basename file}"
142
- hostname = Socket.gethostname[/^[^.]+/]
143
- command = "gsutil cp '#{file}' gs://#{$gcs_bucket}/backup/ricdisk-magic/#{ hostname }-#{filename}"
144
- deb("Command: #{command}")
145
- ret = backquote_execute(command)
146
- # if $opts[:debug] do
147
- # puts "+ Current list of files:"
148
- # ret = backquote_execute("gsutil ls -al gs://#{$gcs_bucket}/backup/ricdisk-magic/")
149
- # puts ret
150
- # end
151
- ret
152
- end
153
-
206
+
207
+
154
208
  # Create RDS file.
155
209
  def self.calculate_stats_files(dir, opts={})
156
210
  opts_upload_to_gcs = opts.fetch :upload_to_gcs, true
157
211
  full_file_path = "#{dir}/#{$stats_file}"
212
+ return "This refacgtor is for another day"
158
213
 
159
214
  puts("calculate_stats_files(#{white dir}): #{white full_file_path}")
160
- puts "TEST1 DIR EXISTS: #{dir} -> #{Dir.directory? dir}"
215
+ puts "TEST1 DIR EXISTS: #{dir} -> #{File.directory? dir}"
161
216
  Dir.chdir(dir)
162
217
  if File.exists?(full_file_path) and ($opts[:force] == false)
163
218
  puts "File '#{$stats_file}' exists already." # - now should see if its too old, like more than 1 week old"
@@ -176,66 +231,128 @@ module Storazzo
176
231
  end
177
232
  end
178
233
 
179
- def self.find_active_dirs(base_dirs=nil, also_mountpoints=true)
180
- base_dirs = DEFAULT_MEDIA_DIRS if base_dirs.nil?
181
- active_dirs = []
182
- base_dirs.each do |ugly_dir|
183
- # https://stackoverflow.com/questions/1899072/getting-a-list-of-folders-in-a-directory#:~:text=Dir.chdir(%27/destination_directory%27)%0ADir.glob(%27*%27).select%20%7B%7Cf%7C%20File.directory%3F%20f%7D
184
- dir = File.expand_path(ugly_dir)
185
- begin
186
- x=[]
187
- # puts "TEST2 DIR EXISTS: #{dir} -> #{Dir.exists?(dir)}"
188
- unless Dir.exists?(dir)
189
- deb "Dir doesnt exist, skipping: #{dir}"
190
- next
191
- end
192
- Dir.chdir(dir)
193
- x = Dir.glob('*').select {|f| File.directory? f}
194
- subdirs = x.map{|subdir| "#{dir}#{subdir}"}
195
- subdirs.each{|subdir|
196
- #puts `ls -al "#{subdir}"`
197
- active_dirs << subdir if self.ok_dir?(subdir)
198
- }
199
- #puts(white x)
200
- rescue Exception => e # optionally: `rescue Exception => ex`
201
- puts "Exception: '#{e}'"
202
- ensure # will always get executed
203
- #deb 'Always gets executed.'
204
- #x = []
205
- end
206
- end
207
-
208
- if also_mountpoints
209
- =begin
210
- Example output from mount:
211
-
212
- devfs on /dev (devfs, local, nobrowse)
213
- /dev/disk3s6 on /System/Volumes/VM (apfs, local, noexec, journaled, noatime, nobrowse)
214
- /dev/disk3s2 on /System/Volumes/Preboot (apfs, local, journaled, nobrowse)
215
- /dev/disk3s4 on /System/Volumes/Update (apfs, local, journaled, nobrowse)
216
- /dev/disk1s2 on /System/Volumes/xarts (apfs, local, noexec, journaled, noatime, nobrowse)
217
- /dev/disk1s1 on /System/Volumes/iSCPreboot (apfs, local, journaled, nobrowse)
218
- /dev/disk1s3 on /System/Volumes/Hardware (apfs, local, journaled, nobrowse)
219
- /dev/disk3s5 on /System/Volumes/Data (apfs, local, journaled, nobrowse, protect)
220
- map auto_home on /System/Volumes/Data/home (autofs, automounted, nobrowse)
221
- //riccardo@1.0.1.10/video on /Volumes/video (afpfs, nodev, nosuid, mounted by ricc)
222
- //riccardo@1.0.1.10/photo on /Volumes/photo (afpfs, nodev, nosuid, mounted by ricc)
223
- =end
224
- # add directories from current mountpoints...
225
- mount_table_lines = interesting_mount_points()
226
- mount_table_lines.each{|line|
227
- next if line =~ /^map /
228
- dev, on, path, mode = line.split(/ /)
229
- #puts line
230
- #deb yellow(path)
231
- active_dirs << path if self.ok_dir?(path)
232
- }
233
- end
234
- active_dirs.uniq!
235
- puts("find_active_dirs(): found dirs " + green(active_dirs))
236
- return active_dirs
237
- end
234
+ # if also_mountpoints
235
+ # =begin
236
+ # Example output from mount:
237
+
238
+ # devfs on /dev (devfs, local, nobrowse)
239
+ # /dev/disk3s6 on /System/Volumes/VM (apfs, local, noexec, journaled, noatime, nobrowse)
240
+ # /dev/disk3s2 on /System/Volumes/Preboot (apfs, local, journaled, nobrowse)
241
+ # /dev/disk3s4 on /System/Volumes/Update (apfs, local, journaled, nobrowse)
242
+ # /dev/disk1s2 on /System/Volumes/xarts (apfs, local, noexec, journaled, noatime, nobrowse)
243
+ # /dev/disk1s1 on /System/Volumes/iSCPreboot (apfs, local, journaled, nobrowse)
244
+ # /dev/disk1s3 on /System/Volumes/Hardware (apfs, local, journaled, nobrowse)
245
+ # /dev/disk3s5 on /System/Volumes/Data (apfs, local, journaled, nobrowse, protect)
246
+ # map auto_home on /System/Volumes/Data/home (autofs, automounted, nobrowse)
247
+ # //riccardo@1.0.1.10/video on /Volumes/video (afpfs, nodev, nosuid, mounted by ricc)
248
+ # //riccardo@1.0.1.10/photo on /Volumes/photo (afpfs, nodev, nosuid, mounted by ricc)
249
+ # =end
250
+ # # add directories from current mountpoints...
251
+ # mount_table_lines = interesting_mount_points()
252
+ # mount_table_lines.each{|line|
253
+ # next if line =~ /^map /
254
+ # dev, on, path, mode = line.split(/ /)
255
+ # #puts line
256
+ # #deb yellow(path)
257
+ # active_dirs << path if self.ok_dir?(path)
258
+ # }
259
+ # end
260
+ # active_dirs.uniq!
261
+ # puts("find_active_dirs(): found dirs " + green(active_dirs))
262
+ # return active_dirs
263
+ # end
238
264
 
265
+
266
+
267
+ end #/Class
268
+ end #/Module
269
+
270
+
271
+
272
+
273
+
274
+ # def initialize(path, ricdisk_file)
275
+ # puts "[DEB] RicDisk initialize.. path=#{path}"
276
+ # @local_mountpoint = path
277
+ # @description = "This is an automated RicDisk description from v.#{VERSION}. Riccardo feel free to edit away with characteristicshs of this device.. Created on #{Time.now}'"
278
+ # @ricdisk_version = VERSION
279
+ # @ricdisk_file = ricdisk_file
280
+ # #@questo_non_esiste = :sobenme
281
+ # @label = path.split("/").last
282
+ # @name = path.split("/").last
283
+ # @wr = File.writable?("#{path}/#{ricdisk_file}" ) # .writeable?
284
+ # @tags = 'ricdisk'
285
+ # puts :beleza
286
+ # @config = RicDiskConfig.instance.get_config
287
+ # #puts @config if @config
288
+ # find_info_from_mount(path)
289
+ # find_info_from_df()
290
+ # end
291
+
292
+ # def ricdisk_absolute_path
293
+ # @local_mountpoint + "/" + @ricdisk_file
294
+ # end
239
295
 
240
- end
241
- end
296
+ # def add_tag(tag)
297
+ # @tags += ", #{tag}"
298
+ # end
299
+
300
+ # # might have other things in the future...
301
+ # def find_info_from_mount(path)
302
+ # mount_table_lines = interesting_mount_points()
303
+ # mount_line = nil
304
+ # mount_table_lines.each do |line|
305
+ # next if line =~ /^map /
306
+ # dev, on, mount_path, mode = line.split(/ /)
307
+ # if mount_path==path
308
+ # mount_line = line
309
+ # else
310
+ # @info_from_mount = false
311
+ # end
312
+ # end
313
+ # @info_from_mount = ! (mount_line.nil?)
314
+ # if @info_from_mount
315
+ # #@mount_line = mount_line
316
+ # @description += "\nMount line:\n" + mount_line
317
+ # @remote_mountpoint = mount_line.split(/ /)[0]
318
+ # @fstype = mount_line.split(/ /)[3].gsub(/[\(,]/, '')
319
+ # add_tag(:synology) if @remote_mountpoint.match('1.0.1.10')
320
+ # end
321
+ # end
322
+
323
+ # def find_info_from_df()
324
+ # path = @local_mountpoint
325
+ # df_info = `df -h "#{path}"`
326
+ # @df_info = df_info
327
+ # lines = df_info.split(/\n+/)
328
+ # raise "I need exactly TWO lines! Or no info is served here..." unless lines.size == 2
329
+ # mount, @size_readable, used_size, avail_size, @disk_utilization, other = lines[1].split(/\s+/) # second line..
330
+ # end
331
+
332
+
333
+
334
+
335
+
336
+
337
+ # def self.backquote_execute(cmd)
338
+ # # executed a command wrapped by dryrun though
339
+ # return "DRYRUN backquote_execute(#{cmd})" if $opts[:dryrun]
340
+ # `#{cmd}`
341
+ # end
342
+
343
+ # def self.upload_to_gcs(file, opts={})
344
+ # deb("upload_to_gcs(#{file}). TODO(ricc) after breafast upload to GCS : #{file}")
345
+ # mount_name = file.split('/')[-2]
346
+ # filename = "#{mount_name}-#{File.basename file}"
347
+ # hostname = Socket.gethostname[/^[^.]+/]
348
+ # command = "gsutil cp '#{file}' gs://#{$gcs_bucket}/backup/ricdisk-magic/#{ hostname }-#{filename}"
349
+ # deb("Command: #{command}")
350
+ # ret = backquote_execute(command)
351
+ # # if $opts[:debug] do
352
+ # # puts "+ Current list of files:"
353
+ # # ret = backquote_execute("gsutil ls -al gs://#{$gcs_bucket}/backup/ricdisk-magic/")
354
+ # # puts ret
355
+ # # end
356
+ # ret
357
+ # end
358
+
@@ -0,0 +1,93 @@
1
+ require 'singleton'
2
+ require 'yaml'
3
+
4
+ module Storazzo
5
+ class Storazzo::RicDiskConfig
6
+ include Singleton
7
+ include Storazzo::Common
8
+ include Storazzo::Colors
9
+
10
+ @@default_config_location = "~/.storazzo.yaml"
11
+ attr_accessor :config, :config_file
12
+
13
+ def load(config_path=nil, opts={})
14
+ verbose = opts.fetch :verbose, false
15
+
16
+ puts "[VERBOSE] Storazzo::RicDiskConfig.load(): BEGIN " if verbose
17
+ # trying default location
18
+ possible_locations = [ @@default_config_location , "./.storazzo.yaml"]
19
+ if config_path
20
+ possible_locations =possible_locations.append(config_path)
21
+ end
22
+ puts "[VERBOSE] Searching these paths in order: #{possible_locations}" if verbose
23
+ possible_locations.each do |possible_path|
24
+ paz = File.expand_path(possible_path)
25
+ #puts "DEB paz:#{paz}"
26
+ if File.exists?(paz)
27
+ @config_file = paz
28
+ @config = YAML.load(File.read paz) # YAML.load(File.read("file_path"))
29
+ #pp @config if verbose
30
+ #config_ver = @config[:ConfigVersion]
31
+ #puts @config[:ConfigVersion]
32
+ puts "Storazzo::RicDiskConfig v#{config_ver} parsed correctly"
33
+ puts "RicDiskConfig.to_s: #{self}" if verbose
34
+ return self.config
35
+ end
36
+ end
37
+ # only get here if nothing is found
38
+ raise "No config found across these locations: #{possible_locations}. Consider copying and editing: #{RicDiskConfig.gem_default_config_path}"
39
+ # @config = 42
40
+ # puts "[VERBOSE] Storazzo::RicDiskConfig.load(): END " if verbose
41
+ end
42
+
43
+ def config_ver
44
+ #self.
45
+ @config['ConfigVersion']
46
+ end
47
+ def config_default_folder
48
+ #self.
49
+ @config['Config']['DefaultFolder'] #rescue "Unknown config_default_folder: #{$!}"
50
+ end
51
+
52
+ def to_s
53
+ size = File.size @config_file
54
+ "RicDiskConfig(v#{config_ver}, file=#{ @config_file}) with #{size} bytes" # - config_default_folder=#{self.config_default_folder}"
55
+ end
56
+
57
+ def get_config(opts={})
58
+ return load(opts) if @config.nil?
59
+ @config
60
+ end
61
+
62
+ def self.gem_default_config_path
63
+ Storazzo.root + "/etc/storazzo_config.sample.yaml"
64
+ end
65
+
66
+ # UGLY CODE, copipasted from binary for ARGV
67
+ def iterate_through_file_list_for_disks(files_list=[])
68
+ if files_list == [] # or files_list.nil? # empty -> ALL
69
+ deb "iterate_through_file_list_for_disks(): no args provided"
70
+ dirs = RicDisk.find_active_dirs()
71
+ puts "DEB find_active_dirs: #{green dirs}"
72
+ dirs.each {|dir|
73
+ RicDisk.write_config_yaml_to_disk(dir)
74
+ RicDisk.calculate_stats_files(dir) # dir is inutile
75
+ } # TODO refactor in option sbrodola_afterwards=true. :)
76
+ else
77
+ deb "iterate_through_file_list_for_disks(): I consider files_list as a list of directories to parse :)"
78
+ dirs = RicDisk.find_active_dirs()
79
+ files_list.each do |dir|
80
+ dir = File.expand_path(dir)
81
+ if dirs.include?(dir)
82
+ deb "Legit dir: #{green dir}"
83
+ RicDisk.write_config_yaml_to_disk(dir)
84
+ RicDisk.calculate_stats_files(dir) # dir is inutile
85
+ else
86
+ deb "Figghiu ri buttana: doesnt exist #{red dir}"
87
+ end
88
+ end
89
+ end
90
+ end #/iterate_through_file_list_for_disks
91
+
92
+ end
93
+ end
@@ -0,0 +1,10 @@
1
+ # This class wraps the RDS file: we're going to write this RDS file
2
+ # directly in the disk: /mount/
3
+ module Storazzo
4
+ class Storazzo::RicDiskStatsFile
5
+ @@default_name = "ricdisk_stats_v11.rds" # => RicDiskStatsFile
6
+
7
+
8
+
9
+ end
10
+ end
@@ -0,0 +1,251 @@
1
+
2
+
3
+ module Storazzo
4
+ class Storazzo::RicDiskUgly
5
+ RICDISK_VERSION = "1.0ugly"
6
+ DEFAULT_MEDIA_DIRS = %w{
7
+ /media/riccardo/
8
+ /Volumes/
9
+ /mnt/
10
+ ~/storazzo/var/test/disks/
11
+ }.append(Storazzo.root + "/var/test/disks/")
12
+
13
+ include Hashify
14
+ extend Storazzo::Colors
15
+
16
+ # todo substitute with protobuf..
17
+ attr_accessor :name, :description, :ricdisk_file, :local_mountpoint, :wr
18
+
19
+ def self.interesting_mount_points(opts={})
20
+ #https://unix.stackexchange.com/questions/177014/showing-only-interesting-mount-points-filtering-non-interesting-types
21
+ `mount | grep -Ev 'type (proc|sysfs|tmpfs|devpts|debugfs|rpc_pipefs|nfsd|securityfs|fusectl|devtmpfs) '`.split(/\n+/)
22
+ end
23
+
24
+ def initialize(path, ricdisk_file)
25
+ puts "[DEB] RicDiskUgly initialize.. path=#{path}"
26
+ @local_mountpoint = path
27
+ @description = "This is an automated RicDiskUgly description from v.#{VERSION}. Riccardo feel free to edit away with characteristicshs of this device.. Created on #{Time.now}'"
28
+ @ricdisk_version = VERSION
29
+ @ricdisk_file = ricdisk_file
30
+ #@questo_non_esiste = :sobenme
31
+ @label = path.split("/").last
32
+ @name = path.split("/").last
33
+ @wr = File.writable?("#{path}/#{ricdisk_file}" ) # .writeable?
34
+ @tags = 'ricdisk'
35
+ puts :beleza
36
+ @config = RicDiskConfig.instance.get_config
37
+ #puts @config if @config
38
+ find_info_from_mount(path)
39
+ find_info_from_df()
40
+ end
41
+
42
+ def ricdisk_absolute_path
43
+ @local_mountpoint + "/" + @ricdisk_file
44
+ end
45
+
46
+ def add_tag(tag)
47
+ @tags += ", #{tag}"
48
+ end
49
+
50
+ # might have other things in the future...
51
+ def find_info_from_mount(path)
52
+ mount_table_lines = interesting_mount_points()
53
+ mount_line = nil
54
+ mount_table_lines.each do |line|
55
+ next if line =~ /^map /
56
+ dev, on, mount_path, mode = line.split(/ /)
57
+ if mount_path==path
58
+ mount_line = line
59
+ else
60
+ @info_from_mount = false
61
+ end
62
+ end
63
+ @info_from_mount = ! (mount_line.nil?)
64
+ if @info_from_mount
65
+ #@mount_line = mount_line
66
+ @description += "\nMount line:\n" + mount_line
67
+ @remote_mountpoint = mount_line.split(/ /)[0]
68
+ @fstype = mount_line.split(/ /)[3].gsub(/[\(,]/, '')
69
+ add_tag(:synology) if @remote_mountpoint.match('1.0.1.10')
70
+ end
71
+ end
72
+
73
+ def find_info_from_df()
74
+ path = @local_mountpoint
75
+ df_info = `df -h "#{path}"`
76
+ @df_info = df_info
77
+ lines = df_info.split(/\n+/)
78
+ raise "I need exactly TWO lines! Or no info is served here..." unless lines.size == 2
79
+ mount, @size_readable, used_size, avail_size, @disk_utilization, other = lines[1].split(/\s+/) # second line..
80
+ end
81
+
82
+
83
+
84
+ def self.sbrodola_ricdisk(subdir)
85
+ # given a path, if .ricdisk exists i do stuff with it..
86
+ disk_info = nil
87
+ unless self.ok_dir?(subdir)
88
+ puts("Nothing for me here. Existing")
89
+ return
90
+ end
91
+ if File.exists?( "#{subdir}/.ricdisk") and File.empty?( "#{subdir}/.ricdisk")
92
+ deb("Interesting1. Empty file! Now I write YAML with it.")
93
+ disk_info = RicDiskUgly.new(subdir, '.ricdisk')
94
+ #puts(x)
95
+ #puts(yellow x.to_yaml)
96
+ end
97
+ if File.exists?( "#{subdir}/.ricdisk.yaml") and File.empty?( "#{subdir}/.ricdisk.yaml")
98
+ deb("Interesting2. Empty file! TODO write YAML with it.")
99
+ disk_info = RicDiskUgly.new(subdir, '.ricdisk.yaml')
100
+ # todo write
101
+ #puts(x)
102
+ puts(yellow disk_info.to_yaml)
103
+ end
104
+ if disk_info
105
+ if File.empty?(disk_info.ricdisk_absolute_path) and (disk_info.wr)
106
+ puts(green("yay, we can now write the file '#{disk_info.ricdisk_absolute_path}' (which is R/W, I just checked!) with proper YAML content.."))
107
+ ret = File.write(disk_info.ricdisk_absolute_path, disk_info.to_yaml)
108
+ puts("Written file! ret=#{ret}")
109
+ else
110
+ puts(red("Nope, qualcosa non va.. #{File.empty?(disk_info.ricdisk_absolute_path)}"))
111
+ puts("File size: #{File.size(disk_info.ricdisk_absolute_path)}")
112
+ end
113
+ end
114
+ if File.exists?( "#{subdir}/.ricdisk") and ! File.empty?( "#{subdir}/.ricdisk")
115
+ puts("Config File found with old-style name: '#{subdir}/.ricdisk' !")
116
+ #puts(white `cat "#{subdir}/.ricdisk"`)
117
+ end
118
+ end
119
+
120
+ # separiamo cosi usiamo meglio...
121
+ def self.ok_dir?(subdir)
122
+ File.exists?( "#{subdir}/.ricdisk") or File.exists?( "#{subdir}/.ricdisk.yaml")
123
+ end
124
+
125
+ def self.obsolescence_seconds file_path
126
+ creation_time = File.stat(file_path).ctime
127
+ deb("[obsolescence_seconds] File #{file_path}: #{creation_time} - #{(Time.now - creation_time)} seconds ago")
128
+ (Time.now - creation_time).to_i
129
+ end
130
+ def self.obsolescence_days(file_path)
131
+ return obsolescence_seconds(file_path) / 86400
132
+ end
133
+
134
+ def self.backquote_execute(cmd)
135
+ # executed a command wrapped by dryrun though
136
+ return "DRYRUN backquote_execute(#{cmd})" if $opts[:dryrun]
137
+ `#{cmd}`
138
+ end
139
+
140
+ def self.upload_to_gcs(file, opts={})
141
+ deb("upload_to_gcs(#{file}). TODO(ricc) after breafast upload to GCS : #{file}")
142
+ mount_name = file.split('/')[-2]
143
+ filename = "#{mount_name}-#{File.basename file}"
144
+ hostname = Socket.gethostname[/^[^.]+/]
145
+ command = "gsutil cp '#{file}' gs://#{$gcs_bucket}/backup/ricdisk-magic/#{ hostname }-#{filename}"
146
+ deb("Command: #{command}")
147
+ ret = backquote_execute(command)
148
+ # if $opts[:debug] do
149
+ # puts "+ Current list of files:"
150
+ # ret = backquote_execute("gsutil ls -al gs://#{$gcs_bucket}/backup/ricdisk-magic/")
151
+ # puts ret
152
+ # end
153
+ ret
154
+ end
155
+
156
+ # Create RDS file.
157
+ def self.calculate_stats_files(dir, opts={})
158
+ opts_upload_to_gcs = opts.fetch :upload_to_gcs, true
159
+ full_file_path = "#{dir}/#{$stats_file}"
160
+
161
+ puts("calculate_stats_files(#{white dir}): #{white full_file_path}")
162
+ puts "TEST1 DIR EXISTS: #{dir} -> #{File.directory? dir}"
163
+ Dir.chdir(dir)
164
+ if File.exists?(full_file_path) and ($opts[:force] == false)
165
+ puts "File '#{$stats_file}' exists already." # - now should see if its too old, like more than 1 week old"
166
+ # TODO check for file time...
167
+ print "Lines found: #{yellow `wc -l "#{full_file_path}" `.chomp }. File obsolescence (days): #{yellow obsolescence_days(full_file_path)}."
168
+ if obsolescence_days(full_file_path) > 7
169
+ puts("*** ACHTUNG *** FIle is pretty old. You might consider rotating: #{yellow "mv #{full_file_path} #{full_file_path}_old"}. Or invoke with --force")
170
+ end
171
+ upload_to_gcs(full_file_path) if opts_upload_to_gcs
172
+ else
173
+ puts "Crunching data stats from '#{dir}' into '#{$stats_file}' ... please bear with me.. [maybe file didnt exist, maybe $opts[:force] is true]"
174
+ command = "find . -print0 | xargs -0 stats-with-md5.rb --no-color | tee '#{full_file_path}'"
175
+ puts("[#{`pwd`.chomp}] Executing: #{azure command}")
176
+ ret = backquote_execute command
177
+ puts "Done. #{ret.split("\n").count} files processed."
178
+ end
179
+ end
180
+
181
+ def self.find_active_dirs(base_dirs=nil, also_mountpoints=true)
182
+ base_dirs = DEFAULT_MEDIA_DIRS if base_dirs.nil?
183
+ active_dirs = []
184
+ base_dirs.each do |ugly_dir|
185
+ # https://stackoverflow.com/questions/1899072/getting-a-list-of-folders-in-a-directory#:~:text=Dir.chdir(%27/destination_directory%27)%0ADir.glob(%27*%27).select%20%7B%7Cf%7C%20File.directory%3F%20f%7D
186
+ dir = File.expand_path(ugly_dir)
187
+ begin
188
+ x=[]
189
+ # puts "TEST2 DIR EXISTS: #{dir} -> #{Dir.exists?(dir)}"
190
+ unless Dir.exists?(dir)
191
+ deb "Dir doesnt exist, skipping: #{dir}"
192
+ next
193
+ end
194
+ Dir.chdir(dir)
195
+ x = Dir.glob('*').select {|f| File.directory? f}
196
+ subdirs = x.map{|subdir| "#{dir}#{subdir}"}
197
+ subdirs.each{|subdir|
198
+ #puts `ls -al "#{subdir}"`
199
+ active_dirs << subdir if self.ok_dir?(subdir)
200
+ }
201
+ #puts(white x)
202
+ rescue Exception => e # optionally: `rescue Exception => ex`
203
+ puts "Exception: '#{e}'"
204
+ ensure # will always get executed
205
+ #deb 'Always gets executed.'
206
+ #x = []
207
+ end
208
+ end
209
+
210
+ if also_mountpoints
211
+ =begin
212
+ Example output from mount:
213
+
214
+ devfs on /dev (devfs, local, nobrowse)
215
+ /dev/disk3s6 on /System/Volumes/VM (apfs, local, noexec, journaled, noatime, nobrowse)
216
+ /dev/disk3s2 on /System/Volumes/Preboot (apfs, local, journaled, nobrowse)
217
+ /dev/disk3s4 on /System/Volumes/Update (apfs, local, journaled, nobrowse)
218
+ /dev/disk1s2 on /System/Volumes/xarts (apfs, local, noexec, journaled, noatime, nobrowse)
219
+ /dev/disk1s1 on /System/Volumes/iSCPreboot (apfs, local, journaled, nobrowse)
220
+ /dev/disk1s3 on /System/Volumes/Hardware (apfs, local, journaled, nobrowse)
221
+ /dev/disk3s5 on /System/Volumes/Data (apfs, local, journaled, nobrowse, protect)
222
+ map auto_home on /System/Volumes/Data/home (autofs, automounted, nobrowse)
223
+ //riccardo@1.0.1.10/video on /Volumes/video (afpfs, nodev, nosuid, mounted by ricc)
224
+ //riccardo@1.0.1.10/photo on /Volumes/photo (afpfs, nodev, nosuid, mounted by ricc)
225
+ =end
226
+ # add directories from current mountpoints...
227
+ mount_table_lines = interesting_mount_points()
228
+ mount_table_lines.each{|line|
229
+ next if line =~ /^map /
230
+ dev, on, path, mode = line.split(/ /)
231
+ #puts line
232
+ #deb yellow(path)
233
+ active_dirs << path if self.ok_dir?(path)
234
+ }
235
+ end
236
+ active_dirs.uniq!
237
+ puts("find_active_dirs(): found dirs " + green(active_dirs))
238
+ return active_dirs
239
+ end
240
+
241
+
242
+ def analyze_local_system()
243
+ puts :TODO
244
+ puts "1. Interesting Mounts: #{green interesting_mount_points}"
245
+ puts "2. Sbrodoling everything: :TODO"
246
+ # find_info_from_mount(path)
247
+ # find_info_from_df()
248
+ end
249
+
250
+ end
251
+ end
data/lib/storazzo.rb CHANGED
@@ -18,11 +18,23 @@ module Storazzo
18
18
  def self.version
19
19
  File.read(self.root + '/VERSION').chomp # "10.0.0"
20
20
  end
21
+
22
+ # alias_method :VERSION, :version
23
+ def self.VERSION
24
+ version
25
+ end
21
26
  end
22
27
 
28
+ # nice to paste nice output
29
+ require 'pp'
30
+
31
+ require 'storazzo/common'
23
32
  require 'storazzo/colors'
24
33
  require 'storazzo/hashify'
25
- require 'storazzo/ric_disk'
34
+ require 'storazzo/ric_disk' # NEW and will build from ground up using multiple files..
35
+ require 'storazzo/ric_disk_ugly' # OLD and 90% working
36
+ require 'storazzo/ric_disk_config'
37
+ require 'storazzo/ric_disk_statsfile'
26
38
  require 'storazzo/main'
27
39
  require 'storazzo/translator'
28
40
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: storazzo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Riccardo Carlesso
@@ -27,11 +27,15 @@ files:
27
27
  - bin/ricdisk-magic
28
28
  - lib/storazzo.rb
29
29
  - lib/storazzo/colors.rb
30
+ - lib/storazzo/common.rb
30
31
  - lib/storazzo/debug.rb
31
32
  - lib/storazzo/hashify.rb
32
33
  - lib/storazzo/main.rb
33
34
  - lib/storazzo/parser/parser.rb
34
35
  - lib/storazzo/ric_disk.rb
36
+ - lib/storazzo/ric_disk_config.rb
37
+ - lib/storazzo/ric_disk_statsfile.rb
38
+ - lib/storazzo/ric_disk_ugly.rb
35
39
  - lib/storazzo/translator.rb
36
40
  - lib/storazzo/version.rb
37
41
  - storazzo.gemspec