Added passenger support. Partialy 1
This commit is contained in:
108
func_ruby/ext-modules/passenger_manager.mod
Normal file
108
func_ruby/ext-modules/passenger_manager.mod
Normal file
@@ -0,0 +1,108 @@
|
||||
#!/opt/brepo/ruby33/bin/ruby
|
||||
|
||||
require "shell"
|
||||
|
||||
class PassengerWorker < Kernel::ModuleCoreWorker
|
||||
MODULE_ID = "passenger_manager"
|
||||
|
||||
def check_domains_with_passenger
|
||||
true
|
||||
end
|
||||
|
||||
def info
|
||||
{
|
||||
ID: 2,
|
||||
NAME: MODULE_ID,
|
||||
DESCR: "Added passenger support for nginx",
|
||||
REQ: "puppet_installer",
|
||||
}
|
||||
end
|
||||
|
||||
def enable
|
||||
log_file = get_log
|
||||
f_inst_pp = get_module_paydata("passenger_installer.pp")
|
||||
f_uninst_pp = get_module_paydata("passenger_uninstaller.pp")
|
||||
if !check
|
||||
inf = info
|
||||
log("Req error, needed #{inf[:REQ]}")
|
||||
"Req error, needed #{inf[:REQ]}"
|
||||
else
|
||||
begin
|
||||
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
|
||||
if ex_status.to_i == 0 || ex_status.to_i == 2
|
||||
log(result_action)
|
||||
super
|
||||
else
|
||||
log(result_action)
|
||||
log("Try to disable action: /usr/bin/puppet apply --detailed-exitcodes #{f_uninst_pp}")
|
||||
result_action = `/usr/bin/puppet apply --detailed-exitcodes "#{f_uninst_pp}"`
|
||||
"module installation error. See log #{log_file}"
|
||||
end
|
||||
rescue => e
|
||||
log("module installation error #{e.message} #{e.backtrace.first}")
|
||||
"module installation error. See log #{log_file}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def disable
|
||||
log_file = get_log
|
||||
f_uninst_pp = get_module_paydata("passenger_uninstaller.pp")
|
||||
if !check_domains_with_passenger
|
||||
return "Presents domains with passenger support disable it first"
|
||||
end
|
||||
begin
|
||||
log("uninstall packages for passenger + nginx support")
|
||||
log("Try to disable action: /usr/bin/puppet apply --detailed-exitcodes #{f_uninst_pp}")
|
||||
result_action = `/usr/bin/puppet apply --detailed-exitcodes "#{f_uninst_pp}"`
|
||||
ex_status = $?.exitstatus
|
||||
if ex_status.to_i == 0 || ex_status.to_i == 2
|
||||
log(result_action)
|
||||
super
|
||||
else
|
||||
log(result_action)
|
||||
"module installation error. See log #{log_file}"
|
||||
end
|
||||
rescue => e
|
||||
log("module installation error #{e.message} #{e.backtrace.first}")
|
||||
"module installation error. See log #{log_file}"
|
||||
end
|
||||
end
|
||||
|
||||
def prepare_default_ruby_conf()
|
||||
#TODO
|
||||
end
|
||||
|
||||
def command(args)
|
||||
if args.length < 1
|
||||
log("Not enough arguments. Needed command")
|
||||
"Not enough arguments. Needed command"
|
||||
end
|
||||
m_command = args[0].strip
|
||||
case m_command
|
||||
when "get_rubys"
|
||||
#TODO
|
||||
else
|
||||
log("Unknown commands. #{args}")
|
||||
"Unknown commands. #{args}"
|
||||
end
|
||||
end
|
||||
|
||||
implements IPluginInterface
|
||||
end
|
||||
|
||||
module PassengerModule
|
||||
def get_object
|
||||
Proc.new { PassengerWorker.new }
|
||||
end
|
||||
|
||||
module_function :get_object
|
||||
end
|
||||
|
||||
class Kernel::PluginConfiguration
|
||||
include PassengerModule
|
||||
|
||||
@@loaded_plugins[PassengerWorker::MODULE_ID] = PassengerModule.get_object
|
||||
end
|
||||
Reference in New Issue
Block a user