Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Ian Eiloart
Sympl
Commits
84d44920
Commit
84d44920
authored
Aug 29, 2017
by
telyn
Browse files
symbiosis-ssl now returns an error code if any of the hooks do not succeed
parent
c652b5ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
common/bin/symbiosis-ssl
View file @
84d44920
...
...
@@ -237,6 +237,7 @@ domains.sort_by(&:name).each do |domain|
end
end
Symbiosis
::
SSL
.
call_hooks
domains_altered
,
'live-update'
success
=
Symbiosis
::
SSL
.
call_hooks
domains_altered
,
'live-update'
exit_code
=
2
unless
success
exit
exit_code
common/lib/symbiosis/ssl.rb
View file @
84d44920
require
'symbiosis'
require
'open3'
module
Symbiosis
# SSL knows about which SSL providers exist and provides SSL helper functions
...
...
@@ -6,18 +7,29 @@ module Symbiosis
PROVIDERS
||=
[]
def
self
.
call_hooks
(
domains_with_updates
,
event
)
return
if
domains_with_updates
.
empty?
hooks_path
=
Symbiosis
.
path_in_etc
(
'/symbiosis/ssl-hooks.d/*'
)
success
=
true
Dir
.
glob
(
hooks_path
).
each
do
|
script
|
next
unless
File
.
executable?
(
script
)
next
if
File
.
basename
(
script
)
=~
/\..*$/
IO
.
popen
([
script
,
event
],
'r+'
)
do
|
io
|
io
.
puts
domains_with_updates
.
join
(
"
\n
"
)
io
.
close_write
# Close the pipe now we've written stuff.
end
next
if
File
.
basename
(
script
)
=~
/^[a-zA-Z0-9_-]+$/
success
&&=
run_hook_script
(
event
,
script
,
domains_with_updates
)
end
success
end
def
self
.
run_hook_script
(
event
,
script
,
domains_with_updates
)
opts
=
{
stdin_data:
domains_with_updates
.
join
(
"
\n
"
)
}
output
,
status
=
Open3
.
capture2e
([
script
,
event
],
opts
)
return
true
if
status
.
success?
puts
"============================================
\n
"
puts
"Error executing SSL script for
#{
event
}
hook
\n
"
puts
"
#{
script
}
exited with status
#{
status
.
exitstatus
}
\n
"
puts
output
+
"
\n\n
"
false
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment