kernel/msdosfs: Add pathconf(3) support for FILESIZEBITS.
[dragonfly.git] / etc / rc.d / virecover
blob6541d7492d27f50fecfc4c320cf992cbaaf3be0a
1 #!/bin/sh
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 21:47:32 swildner Exp $
8 # PROVIDE: virecover
9 # REQUIRE: mountcritremote ldconfig
10 # BEFORE: DAEMON
12 # XXX: should require `mail'!
14 . /etc/rc.subr
16 name="virecover"
17 stop_cmd=":"
18 start_cmd="virecover_start"
20 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
34 continue
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
40 rm -f "${i}"
42 done
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
51 continue
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
59 sendmail -t < "${i}"
60 else
61 rm -f "${i}"
63 done
65 echo '.'
69 load_rc_config $name
70 run_rc_command "$1"