Class: Avm::Instances::Data::FilesUnit
- Inherits:
-
Unit
show all
- Defined in:
- lib/avm/instances/data/files_unit.rb
Constant Summary
collapse
- EXTENSION =
'.tar.gz'
Instance Method Summary
collapse
Methods inherited from Unit
#data_default_dump_path, #identifier, #load
#dump_path_extension, #dump_to_directory, #load_from_directory
Methods inherited from Data::Unit
#clear, #dump, #load, #name
Instance Method Details
#do_clear ⇒ Object
34
35
36
37
|
# File 'lib/avm/instances/data/files_unit.rb', line 34
def do_clear
instance_command('mkdir', '-p', files_path).execute!
instance_command('find', files_path, '-mindepth', 1, '-delete').execute!
end
|
#dump_command ⇒ Object
26
27
28
|
# File 'lib/avm/instances/data/files_unit.rb', line 26
def dump_command
instance_command('tar', '-czf', '-', '-C', files_path, '.')
end
|
#files_path ⇒ Pathname
21
22
23
24
|
# File 'lib/avm/instances/data/files_unit.rb', line 21
def files_path
fs_path_subpath
.expand_path(instance.read_entry(::Avm::Instances::EntryKeys::INSTALL_PATH))
end
|
#installation_files_data ⇒ Struct(:key, :subpath)?
40
41
42
43
44
|
# File 'lib/avm/instances/data/files_unit.rb', line 40
def installation_files_data
return nil unless fs_path_subpath.relative?
::Struct.new(:key, :subpath).new(fs_path_subpath.basename.to_path, fs_path_subpath)
end
|
#instance_command(*args) ⇒ EacRubyUtils::Envs::Command
47
48
49
50
|
# File 'lib/avm/instances/data/files_unit.rb', line 47
def instance_command(*args)
args = ['sudo', '-Hu', sudo_user] + args if sudo_user.present?
instance.host_env.command(*args).chdir('/')
end
|
#load_command ⇒ Object
30
31
32
|
# File 'lib/avm/instances/data/files_unit.rb', line 30
def load_command
instance_command('tar', '-xzf', '-', '-C', files_path)
end
|
#sudo_user ⇒ String?
53
54
55
|
# File 'lib/avm/instances/data/files_unit.rb', line 53
def sudo_user
options[OPTION_SUDO_USER]
end
|