TOR: fix compilation
[tomato.git] / release / src / router / e2fsprogs / contrib / e2croncheck
blob87204be307c04d2d787dea2ee24e38eababcb373
1 #!/bin/sh
3 # e2croncheck -- run e2fsck automatically out of /etc/cron.weekly
5 # This script is intended to be run by the system administrator
6 # periodically from the command line, or to be run once a week
7 # or so by the cron daemon to check a mounted filesystem (normally
8 # the root filesystem, but it could be used to check other filesystems
9 # that are always mounted when the system is booted).
11 # Make sure you customize "VG" so it is your LVM volume group name,
12 # "VOLUME" so it is the name of the filesystem's logical volume,
13 # and "EMAIL" to be your e-mail address
15 # Written by Theodore Ts'o, Copyright 2007, 2008, 2009.
17 # This file may be redistributed under the terms of the
18 # GNU Public License, version 2.
21 VG=ssd
22 VOLUME=root
23 SNAPSIZE=100m
24 EMAIL=sysadmin@example.com
26 TMPFILE=`mktemp -t e2fsck.log.XXXXXXXXXX`
28 OPTS="-Fttv -C0"
29 #OPTS="-Fttv -E fragcheck"
31 set -e
32 START="$(date +'%Y%m%d%H%M%S')"
33 lvcreate -s -L ${SNAPSIZE} -n "${VOLUME}-snap" "${VG}/${VOLUME}"
34 if nice logsave -as $TMPFILE e2fsck -p $OPTS "/dev/${VG}/${VOLUME}-snap" && \
35 nice logsave -as $TMPFILE e2fsck -fy $OPTS "/dev/${VG}/${VOLUME}-snap" ; then
36 echo 'Background scrubbing succeeded!'
37 tune2fs -C 0 -T "${START}" "/dev/${VG}/${VOLUME}"
38 else
39 echo 'Background scrubbing failed! Reboot to fsck soon!'
40 tune2fs -C 16000 -T "19000101" "/dev/${VG}/${VOLUME}"
41 if test -n "$RPT-EMAIL"; then
42 mail -s "E2fsck of /dev/${VG}/${VOLUME} failed!" $EMAIL < $TMPFILE
45 lvremove -f "${VG}/${VOLUME}-snap"
46 rm $TMPFILE