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
#check_load_permission!, #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
32
33
34
35
|
# File 'lib/avm/instances/data/files_unit.rb', line 32
def do_clear
instance_command('mkdir', '-p', files_path).execute!
instance_command('find', files_path, '-mindepth', 1, '-delete').execute!
end
|
#dump_command ⇒ Object
24
25
26
|
# File 'lib/avm/instances/data/files_unit.rb', line 24
def dump_command
instance_command('tar', '-czf', '-', '-C', files_path, '.')
end
|
#files_path ⇒ Pathname
19
20
21
22
|
# File 'lib/avm/instances/data/files_unit.rb', line 19
def files_path
fs_path_subpath
.expand_path(instance.read_entry(::Avm::Instances::EntryKeys::INSTALL_PATH))
end
|
#installation_files_data ⇒ Struct(:key, :subpath)?
38
39
40
41
42
|
# File 'lib/avm/instances/data/files_unit.rb', line 38
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
45
46
47
48
|
# File 'lib/avm/instances/data/files_unit.rb', line 45
def instance_command(*args)
args = ['sudo', '-Hu', sudo_user] + args if sudo_user.present?
instance.host_env.command(*args).chdir('/')
end
|
#load_command ⇒ Object
28
29
30
|
# File 'lib/avm/instances/data/files_unit.rb', line 28
def load_command
instance_command('tar', '-xzf', '-', '-C', files_path)
end
|
#sudo_user ⇒ String?
51
52
53
|
# File 'lib/avm/instances/data/files_unit.rb', line 51
def sudo_user
options[OPTION_SUDO_USER]
end
|