Added ruby manager. Partial

This commit is contained in:
Alexey Berezhok
2024-12-09 23:55:35 +03:00
parent d0da95dfc5
commit 4905975d79
9 changed files with 130 additions and 11 deletions

View File

@@ -228,3 +228,21 @@ def hestia_print_array_of_hashes(in_array = nil, format = "shell", header = nil)
hestia_format_cli_table(data_out)
end
end
def hestia_write_to_config_with_lock(config_file, values, perms = 0600)
File.open(config_file, File::WRONLY | File::CREAT, perms) do |f|
f.flock(File::LOCK_EX)
f.truncate(0)
values.each { |item| f.puts(item) }
f.flush
end
end
def hestia_read_config_with_lock(config_file)
arr = []
File.open(config_file, File::RDONLY) do |f|
f.flock(File::LOCK_SH)
f.each { |line| arr << line.strip }
end
arr
end