3 # $NetBSD: virecover,v 1.6 2002/03/22 04:34:00 thorpej Exp $
4 # $FreeBSD: src/etc/rc.d/virecover,v 1.5 2003/05/05 09:53:32 mtm Exp $
5 # $DragonFly: src/etc/rc.d/virecover,v 1.4 2005/11/19 22:47:32 swildner Exp $
9 # REQUIRE: mountcritremote ldconfig
12 # XXX: should require `mail'!
18 start_cmd
="virecover_start"
22 if [ ! -d /var
/tmp
/vi.recover
]; then
23 mkdir
/var
/tmp
/vi.recover
24 chown root
:wheel
/var
/tmp
/vi.recover
25 chmod 1777 /var
/tmp
/vi.recover
27 find /var
/tmp
/vi.recover
! -type f
-a ! -type d
-delete
28 vibackup
=`echo /var/tmp/vi.recover/vi.*`
29 if [ "${vibackup}" != '/var/tmp/vi.recover/vi.*' ]; then
30 echo -n 'Recovering vi editor sessions:'
31 for i
in /var
/tmp
/vi.recover
/vi.
*; do
32 # Only test files that are readable.
33 if [ ! -r "${i}" ]; then
37 # Unmodified nvi editor backup files either have the
38 # execute bit set or are zero length. Delete them.
39 if [ -x "${i}" -o ! -s "${i}" ]; then
44 # It is possible to get incomplete recovery files, if the editor
45 # crashes at the right time.
46 virecovery
=`echo /var/tmp/vi.recover/recover.*`
47 if [ "${virecovery}" != "/var/tmp/vi.recover/recover.*" ]; then
48 for i
in /var
/tmp
/vi.recover
/recover.
*; do
49 # Only test files that are readable.
50 if [ ! -r "${i}" ]; then
54 # Delete any recovery files that are zero length,
55 # corrupted, or that have no corresponding backup file.
56 # Else send mail to the user.
57 recfile
=`awk '/^X-vi-recover-path:/{print $2}' < "${i}"`
58 if [ -n "${recfile}" -a -s "${recfile}" ]; then