blob: f3bcc857b4664fc2a58524187649b0799d45cf6a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: virecover
# REQUIRE: mountcritremote ldconfig
# BEFORE: DAEMON
#
# XXX: should require `mail'!
. /etc/rc.subr
name="virecover"
rcvar="virecover_enable"
stop_cmd=":"
start_cmd="virecover_start"
virecover_start()
{
[ -d /var/tmp/vi.recover ] || return
find /var/tmp/vi.recover ! -type f -a ! -type d -delete
vibackup=`echo /var/tmp/vi.recover/vi.*`
if [ "${vibackup}" != '/var/tmp/vi.recover/vi.*' ]; then
echo -n 'Recovering vi editor sessions:'
for i in /var/tmp/vi.recover/vi.*; do
# Only test files that are readable.
if [ ! -r "${i}" ]; then
continue
fi
# Unmodified nvi editor backup files either have the
# execute bit set or are zero length. Delete them.
if [ -x "${i}" -o ! -s "${i}" ]; then
rm -f "${i}"
fi
done
# It is possible to get incomplete recovery files, if the editor
# crashes at the right time.
virecovery=`echo /var/tmp/vi.recover/recover.*`
if [ "${virecovery}" != "/var/tmp/vi.recover/recover.*" ]; then
for i in /var/tmp/vi.recover/recover.*; do
# Only test files that are readable.
if [ ! -r "${i}" ]; then
continue
fi
# Delete any recovery files that are zero length,
# corrupted, or that have no corresponding backup file.
# Else send mail to the user.
recfile=`awk '/^X-vi-recover-path:/{print $2}' < "${i}"`
if [ -n "${recfile}" -a -s "${recfile}" ]; then
sendmail -t < "${i}"
else
rm -f "${i}"
fi
done
fi
echo '.'
fi
}
load_rc_config $name
run_rc_command "$1"
|