# indicating success to avoid spamming the sysadmin with fail messages
# when e2scrub_all is run out of cron or a systemd timer.
+if ! type mapfile >& /dev/null ; then
+ test -n "${SERVICE_MODE}" && exitcode 0
+ echo "e2scrub_all: can't find mapfile --- is bash 4.xx installed?"
+ exitcode 1
+fi
+
if ! type lsblk >& /dev/null ; then
test -n "${SERVICE_MODE}" && exitcode 0
echo "e2scrub_all: can't find lsblk --- is util-linux installed?"
}
# Scrub any mounted fs on lvm by creating a snapshot and fscking that.
-stdin="$(realpath /dev/stdin)"
-ls_targets | while read tgt; do
+mapfile -t targets < <(ls_targets)
+for tgt in "${targets[@]}"; do
# If we're not reaping and systemd is present, try invoking the
# systemd service.
if [ "${reap}" -ne 1 ] && type systemctl > /dev/null 2>&1; then
tgt_esc="$(escape_path_for_systemd "${tgt}")"
- ${DBG} systemctl start "e2scrub@${tgt_esc}" 2> /dev/null < "${stdin}"
+ ${DBG} systemctl start "e2scrub@${tgt_esc}" 2> /dev/null
res=$?
if [ "${res}" -eq 0 ] || [ "${res}" -eq 1 ]; then
continue;
fi
# Otherwise use direct invocation
- ${DBG} "@root_sbindir@/e2scrub" ${scrub_args} "${tgt}" < "${stdin}"
+ ${DBG} "@root_sbindir@/e2scrub" ${scrub_args} "${tgt}"
done
exitcode 0