diff options
author | gordon <gordon@FreeBSD.org> | 2002-06-13 22:14:37 +0000 |
---|---|---|
committer | gordon <gordon@FreeBSD.org> | 2002-06-13 22:14:37 +0000 |
commit | 9c5433cb225f7a4e56e87623ea2e4011179553a5 (patch) | |
tree | 3168589e209abd888b033397e3c46dee6131a116 /etc/rc.d/virecover | |
parent | 50d99cdfecd92f5323a18aa791a5b1cb9d8b7191 (diff) | |
download | FreeBSD-src-9c5433cb225f7a4e56e87623ea2e4011179553a5.zip FreeBSD-src-9c5433cb225f7a4e56e87623ea2e4011179553a5.tar.gz |
Merge in all the changes that Mike Makonnen has been maintaining for a
while. This is only the script pieces, the glue for the build comes next.
Submitted by: Mike Makonnen <makonnen@pacbell.net>
Reviewed by: silence on -current and -hackers
Prodded by: rwatson
Diffstat (limited to 'etc/rc.d/virecover')
-rwxr-xr-x | etc/rc.d/virecover | 58 |
1 files changed, 51 insertions, 7 deletions
diff --git a/etc/rc.d/virecover b/etc/rc.d/virecover index aad6295..9ecdbf6 100755 --- a/etc/rc.d/virecover +++ b/etc/rc.d/virecover @@ -1,27 +1,71 @@ #!/bin/sh # -# $NetBSD: virecover,v 1.3 2000/07/26 00:11:49 lukem Exp $ +# $NetBSD: virecover,v 1.6 2002/03/22 04:34:00 thorpej Exp $ +# $FreeBSD$ # # PROVIDE: virecover # REQUIRE: mountcritremote +# BEFORE: DAEMON +# KEYWORD: FreeBSD NetBSD # # XXX: should require `mail'! . /etc/rc.subr name="virecover" -start_cmd="virecover_start" stop_cmd=":" +case `${CMD_OSTYPE}` in +FreeBSD) + start_cmd="virecover_start" + ;; +NetBSD) + command="/usr/libexec/${name}" + ;; +esac + virecover_start() { - recover=`find /var/tmp/vi.recover -name 'recover.*' -type f -print` - if [ -n "$recover" ]; then - echo "Preserving editor files." - for i in $recover; do - sendmail -t < $i + 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 } |