1#!/bin/sh - 2# 3# $FreeBSD$ 4# 5 6# If there is a global system configuration file, suck it in. 7# 8if [ -r /etc/defaults/periodic.conf ] 9then 10 . /etc/defaults/periodic.conf 11 source_periodic_confs 12fi 13 14oldmask=$(umask) 15umask 066 16case "$monthly_accounting_enable" in 17 [Yy][Ee][Ss]) 18 W=/var/log/utx.log 19 rc=0 20 remove=NO 21 filetoread=$W.0 22 if [ ! -f $W.0 ] 23 then 24 if [ -f $W.0.gz ] || [ -f $W.0.bz2 ] || [ -f $W.0.xz ] || [ -f $W.0.zst ] 25 then 26 TMP=`mktemp -t accounting` 27 remove=YES 28 filetoread=$TMP 29 if [ -f $W.0.gz ] 30 then 31 zcat $W.0.gz > $TMP || rc=1 32 elif [ -f $W.0.bz2 ] 33 then 34 bzcat $W.0.bz2 > $TMP || rc=1 35 elif [ -f $W.0.xz ] 36 then 37 xzcat $W.0.xz > $TMP || rc=1 38 elif [ -f $W.0.zst ] 39 then 40 zstdcat $W.0.zst > $TMP || rc=1 41 else 42 # shouldn't get here, unless something disappeared under us. 43 rc=2 44 fi 45 else 46 echo '$monthly_accounting_enable is set but' \ 47 "$W.0 doesn't exist" 48 rc=2 49 fi 50 fi 51 if [ $rc -eq 0 ] 52 then 53 echo "" 54 echo "Doing login accounting:" 55 56 rc=$(ac -p -w $filetoread | sort -nr -k 2 | tee /dev/stderr | wc -l) 57 [ $rc -gt 0 ] && rc=1 58 fi 59 [ $remove = YES ] && rm -f $TMP;; 60 61 *) rc=0;; 62esac 63 64umask $oldmask 65exit $rc 66