Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / etc / periodic / daily / 200.backup-passwd
CommitLineData
984263bc
MD
1#!/bin/sh
2#
3# $FreeBSD: src/etc/periodic/daily/200.backup-passwd,v 1.6.2.3 2001/11/17 22:42:46 cjc Exp $
1de703da 4# $DragonFly: src/etc/periodic/daily/200.backup-passwd,v 1.2 2003/06/17 04:24:48 dillon Exp $
984263bc
MD
5#
6
7# If there is a global system configuration file, suck it in.
8#
9if [ -r /etc/defaults/periodic.conf ]
10then
11 . /etc/defaults/periodic.conf
12 source_periodic_confs
13fi
14
15case "$daily_backup_passwd_enable" in
16 [Yy][Ee][Ss])
17 if [ ! -f /etc/master.passwd ]
18 then
19 echo '$daily_backup_passwd_enable" is set but /etc/master.passwd' \
20 "doesn't exist"
21 rc=2
22 elif [ ! -f /etc/group ]
23 then
24 echo '$daily_backup_passwd_enable" is set but /etc/group' \
25 "doesn't exist"
26 rc=2
27 else
28 bak=/var/backups
29 rc=0
30
31 echo ""
32 echo "Backup passwd and group files:"
33
34 if [ ! -f $bak/master.passwd.bak ]
35 then
36 rc=1
37 echo "no $bak/master.passwd.bak"
38 cp -p /etc/master.passwd $bak/master.passwd.bak || rc=3
39 fi
40
41 if ! cmp -s $bak/master.passwd.bak /etc/master.passwd
42 then
43 [ $rc -lt 1 ] && rc=1
44 echo "$host passwd diffs:"
45 diff -I '^#' $bak/master.passwd.bak /etc/master.passwd |\
46 sed 's/^\([<>] [^:]*\):[^:]*:/\1:(password):/'
47 mv $bak/master.passwd.bak $bak/master.passwd.bak2
48 cp -p /etc/master.passwd $bak/master.passwd.bak || rc=3
49 fi
50
51 if [ ! -f $bak/group.bak ]
52 then
53 [ $rc -lt 1 ] && rc=1
54 echo "no $bak/group.bak"
55 cp -p /etc/group $bak/group.bak || rc=3
56 fi
57
58 if ! cmp -s $bak/group.bak /etc/group
59 then
60 [ $rc -lt 1 ] && rc=1
61 echo "$host group diffs:"
62 diff $bak/group.bak /etc/group
63 mv $bak/group.bak $bak/group.bak2
64 cp -p /etc/group $bak/group.bak || rc=3
65 fi
66
67 if [ -f /etc/group ]
68 then
69 echo ""
70 echo "Verifying group file syntax:"
71 chkgrp /etc/group || rc=3
72 fi
73 fi;;
74
75 *) rc=0;;
76esac
77
78exit $rc