mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-24 21:34:01 +03:00
F #4809: Cleanup script
This commit is contained in:
parent
3224a504e4
commit
8e19b5666d
29
share/hooks/raft/follower_cleanup
Executable file
29
share/hooks/raft/follower_cleanup
Executable file
@ -0,0 +1,29 @@
|
||||
#!/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)
|
Loading…
Reference in New Issue
Block a user