diff options
author | Theodore Ts'o <tytso@mit.edu> | 2019-03-10 19:41:11 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2019-03-10 19:52:25 -0400 |
commit | 04738f2ff3b8a2acaf2de09856e07601817350b5 (patch) | |
tree | d4380bb39a989e36a4b98325b89aef050c45aa96 /scrub/e2scrub_all.in | |
parent | 2fe97b2bd04e18c3fb6dfa7a1801198b32c4437e (diff) | |
download | e2fsprogs-04738f2ff3b8a2acaf2de09856e07601817350b5.tar.gz |
e2scrub: check to make sure lvm2 is installed
Not all systems will have the lvm2 package installed, so check for
that. Pretty much all systems should have util-linux installed, but
check for that as well.
Of course, if lvm2 is installed we shouldn't find any LVM devices ---
but eventually the Demon Murphy will find a way to make it happen. :-)
Also, set the PATH so we don't have to worry about the script failing
due to /sbin not being in the path.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'scrub/e2scrub_all.in')
-rw-r--r-- | scrub/e2scrub_all.in | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/scrub/e2scrub_all.in b/scrub/e2scrub_all.in index 23d122d2..d725a7f2 100644 --- a/scrub/e2scrub_all.in +++ b/scrub/e2scrub_all.in @@ -18,6 +18,8 @@ # along with this program; if not, write the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin + scrub_all=0 conffile="@root_sysconfdir@/e2scrub.conf" @@ -68,6 +70,20 @@ while getopts "ArV" opt; do done shift "$((OPTIND - 1))" +# If some prerequisite packages are not installed, exit with a code +# indicating success to avoid spamming the sysadmin with fail messages +# when e2scrub_all is run out of cron or a systemd timer. + +if ! type lsblk >& /dev/null ; then + echo "e2scrub_all: can't find lsblk --- is util-linux installed?" + exitcode 0 +fi + +if ! type lvcreate >& /dev/null ; then + echo "e2scrub_all: can't find lvcreate --- is lvm2 installed?" + exitcode 0 +fi + # Find scrub targets, make sure we only do this once. ls_scrub_targets() { lsblk -o NAME,FSTYPE,MOUNTPOINT -p -P -n | while read vars; do |