Added ruby manager. Partial
This commit is contained in:
@@ -88,7 +88,7 @@ when :list, :state
|
||||
else
|
||||
format = (v_ext_option.nil? ? "shell" : v_ext_option.strip)
|
||||
end
|
||||
hestia_print_array_of_hashes(result_arr, format, "ID, NAME, DESCR, STATE, REQ")
|
||||
hestia_print_array_of_hashes(result_arr, format, "ID, NAME, DESCR, STATE, REQ, CONF")
|
||||
when :enable
|
||||
if v_ext_option.nil?
|
||||
hestia_print_error_message_to_cli "no module name specified"
|
||||
|
||||
0
bin/v-ext-modules-run
Normal file → Executable file
0
bin/v-ext-modules-run
Normal file → Executable file
@@ -9,6 +9,7 @@ class EmptyWorker < Kernel::ModuleCoreWorker
|
||||
NAME: MODULE_ID,
|
||||
DESCR: "Just empty module for storing max module id",
|
||||
REQ: "",
|
||||
CONF: "",
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ class PassengerWorker < Kernel::ModuleCoreWorker
|
||||
NAME: MODULE_ID,
|
||||
DESCR: "Added passenger support for nginx",
|
||||
REQ: "puppet_installer",
|
||||
CONF: "yes",
|
||||
}
|
||||
end
|
||||
|
||||
@@ -28,6 +29,7 @@ class PassengerWorker < Kernel::ModuleCoreWorker
|
||||
"Req error, needed #{inf[:REQ]}"
|
||||
else
|
||||
begin
|
||||
prepare_default_ruby_conf
|
||||
log("install packages for passenger + nginx support: /usr/bin/puppet apply --detailed-exitcodes #{f_inst_pp}")
|
||||
result_action = `/usr/bin/puppet apply --detailed-exitcodes "#{f_inst_pp}"`
|
||||
ex_status = $?.exitstatus
|
||||
@@ -71,22 +73,73 @@ class PassengerWorker < Kernel::ModuleCoreWorker
|
||||
end
|
||||
end
|
||||
|
||||
def prepare_default_ruby_conf()
|
||||
#TODO
|
||||
def prepare_default_ruby_conf
|
||||
ruby_conf_rubys = get_module_conf("rubys.conf")
|
||||
return if File.exist?(ruby_conf_rubys)
|
||||
|
||||
arr = ["/usr/bin/ruby", "/opt/brepo/ruby33/bin/ruby"]
|
||||
hestia_write_to_config_with_lock(ruby_conf_rubys, arr)
|
||||
end
|
||||
|
||||
def return_rubys_from_conf
|
||||
arr = []
|
||||
ruby_conf_rubys = get_module_conf("rubys.conf")
|
||||
return arr unless File.exist?(ruby_conf_rubys)
|
||||
|
||||
hestia_read_config_with_lock(ruby_conf_rubys)
|
||||
end
|
||||
|
||||
def command(args)
|
||||
if args.length < 1
|
||||
log("Not enough arguments. Needed command")
|
||||
"Not enough arguments. Needed command"
|
||||
end
|
||||
return log_return("Not enough arguments. Needed command") if args.length < 1
|
||||
|
||||
m_command = args[0].strip
|
||||
case m_command
|
||||
when "get_rubys"
|
||||
#TODO
|
||||
result = return_rubys_from_conf.map { |item| { "RUBY" => item } }
|
||||
format = (args[1].nil? ? "shell" : args[1].strip)
|
||||
hestia_print_array_of_hashes(result, format, "RUBY")
|
||||
ACTION_OK
|
||||
when "add_ruby"
|
||||
path = args[1]
|
||||
if path.nil?
|
||||
log_return("Path to ruby should be specified. #{args}")
|
||||
else
|
||||
log("Unknown commands. #{args}")
|
||||
"Unknown commands. #{args}"
|
||||
path = path.strip
|
||||
if File.exist?(path)
|
||||
rubys = return_rubys_from_conf
|
||||
unless rubys.include? path
|
||||
rubys << path
|
||||
ruby_conf_rubys = get_module_conf("rubys.conf")
|
||||
hestia_write_to_config_with_lock(ruby_conf_rubys, rubys)
|
||||
end
|
||||
ACTION_OK
|
||||
else
|
||||
log_return("File #{path} doesn't exists")
|
||||
end
|
||||
end
|
||||
when "del_ruby"
|
||||
path = args[1]
|
||||
if path.nil?
|
||||
log_return("Path to ruby should be specified. #{args}")
|
||||
else
|
||||
path = path.strip
|
||||
rubys = return_rubys_from_conf
|
||||
if rubys.include? path
|
||||
rubys.delete(path)
|
||||
ruby_conf_rubys = get_module_conf("rubys.conf")
|
||||
hestia_write_to_config_with_lock(ruby_conf_rubys, rubys)
|
||||
end
|
||||
ACTION_OK
|
||||
end
|
||||
when "set_user_ruby"
|
||||
domain = args[1]
|
||||
if domain.nil?
|
||||
log_return("Domain should be specified. #{args}")
|
||||
else
|
||||
#TODO
|
||||
end
|
||||
else
|
||||
log_return("Unknown commands. #{args}")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ class PuppetWorker < Kernel::ModuleCoreWorker
|
||||
NAME: MODULE_ID,
|
||||
DESCR: "Added puppet support, needed for another modules",
|
||||
REQ: "",
|
||||
CONF: "",
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -101,6 +101,11 @@ class Kernel::ModuleCoreWorker
|
||||
File.append! log_file, "#{log_time} #{out_result}"
|
||||
end
|
||||
|
||||
def log_return(format, *args)
|
||||
log(format, *args)
|
||||
format % args
|
||||
end
|
||||
|
||||
def check
|
||||
result = self.info
|
||||
if result[:REQ] == "" || result[:REQ].nil?
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
$TAB = "EXTMODULES";
|
||||
|
||||
// Main include
|
||||
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
|
||||
|
||||
// Check user
|
||||
if ($_SESSION["userContext"] != "admin") {
|
||||
header("Location: /list/user");
|
||||
exit();
|
||||
}
|
||||
|
||||
// Data
|
||||
exec(HESTIA_CMD . "v-ext-modules list json", $output, $return_var);
|
||||
$data = json_decode(implode("", $output), true);
|
||||
ksort($data);
|
||||
|
||||
unset($output);
|
||||
|
||||
// Render page
|
||||
render_page($user, $TAB, "extmodules");
|
||||
|
||||
// Back uri
|
||||
$_SESSION["back"] = $_SERVER["REQUEST_URI"];
|
||||
@@ -22,6 +22,7 @@
|
||||
<div class="units-table-cell u-text-center"><?= _("Module description") ?></div>
|
||||
<div class="units-table-cell u-text-center"><?= _("Module state") ?></div>
|
||||
<div class="units-table-cell u-text-center"><?= _("Requirements") ?></div>
|
||||
<div class="units-table-cell u-text-center"><?= _("Configuration") ?></div>
|
||||
</div>
|
||||
|
||||
<!-- Begin extmodules list item loop -->
|
||||
@@ -81,10 +82,26 @@
|
||||
<span class="u-hide-desktop u-text-bold"><?= _("Module state") ?>:</span>
|
||||
<?= $data[$key]["STATE"] ?>
|
||||
</div>
|
||||
<div class="units-table-cell u-text-bold u-text-center-desktop">
|
||||
<div class="units-table-cell u-text-center-desktop">
|
||||
<span class="u-hide-desktop"><?= _("Requirements") ?>:</span>
|
||||
<?= $data[$key]["REQ"] ?>
|
||||
</div>
|
||||
<div class="units-table-cell u-text-center-desktop">
|
||||
<span class="u-hide-desktop"><?= _("Configuration") ?>:</span>
|
||||
<?php
|
||||
if (($data[$key]["CONF"]=="yes") && ($status == "enabled")) {
|
||||
?>
|
||||
<a href="/extm/<?= urlencode($data[$key]['NAME']) ?>/edit/" title="<?= $data[$key]['NAME'] ?>">
|
||||
<?= _("Edit") ?>
|
||||
</a>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user