mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-11 05:17:41 +03:00
30 lines
509 B
Ruby
Executable File
30 lines
509 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
|
|
VAR_LOCATION = "/var/lib/one"
|
|
CONFIG_LOCATION = VAR_LOCATION + "/config"
|
|
HOOKS_LOCATION = VAR_LOCATION + "/remotes/hooks"
|
|
|
|
REGEXP = /^RAFT_FOLLOWER_HOOK=(?:ARGUMENTS=(.*),)?COMMAND=(.*)$/
|
|
|
|
config = File.read(CONFIG_LOCATION)
|
|
|
|
groups = config.match(REGEXP) rescue nil
|
|
|
|
if groups.nil? || groups[2].nil?
|
|
exit 0
|
|
end
|
|
|
|
cmd = groups[2]
|
|
|
|
if !cmd.start_with?("/")
|
|
cmd = HOOKS_LOCATION + "/" + cmd
|
|
end
|
|
|
|
cmd = cmd.split(" ")
|
|
|
|
if groups[1]
|
|
cmd += groups[1].split(" ")
|
|
end
|
|
|
|
exec(*cmd)
|