MFC: Use humanize_number(3) for -h and -H.
[dragonfly.git] / etc / periodic / daily / 200.backup-passwd
blobb15f952bfc1dcb14b69b53925763677e1ab7fb5b
1 #!/bin/sh
3 # $FreeBSD: src/etc/periodic/daily/200.backup-passwd,v 1.6.2.3 2001/11/17 22:42:46 cjc Exp $
4 # $DragonFly: src/etc/periodic/daily/200.backup-passwd,v 1.2 2003/06/17 04:24:48 dillon Exp $
7 # If there is a global system configuration file, suck it in.
9 if [ -r /etc/defaults/periodic.conf ]
10 then
11 . /etc/defaults/periodic.conf
12 source_periodic_confs
15 case "$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
31 echo ""
32 echo "Backup passwd and group files:"
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
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
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
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
67 if [ -f /etc/group ]
68 then
69 echo ""
70 echo "Verifying group file syntax:"
71 chkgrp /etc/group || rc=3
73 fi;;
75 *) rc=0;;
76 esac
78 exit $rc