irgat 0.0.1
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/History.txt +4 -0
- data/Manifest.txt +45 -0
- data/PostInstall.txt +4 -0
- data/README.rdoc +29 -0
- data/Rakefile +4 -0
- data/TODO +26 -0
- data/bin/irgat +87 -0
- data/bin/irgat_setup +135 -0
- data/config/hoe.rb +80 -0
- data/config/requirements.rb +15 -0
- data/lib/irgat.rb +94 -0
- data/lib/irgat/console.rb +85 -0
- data/lib/irgat/dependencies.rb +75 -0
- data/lib/irgat/execs.rb +73 -0
- data/lib/irgat/log.rb +116 -0
- data/lib/irgat/mail.rb +88 -0
- data/lib/irgat/utils.rb +17 -0
- data/lib/irgat/version.rb +10 -0
- data/lib/modules/backup.rb +348 -0
- data/lib/modules/console.rb +48 -0
- data/lib/modules/kwallet.rb +133 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +1585 -0
- data/setup/etc/backup.yml.example +103 -0
- data/setup/etc/chroot.yml.example +42 -0
- data/setup/etc/console.yml.default +11 -0
- data/setup/etc/cron.yml.example +56 -0
- data/setup/etc/dar.yml.example +16 -0
- data/setup/etc/irgat.yml.example +37 -0
- data/setup/etc/kwallet.yml.default +18 -0
- data/setup/etc/kwallet.yml.example +18 -0
- data/setup/etc/ssh.yml.example +17 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_helper.rb +2 -0
- data/test/test_irgat.rb +11 -0
- data/website/index.html +83 -0
- data/website/index.txt +83 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- metadata +157 -0
@@ -0,0 +1,348 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
Irgat::Backup
|
4
|
+
--------------
|
5
|
+
|
6
|
+
Author: Gnoxys. info@gnoxys.net
|
7
|
+
License: GPL v3.
|
8
|
+
|
9
|
+
Read more info in <irgat_path>/README
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
|
14
|
+
module Irgat
|
15
|
+
|
16
|
+
# create the class, that extends the Module Irgat::Irgat class
|
17
|
+
class Backup < Irgat
|
18
|
+
|
19
|
+
# initialize the Class... make default operations
|
20
|
+
def initialize
|
21
|
+
# Create and irgat process
|
22
|
+
irgat_process = Irgat.new()
|
23
|
+
# Get the instance variables
|
24
|
+
@config = irgat_process.config
|
25
|
+
# load options for subsystem
|
26
|
+
@config_module = self.load_config
|
27
|
+
@init_time = Time.now
|
28
|
+
# build the programs needed
|
29
|
+
need_programs=["dar", "dar_manager", "gzip","tar"]
|
30
|
+
# in function of options
|
31
|
+
need_programs << "mysql" << "mysqldump" if @config_module[:dump_mysql]
|
32
|
+
need_programs << "ssh" << "scp" if @config_module[:distribute_method]
|
33
|
+
# check all the needed things
|
34
|
+
check_dependencies(:check_programs => need_programs,
|
35
|
+
:check_mounted_folder => (@config_module[:mounted_folder] ? @config_module[:working_path] : false),
|
36
|
+
:check_folders => [ @config_module[:working_path],
|
37
|
+
@config_module[:folders_tree] ],
|
38
|
+
:check_egid => @config_module[:run_as_user]
|
39
|
+
)
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
def default(args = {})
|
44
|
+
# no default action in backup module, show help
|
45
|
+
puts 'FIXME * action needed'
|
46
|
+
end
|
47
|
+
|
48
|
+
def list(args = [])
|
49
|
+
puts list_catalog
|
50
|
+
end
|
51
|
+
|
52
|
+
def launch(args = [])
|
53
|
+
# @backup.set_log_output_to_file
|
54
|
+
log("point", "Init Irgat Backup Launch")
|
55
|
+
|
56
|
+
# mysql dumps? FIXME to bbdd_dumps?
|
57
|
+
if @config_module[:dump_mysql]
|
58
|
+
log("point","Doing MySQL database Dumping")
|
59
|
+
do_mysql_dumps
|
60
|
+
end
|
61
|
+
|
62
|
+
# use the specific backup program
|
63
|
+
self.send("do_backup_with_" + @config_module[:backup_program])
|
64
|
+
|
65
|
+
# finish process
|
66
|
+
finish_process({ :msj => "[IRGAT] [BACKUP] [OK] Backup Launch in #{ @config[:server_name] } server" })
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
# Perform a mysqldump of all the databases
|
72
|
+
def do_mysql_dumps
|
73
|
+
# Take the DBs
|
74
|
+
dbs = execute_command(
|
75
|
+
"#{ @programs[:mysql] } -u '#{ @config_module[:mysql_user] }' -p'#{ @config_module[:mysql_pass] }' -Bse 'show databases'",
|
76
|
+
"Get databases info")
|
77
|
+
# chdir to mysql
|
78
|
+
Dir.chdir(@folders[:extras_mysql])
|
79
|
+
|
80
|
+
# delete old files, if exists || sure that we only delete .sql.gz files
|
81
|
+
if Dir.entries(@folders[:extras_mysql]).length > 1
|
82
|
+
execute_command("rm -f *.sql.gz ", "Delete old's dumps' files")
|
83
|
+
end
|
84
|
+
|
85
|
+
# Each db, make dump and compress with gzip
|
86
|
+
dbs.each { |db|
|
87
|
+
dump_file = "mysqldump_#{ Date.today }_#{db.chop}.sql"
|
88
|
+
execute_command(
|
89
|
+
"#{ @programs[:mysqldump] } -u #{ @config_module[:mysql_user] } -p#{ @config_module[:mysql_pass] } #{db.chop} -r #{dump_file}",
|
90
|
+
"Dumping database #{db.chop}")
|
91
|
+
execute_command(
|
92
|
+
"#{ @programs[:gzip] } -9 #{dump_file}",
|
93
|
+
"Compressing sql file: #{dump_file}")
|
94
|
+
}
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
# do dar backup with dar tool
|
99
|
+
def do_backup_with_dar
|
100
|
+
# move to current_folder
|
101
|
+
Dir.chdir(@folders[:data_local_current])
|
102
|
+
|
103
|
+
# define file names
|
104
|
+
@complete_backup_file = "#{ Date.today }_#{ @config[:server_name] }_complete"
|
105
|
+
@diff_backup_file = "#{ Date.today }_#{ @config[:server_name] }_diff"
|
106
|
+
@last_complete_backup_file = Dir["*complete.*"][0]
|
107
|
+
|
108
|
+
# complet or diff
|
109
|
+
backup_type = ((@config_module[:complet_backup_days].include?(Time.now.wday) || !@last_complete_backup_file) ? "complet" : "diff")
|
110
|
+
|
111
|
+
# need to move files if backup is complete and there is some backup already
|
112
|
+
if backup_type == 'complet' && @last_complete_backup_file
|
113
|
+
move_and_purge_old_backups
|
114
|
+
end
|
115
|
+
|
116
|
+
# build command
|
117
|
+
dar_command = build_dar_command("do_backup", { "backup_type" => backup_type })
|
118
|
+
|
119
|
+
# exec backup
|
120
|
+
log("point", "Doing backup")
|
121
|
+
execute_command(dar_command, "Doing #{ backup_type.capitalize } Backup")
|
122
|
+
|
123
|
+
# test backup
|
124
|
+
log("point", "Testing backup")
|
125
|
+
do_test_backup
|
126
|
+
|
127
|
+
# add the backup in the catalog
|
128
|
+
log("point","Isolation and backup to catalog")
|
129
|
+
# 1) make the isolation file and add the backup in catalog
|
130
|
+
do_isolation_file
|
131
|
+
insert_backup_in_catalog
|
132
|
+
end
|
133
|
+
|
134
|
+
# method to move the old backups and purge the older in function of how many backups we are storing
|
135
|
+
def move_and_purge_old_backups
|
136
|
+
# move to current Dir
|
137
|
+
Dir.chdir(@folders[:data_local_current])
|
138
|
+
# move old backup
|
139
|
+
complet_date_backup = Dir["*complete.*"][0].slice(0,10)
|
140
|
+
folder_date_name = @folders[:data_local_old] + '/' + complet_date_backup
|
141
|
+
exist_or_create_folder(folder_date_name)
|
142
|
+
# move the current files to the new location "only .dar files"
|
143
|
+
execute_command(
|
144
|
+
"mv *.dar #{ folder_date_name }",
|
145
|
+
"Moving Olds Backup Files",
|
146
|
+
{:fatal_error => true})
|
147
|
+
# change the path for this backups
|
148
|
+
Dir.chdir(folder_date_name)
|
149
|
+
# all but isolates files
|
150
|
+
(Dir["*"] - Dir["*isolate*"]).each { |backup_file|
|
151
|
+
change_path_in_catalog(folder_date_name, backup_file.slice(0,10))
|
152
|
+
}
|
153
|
+
|
154
|
+
# return to delete
|
155
|
+
Dir.chdir(@folders[:data_local_old])
|
156
|
+
# if we have more, that the options how many stored backups number...
|
157
|
+
if (old_backups = Dir["*"].sort).length > @config_module[:number_backup_stored]
|
158
|
+
while old_backups.length > @config_module[:number_backup_stored]
|
159
|
+
to_delete_folder = old_backups.shift
|
160
|
+
Dir.chdir(to_delete_folder) # FIXME
|
161
|
+
# all but isolates files
|
162
|
+
(Dir["*"] - Dir["*isolate*"]).each { |backup_file|
|
163
|
+
# remove from catalog
|
164
|
+
remove_from_catalog(backup_file.slice(0,10))
|
165
|
+
}
|
166
|
+
Dir.chdir(@folders[:data_local_old]) # FIXME
|
167
|
+
execute_command(
|
168
|
+
"rm -rf #{ @folders[:data_local_old] + '/' + to_delete_folder}",
|
169
|
+
"Deleting old backup folder #{ to_delete_folder.strip }",
|
170
|
+
{ :fatal_error => true })
|
171
|
+
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def change_path_in_catalog(new_path, backup_pattern, options = {})
|
177
|
+
catalog = options[:catalog] || @folders[:catalog] + '/catalog_' + @config[:server_name]
|
178
|
+
# search the backups to delete
|
179
|
+
ids_backups = identifies_backups_in_catalog(backup_pattern)
|
180
|
+
ids_backups.each { |id|
|
181
|
+
command_change_path = @programs[:dar_manager] + ' -B ' + catalog + ' -p ' + id + ' ' + new_path
|
182
|
+
execute_command(
|
183
|
+
command_change_path,
|
184
|
+
"Change path to backup #{ id } in catalog")
|
185
|
+
}
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
# build the command to check backup and exec it
|
190
|
+
def do_test_backup
|
191
|
+
test_command = @programs[:dar] + ' -t ' + @backup_file + ' -K ' + @config_module[:dar]["encrypt_passwd"]
|
192
|
+
#exec it
|
193
|
+
self.execute_command(
|
194
|
+
test_command,
|
195
|
+
"Testing integrity off backup")
|
196
|
+
end
|
197
|
+
|
198
|
+
# build the isolation file
|
199
|
+
def do_isolation_file
|
200
|
+
isolation_command = self.programs[:dar] + ' -J ' + @config_module[:dar]["decrypt_passwd"] + ' -C ' + @backup_file + '_isolate -A ' +@backup_file
|
201
|
+
#exec it
|
202
|
+
execute_command(
|
203
|
+
isolation_command,
|
204
|
+
"Making isolation file",
|
205
|
+
{ :fatal_error => true })
|
206
|
+
end
|
207
|
+
|
208
|
+
# insert the backup in catalog
|
209
|
+
def insert_backup_in_catalog(options = {})
|
210
|
+
# options
|
211
|
+
catalog = options[:catalog] || @folders[:catalog] + '/catalog_' + @config[:server_name]
|
212
|
+
backup_file = options[:backup_file] || @folders[:data_local_current] + '/' + @backup_file + '_isolate '
|
213
|
+
backup_file_name = options[:backup_file_name] || @folders[:data_local_current] + '/' + @backup_file
|
214
|
+
|
215
|
+
if ! test(?e,catalog)
|
216
|
+
create_catalog(catalog)
|
217
|
+
end
|
218
|
+
|
219
|
+
# now, build the command to insert in catalog
|
220
|
+
command_insert_in_catalog = @programs[:dar_manager] + ' -B ' + catalog + ' -A' + backup_file + backup_file_name
|
221
|
+
# exec it
|
222
|
+
execute_command(
|
223
|
+
command_insert_in_catalog,
|
224
|
+
"Inserting backup in catalog",
|
225
|
+
{ :fatal_error => true })
|
226
|
+
end
|
227
|
+
|
228
|
+
|
229
|
+
def remove_from_catalog(backup_pattern, options = {})
|
230
|
+
catalog = options[:catalog] || @folders[:catalog] + '/catalog_' + @config[:server_name]
|
231
|
+
# search the backups to delete
|
232
|
+
ids_backups = identifies_backups_in_catalog(backup_pattern)
|
233
|
+
ids_backups.each { |id|
|
234
|
+
command_remove_backup= @programs[:dar_manager] + ' -B ' + catalog + ' -D ' + id
|
235
|
+
execute_command(
|
236
|
+
command_remove_backup,
|
237
|
+
"Removing Backup #{ id } from catalog")
|
238
|
+
}
|
239
|
+
end
|
240
|
+
|
241
|
+
|
242
|
+
def list_catalog(options = {})
|
243
|
+
catalog = options[:catalog] || @folders[:catalog] + '/catalog_' + @config[:server_name]
|
244
|
+
command_list_catalog = @programs[:dar_manager] + ' -B ' + catalog + ' -l'
|
245
|
+
execute_command(
|
246
|
+
command_list_catalog,
|
247
|
+
"Listing backup in catalog")
|
248
|
+
end
|
249
|
+
|
250
|
+
def identifies_backups_in_catalog(pattern)
|
251
|
+
ids_backups = []
|
252
|
+
backups_in_catalog = list_catalog
|
253
|
+
backups_in_catalog.each_line { |backup_data|
|
254
|
+
if backup_data.include?(pattern)
|
255
|
+
ids_backups << backup_data.split(' ')[0]
|
256
|
+
end
|
257
|
+
}
|
258
|
+
return ids_backups
|
259
|
+
end
|
260
|
+
|
261
|
+
# end backups process... report state and send emails if is configured for
|
262
|
+
def do_finish_backup(fatal = nil)
|
263
|
+
# take a report for the backup process
|
264
|
+
report = self.process_report
|
265
|
+
|
266
|
+
# if email reporting is avaible, we have to send an email
|
267
|
+
if @config_module[:report_email]
|
268
|
+
#build subjetc
|
269
|
+
if fatal
|
270
|
+
subject_email="[IRGAT Backup] Fatal error in #{self.config[:server_name]}"
|
271
|
+
else
|
272
|
+
subject_email="[IRGAT Backup] Succesfull in #{self.config[:server_name]}"
|
273
|
+
end
|
274
|
+
|
275
|
+
# FIXME, wrap to litura... not good hear
|
276
|
+
if self.config[:server_name]=='litura'
|
277
|
+
self.send_email(:body=>report,:subject => subject_email, :in_chroot => true )
|
278
|
+
else
|
279
|
+
self.send_email(:body=>report,:subject => subject_email)
|
280
|
+
end
|
281
|
+
|
282
|
+
end
|
283
|
+
# write the report also to the file
|
284
|
+
self.log("text",report,1)
|
285
|
+
end
|
286
|
+
|
287
|
+
def create_catalog(catalog_file_name)
|
288
|
+
create_catalog_command = @programs[:dar_manager] + ' -C ' + catalog_file_name
|
289
|
+
execute_command(
|
290
|
+
create_catalog_command,
|
291
|
+
"Creating catalog",
|
292
|
+
{ :fatal_error => true })
|
293
|
+
end
|
294
|
+
|
295
|
+
# FIXME
|
296
|
+
def build_dar_command(for_what, options = {})
|
297
|
+
# merge options with default
|
298
|
+
options = options.merge(@config_module[:dar])
|
299
|
+
# BUILD basic dar command
|
300
|
+
dar_command = Hash.new
|
301
|
+
# required
|
302
|
+
dar_command[:file_size] = "-s #{ options["file_size"] }"
|
303
|
+
dar_command[:root_backup] = "-R #{ options["root_backup"] }"
|
304
|
+
dar_command[:encrypt_passwd] = "-J #{ options["encrypt_passwd"] }"
|
305
|
+
dar_command[:decrypt_passwd] = "-K #{ options["decrypt_passwd"] }"
|
306
|
+
# conditionals
|
307
|
+
if options["compression"]
|
308
|
+
dar_command[:compression] = '-m ' + options["compression"].to_s + ' -y'
|
309
|
+
end
|
310
|
+
if options["enable_empty_folders"]
|
311
|
+
dar_command[:enable_empty_folders] = '-D '
|
312
|
+
end
|
313
|
+
|
314
|
+
# multiples
|
315
|
+
dar_command[:exclude_to_compress] = ''
|
316
|
+
for extension in @config_module[:exclude_to_compress]
|
317
|
+
dar_command[:exclude_to_compress] << "-Z '*" + extension + "' "
|
318
|
+
end
|
319
|
+
dar_command[:exclude_folders] = ''
|
320
|
+
for folder in @config_module[:exclude_folders]
|
321
|
+
dar_command[:exclude_folders] << "-P #{folder} "
|
322
|
+
end
|
323
|
+
dar_command[:exclude_files] = ''
|
324
|
+
for extension in @config_module[:exclude_files]
|
325
|
+
dar_command[:exclude_files] << "-X '*#{extension}' "
|
326
|
+
end
|
327
|
+
|
328
|
+
dar_cmd = @programs[:dar] + " "
|
329
|
+
|
330
|
+
dar_command.each_value {|v|
|
331
|
+
dar_cmd << v + ' '
|
332
|
+
}
|
333
|
+
|
334
|
+
# diff or complete
|
335
|
+
if options["backup_type"] == 'complet'
|
336
|
+
dar_cmd << "-c #{ @complete_backup_file }"
|
337
|
+
@backup_file = @complete_backup_file
|
338
|
+
elsif options["backup_type"] == 'diff'
|
339
|
+
dar_cmd << "-c #{ @diff_backup_file } -A #{ @last_complete_backup_file.split('.')[0] }"
|
340
|
+
@backup_file = @diff_backup_file
|
341
|
+
end
|
342
|
+
|
343
|
+
dar_cmd
|
344
|
+
end
|
345
|
+
|
346
|
+
|
347
|
+
end
|
348
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
IRGAT::Console
|
4
|
+
--------------
|
5
|
+
|
6
|
+
Author: Gnoxys. info@gnoxys.net
|
7
|
+
License: GPL v3.
|
8
|
+
|
9
|
+
Read more info in <irgat_path>/README
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
|
14
|
+
module Irgat
|
15
|
+
|
16
|
+
# create the class, that extends the Module Irgat::Irgat class
|
17
|
+
class Console < Irgat
|
18
|
+
|
19
|
+
#accesor to configs
|
20
|
+
attr_reader :config
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
# Create and irgat process
|
24
|
+
irgat_process = Irgat.new()
|
25
|
+
# Get config
|
26
|
+
@config = irgat_process.config
|
27
|
+
# load options for module
|
28
|
+
@config_module = self.load_config
|
29
|
+
# include modules?
|
30
|
+
#case @config_module[:load_modules]
|
31
|
+
# when 'all'
|
32
|
+
# log("text", "Loading all activated modules")
|
33
|
+
# # get modules
|
34
|
+
# # @config
|
35
|
+
# # TODO
|
36
|
+
# when
|
37
|
+
@log_to_stdout = true
|
38
|
+
end
|
39
|
+
|
40
|
+
def default(args = {})
|
41
|
+
require 'irb'
|
42
|
+
puts "\nLaunching irgat command line"
|
43
|
+
puts "---------------------------"
|
44
|
+
exec("irb -r #{IRGAT_ROOT}/lib/boot.rb -r #{IRGAT_ROOT}/lib/irgat.rb -r #{IRGAT_ROOT}/lib/irgat/console.rb -r irb/completion")
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
#=Index
|
2
|
+
#
|
3
|
+
# IRGAT::Kwallet Class
|
4
|
+
# ----------------------
|
5
|
+
# get more info typing @your_object.help '<reference word>'
|
6
|
+
#
|
7
|
+
# * Methods:
|
8
|
+
# - get_passwd_entry # Get a password entry from you wallet
|
9
|
+
# - show_passwd_list # List the avalible passwords in your wallet
|
10
|
+
# - get_kwallet_int_code # Get the code of your wallet
|
11
|
+
# - show_folders # Show the folders in your wallet
|
12
|
+
#
|
13
|
+
#
|
14
|
+
#= Get_passwd_entry
|
15
|
+
#
|
16
|
+
# method: public: get_passwd_entry(folder,key)
|
17
|
+
#
|
18
|
+
# Description: Get a password entry stored in your kwallet defined in your irgat_kwallet.yml file.
|
19
|
+
#
|
20
|
+
# Need:
|
21
|
+
# -folder: string name of the folder tha have the key
|
22
|
+
# -key: string name of the wanted coded
|
23
|
+
#
|
24
|
+
# Return: this method return an string with the password entry
|
25
|
+
#
|
26
|
+
|
27
|
+
|
28
|
+
# create the class, that extends the Module IRGAT::Base class
|
29
|
+
|
30
|
+
module Irgat
|
31
|
+
|
32
|
+
class Kwallet < Irgat
|
33
|
+
|
34
|
+
# initialize the Class... make default operations
|
35
|
+
def initialize
|
36
|
+
# Create and irgat process
|
37
|
+
irgat_process = Irgat.new()
|
38
|
+
# Get the instance variables
|
39
|
+
@config = irgat_process.config
|
40
|
+
# load options for subsystem
|
41
|
+
@config_module = self.load_config
|
42
|
+
@init_time = Time.now
|
43
|
+
# build the programs needed
|
44
|
+
need_programs = ["dcop", "gpg"]
|
45
|
+
|
46
|
+
# get kwallet code at start
|
47
|
+
@code ||= get_kwallet_int_code.strip
|
48
|
+
# define module to log in console
|
49
|
+
@log_to_stdout = true
|
50
|
+
end
|
51
|
+
|
52
|
+
def default(args)
|
53
|
+
do_petition(args)
|
54
|
+
end
|
55
|
+
|
56
|
+
def do_petition(args)
|
57
|
+
petition = args.shift
|
58
|
+
if !petition or petition == ""
|
59
|
+
log("text","No petition registered. Options are: ", 1)
|
60
|
+
else
|
61
|
+
if !args.empty?
|
62
|
+
self.send(petition, (args))
|
63
|
+
else
|
64
|
+
self.send(petition)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def show( arg = [])
|
70
|
+
puts arg.inspect
|
71
|
+
args = arg.split(' ')
|
72
|
+
folder = args.shift
|
73
|
+
entry = args.shift
|
74
|
+
puts folder
|
75
|
+
puts entry
|
76
|
+
if !folder || !entry
|
77
|
+
return "Select a folder or entry"
|
78
|
+
else
|
79
|
+
return "Value: #{ get_passwd_entry(folder,entry) }"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def list( args = [])
|
84
|
+
option = args.first
|
85
|
+
if !option
|
86
|
+
return " List stored objects. Specify a folder from list: #{ show_folders.gsub(/\n/,' ') }"
|
87
|
+
else
|
88
|
+
if option == "all"
|
89
|
+
else
|
90
|
+
show_passwd_list(option.strip)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
#get the kwallet code from the default wallet
|
97
|
+
def get_kwallet_int_code
|
98
|
+
code = execute_command("dcop kded kwalletd open '#{ @config_module[:kwallet_name] }' ''","Get #{ @config_module[:kwallet_name] } wallet code id' files")
|
99
|
+
code
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
def insert_passwd_entry(folder, key, value)
|
104
|
+
petition = execute_command("dcop kded kwalletd writePassword #{ @code } '#{ folder }' '#{ key }' '#{ value }'","Writing new password key #{ key } in #{ folder }")
|
105
|
+
end
|
106
|
+
|
107
|
+
def get_passwd_entry(folder, key)
|
108
|
+
petition = execute_command("dcop kded kwalletd readPasswordList #{ @code } '#{ folder }' '#{ key }'","Get password key #{ key } in #{ folder }",1)
|
109
|
+
pass=petition.split('->')[1]
|
110
|
+
pass
|
111
|
+
end
|
112
|
+
|
113
|
+
def show_passwd_list(folder)
|
114
|
+
petition = execute_command("dcop kded kwalletd entryList #{ @code } '#{ folder }'", "Get Password of #{ folder }")
|
115
|
+
return "Avaible Entries in #{ folder }: #{ petition.gsub(/\n/,' ') } . Type $ @kwallet.show #{ folder } <entry> to see the key value"
|
116
|
+
end
|
117
|
+
|
118
|
+
def show_folders
|
119
|
+
petition = execute_command("dcop kded kwalletd folderList #{ @code }","Get the folders in #{ @config_module[:kwallet_name] } wallet")
|
120
|
+
petition
|
121
|
+
end
|
122
|
+
|
123
|
+
def commit_kwallet_file
|
124
|
+
execute_command("scp -P #{@config_module[:remote_path]["port"]} #{@config_module[:local_path]}/#{@config_module[:kwallet_name]}.kwl #{@config_module[:remote_path]["user"]}@#{@config_module[:remote_path]["server"]}:/#{@config_module[:remote_path]["folder"]}","Sending local kwallet file",1)
|
125
|
+
end
|
126
|
+
|
127
|
+
def update_kwallet_file
|
128
|
+
execute_command("scp -P #{@config_module[:remote_path]["port"]} #{@config_module[:remote_path]["user"]}@#{@config_module[:remote_path]["server"]}:/#{@config_module[:remote_path]["folder"]}/#{@config_module[:kwallet_name]}.kwl #{@config_module[:local_path]}","Updating local kwallet file from server",1)
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|