7 # (the "License"). You may not use this file except in compliance
8 # with the License.
9 #
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
14 #
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
20 #
21 # CDDL HEADER END
22 #
23 # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
24 # All Rights Reserved
25
26
27 #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.6 */
28 # "lastlogin - keep record of date each person last logged in"
29 # "bug - the date shown is usually 1 more than it should be "
30 # " because lastlogin is run at 4am and checks the last"
31 # " 24 hrs worth of process accounting info (in pacct)"
32 PATH=/usr/lib/acct:/usr/bin:/usr/sbin
33 cd /var/adm/acct
34 if test ! -r sum/loginlog; then
35 nulladm sum/loginlog
36 fi
37 # "cleanup loginlog - delete entries of those no longer in"
38 # "/etc/passwd and add an entry for those recently added"
39 # "line 1 - get file of current logins in same form as loginlog"
40 # "line 2 - merge the 2 files; use uniq to delete common"
41 # "lines resulting in those lines which need to be"
42 # "deleted or added from loginlog"
43 # "line 3 - result of sort will be a file with 2 copies"
44 # "of lines to delete and 1 copy of lines that are "
45 # "valid; use uniq to remove duplicate lines"
46 getent passwd | sed "s/\([^:]*\).*/00-00-00 \1/" |\
47 sort +1 - sum/loginlog | uniq -u +10 |\
48 sort +1 - sum/loginlog |uniq -u > sum/tmploginlog
49 cp sum/tmploginlog sum/loginlog
50 # "update loginlog"
51 _d="`date +%y-%m-%d`"
52 _day=`date +%m%d`
53 # "lines 1 and 2 - remove everything from the total"
54 # "acctng records with connect info except login"
55 # "name and adds the date"
56 # "line 3 - sorts in reverse order by login name; gets"
57 # "1st occurrence of each login name and resorts by date"
58 acctmerg -a < nite/ctacct.$_day | \
59 sed -e "s/^[^ ]*[ ]\([^ ]*\)[ ].*/$_d \1/" | \
60 nawk '/^00-00-00/ {
61 $0 = "00" $0
62 }
63 /^[0-9][0-9]-/ {
64 d=substr($0,1,2);
65 if (d<=68) {
66 $0 = "20" $0
67 } else {
68 $0 = "19" $0
69 }
70 }
71 { print }' - sum/loginlog | \
72 sort -r +1 | uniq +10 | sort | \
73 nawk '/^[0-9][0-9][0-9][0-9]-/ {
74 $0 = substr($0,3)
75 }
76 { print }' > sum/tmploginlog
77 cp sum/tmploginlog sum/loginlog
78 rm -f sum/tmploginlog
|
7 # (the "License"). You may not use this file except in compliance
8 # with the License.
9 #
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
14 #
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
20 #
21 # CDDL HEADER END
22 #
23 # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
24 # All Rights Reserved
25
26
27 # "lastlogin - keep record of date each person last logged in"
28 # "bug - the date shown is usually 1 more than it should be "
29 # " because lastlogin is run at 4am and checks the last"
30 # " 24 hrs worth of process accounting info (in pacct)"
31 PATH=/usr/lib/acct:/usr/bin:/usr/sbin
32 cd /var/adm/acct
33 if test ! -r sum/loginlog; then
34 nulladm sum/loginlog
35 fi
36 # "cleanup loginlog - delete entries of those no longer in"
37 # "/etc/passwd and add an entry for those recently added"
38 # "line 1 - get file of current logins in same form as loginlog"
39 # "line 2 - merge the 2 files; use uniq to delete common"
40 # "lines resulting in those lines which need to be"
41 # "deleted or added from loginlog"
42 # "line 3 - result of sort will be a file with 2 copies"
43 # "of lines to delete and 1 copy of lines that are "
44 # "valid; use uniq to remove duplicate lines"
45 getent passwd | sed "s/\([^:]*\).*/00-00-00 \1/" |\
46 sort +1 - sum/loginlog | uniq -u +10 |\
47 sort +1 - sum/loginlog |uniq -u > sum/tmploginlog
48 cp sum/tmploginlog sum/loginlog
49 # "update loginlog"
50 _d="`date +%y-%m-%d`"
51 _day=`date +%m%d`
52 # "lines 1 and 2 - remove everything from the total"
53 # "acctng records with connect info except login"
54 # "name and adds the date"
55 # "line 3 - sorts in reverse order by login name; gets"
56 # "1st occurrence of each login name and resorts by date"
57 acctmerg -a < nite/ctacct.$_day | \
58 sed -e "s/^[^ ]*[ ]\([^ ]*\)[ ].*/$_d \1/" | \
59 /usr/xpg4/bin/awk '/^00-00-00/ {
60 $0 = "00" $0
61 }
62 /^[0-9][0-9]-/ {
63 d=substr($0,1,2);
64 if (d<=68) {
65 $0 = "20" $0
66 } else {
67 $0 = "19" $0
68 }
69 }
70 { print }' - sum/loginlog | \
71 sort -r +1 | uniq +10 | sort | \
72 /usr/xpg4/bin/awk '/^[0-9][0-9][0-9][0-9]-/ {
73 $0 = substr($0,3)
74 }
75 { print }' > sum/tmploginlog
76 cp sum/tmploginlog sum/loginlog
77 rm -f sum/tmploginlog
|