25 lines
No EOL
663 B
Text
25 lines
No EOL
663 B
Text
#!/usr/bin/env bash
|
|
# https://serverfault.com/questions/538978/how-to-run-a-command-once-a-zfs-scrub-completes
|
|
set -euo pipefail
|
|
|
|
<% unless @hc_url.nil? %>
|
|
curl -m 10 --retry 5 <%= @hc_url %>/start
|
|
<% end %>
|
|
<% @pools.each_key do |pool| %>
|
|
zpool scrub <%= pool %>
|
|
# Wait until scrub for <%= pool %> is finished
|
|
while zpool status <%= pool %> | grep -q 'scan: *scrub in progress'; do
|
|
zpool status <%= pool %>
|
|
sleep 600
|
|
done
|
|
<% end %>
|
|
|
|
# Get status for all pools
|
|
zpool status
|
|
|
|
# Get stdout from journalctl
|
|
<% unless @hc_url.nil? %>
|
|
LOG=$(journalctl -o cat -u zfs-scrub.service -n 100)
|
|
curl -fsS -m 10 --retry 5 --data-raw "$LOG" <%= @hc_url %>
|
|
<% end %>
|
|
exit 0 |