We already have the "SERVICE_MODE=1" feature that signals to e2scrub
that we're running as a background daemon and therefore we should exit
quietly if conditions aren't right.
It's therefore unnecessary to have a separate -C flag to achieve the
same outcome for cron jobs. Merge the two together.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-30 3 * * 0 root test -e /run/systemd/system || @pkglibdir@/e2scrub_all_cron
-10 3 * * * root test -e /run/systemd/system || @root_sbindir@/e2scrub_all -C -A -r
+30 3 * * 0 root test -e /run/systemd/system || SERVICE_MODE=1 @pkglibdir@/e2scrub_all_cron
+10 3 * * * root test -e /run/systemd/system || SERVICE_MODE=1 @root_sbindir@/e2scrub_all -A -r
snap_size_mb=256
reap=0
conffile="@root_sysconfdir@/e2scrub.conf"
snap_size_mb=256
reap=0
conffile="@root_sysconfdir@/e2scrub.conf"
-while getopts "nrACV" opt; do
+while getopts "nrAV" opt; do
case "${opt}" in
"n") DBG="echo Would execute: " ;;
"r") scrub_args="${scrub_args} -r"; reap=1;;
"A") scrub_all=1;;
case "${opt}" in
"n") DBG="echo Would execute: " ;;
"r") scrub_args="${scrub_args} -r"; reap=1;;
"A") scrub_all=1;;
"V") print_version; exitcode 0;;
*) print_help; exitcode 2;;
esac
"V") print_version; exitcode 0;;
*) print_help; exitcode 2;;
esac
# when e2scrub_all is run out of cron or a systemd timer.
if ! type lsblk >& /dev/null ; then
# when e2scrub_all is run out of cron or a systemd timer.
if ! type lsblk >& /dev/null ; then
- if [ "${run_from_cron}" -eq 1 ] ; then
- exitcode 0
- fi
+ test -n "${SERVICE_MODE}" && exitcode 0
echo "e2scrub_all: can't find lsblk --- is util-linux installed?"
exitcode 1
fi
if ! type lvcreate >& /dev/null ; then
echo "e2scrub_all: can't find lsblk --- is util-linux installed?"
exitcode 1
fi
if ! type lvcreate >& /dev/null ; then
- if [ "${run_from_cron}" -eq 1 ] ; then
- exitcode 0
- fi
+ test -n "${SERVICE_MODE}" && exitcode 0
echo "e2scrub_all: can't find lvcreate --- is lvm2 installed?"
exitcode 1
fi
echo "e2scrub_all: can't find lvcreate --- is lvm2 installed?"
exitcode 1
fi
[Service]
Type=oneshot
Environment=SERVICE_MODE=1
[Service]
Type=oneshot
Environment=SERVICE_MODE=1
-ExecStart=@root_sbindir@/e2scrub_all -C
+ExecStart=@root_sbindir@/e2scrub_all
SyslogIdentifier=e2scrub_all
SyslogIdentifier=e2scrub_all
test -e /run/systemd/system && exit 0
on_ac_power || exit 0
test -e /run/systemd/system && exit 0
on_ac_power || exit 0
-exec @root_sbindir@/e2scrub_all -C
+exec @root_sbindir@/e2scrub_all
User=root
IOSchedulingClass=idle
CPUSchedulingPolicy=idle
User=root
IOSchedulingClass=idle
CPUSchedulingPolicy=idle
-ExecStart=@root_sbindir@/e2scrub_all -C -A -r
+Environment=SERVICE_MODE=1
+ExecStart=@root_sbindir@/e2scrub_all -A -r
SyslogIdentifier=%N
RemainAfterExit=no
SyslogIdentifier=%N
RemainAfterExit=no