5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License, Version 1.0 only
7 # (the "License"). You may not use this file except in compliance
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.
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]
24 # Copyright 1997 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
27 #ident "%Z%%M% %I% %E% SMI"
29 # This demon cleans up uucp directories.
30 # It is started by /var/spool/cron/crontabs/uucp;
31 # it can be run daily, weekly, whatever depending on the system
35 # return a list of systems defined in /etc/uucp/Systems
37 if [ ! -f /etc
/uucp
/Systems
]; then
40 awk '$1 !~ /^#/ {print $1}' /etc
/uucp
/Systems
44 # return a list of systems defined in /etc/asppp.cf
46 if [ ! -f /etc
/asppp.cf
]; then
49 X
=`sed -e 's/#.*$//' /etc/asppp.cf`
53 if [ "$1" = "peer_system_name" ]; then
54 PPPSYSTEMS
="$PPPSYSTEMS $2"
63 # run through the systems list, deleting ppp systems
68 for j
in `getpppsystems`
70 if [ "$j" = "$i" ]; then
74 if [ $del -ne 1 ]; then
79 # if any names are in $outstr, assume uucp is configured
81 if [ -n "$outstr" ]; then
88 # Start of actual processing. For energystar compatibility,
89 # we attempt to do as little I/O as possible, so first check
90 # to see if uucp is configured before doing all this work.
99 PATH
=/usr
/bin
:/usr
/lib
/uucp
102 # Running as uucp, take care to protect things
107 # These are taken from the Makefile. If changed in Makefile
108 # they must be changed here also.
110 PUBDIR
=/var
/spool
/uucppublic
111 SPOOL
=/var
/spool
/uucp
113 LOCKS
=/var
/spool
/locks
# needs a comment in parms.h on USRSPOOLOCKS
115 CORRUPT
=$SPOOL/.Corrupt
117 SEQDIR
=$VAR/.Sequence
119 WORKDIR
=$SPOOL/.Workspace
122 # OLD is the directory for archiving old admin/log files
125 ACCT_LOGS
=$OLD/Old-acct
126 SEC_LOGS
=$OLD/Old-sec
128 [ -f $ADMIN/xferstats
] && mv $ADMIN/xferstats
$OLD/xferstats
129 [ -f $ADMIN/audit
] && mv $ADMIN/audit
$OLD/audit
130 [ -f $ADMIN/command ] &&mv $ADMIN/command $OLD/command
131 [ -f $ADMIN/errors
] && mv $ADMIN/errors
$OLD/errors
132 [ -f $ADMIN/Foreign
] && mv $ADMIN/Foreign
$OLD/Foreign
141 # If performance log exists, save it and create a new one
143 if [ -f $ADMIN/perflog
]
145 mv $ADMIN/perflog
$OLD/perflog
150 # The list in the for controls how many old Log and security logs
151 # are retained: 2 -> 3, 1 -> 2, current -> 1.
156 [ -f ${O_LOGS}-$i ] && mv ${O_LOGS}-$i ${O_LOGS}-$j
157 [ -f ${SEC_LOGS}-$i ] && mv ${SEC_LOGS}-$i ${SEC_LOGS}-$j
160 [ -f $ADMIN/security
] && mv $ADMIN/security
${SEC_LOGS}-1
164 # Combine all log files into O_LOGS-1.
165 # Add a name separator between each system.
168 for i
in uucico
uucp uux uuxqt
170 if [ ! -d $LOGDIR/$i ]
172 (echo "uudemon.cleanup: $LOGDIR/$i directory does not exist, remove if file"
173 echo "uudemon.cleanup: making a directory $LOGDIR/$i"
181 # can't compare exactly because of symlinks
183 *`basename $LOGDIR`/$i)
186 (echo "uudemon.cleanup: unable to chdir to $LOGDIR/$i") |
mail $MAILTO
196 echo "********** $j ********** ($i)" >> ${O_LOGS}-1
197 cat $j >> ${O_LOGS}-1
203 # If the accounting log exists, save it and create a new one.
204 # The list in the for controls how many old accounting logs
205 # are retained: 2 -> 3, 1 -> 2, current -> 1.
207 if [ -f $ADMIN/account
]
212 [ -f ${ACCT_LOGS}-$i ] && mv ${ACCT_LOGS}-$i ${ACCT_LOGS}-$j
214 [ -f $ADMIN/account
] && mv $ADMIN/account
${ACCT_LOGS}-1
218 # Execute the system directory cleanup program
219 # See uucleanup.1m for details.
220 uucleanup
-D7 -C7 -X2 -o2 -W1
222 # Use the grep instead of the mv to ignore warnings to uucp
223 # grep -v 'warning message sent to uucp' $ADMIN/uucleanup > $OLD/uucleanup
224 [ -f $ADMIN/uucleanup
] && mv $ADMIN/uucleanup
$OLD/uucleanup
225 if [ -s $OLD/uucleanup
]
227 (echo "Subject: cleanup"; echo; cat $OLD/uucleanup
) |
mail $MAILTO
231 # cleanup funny directories that may have been created in the spool areas
232 for d
in $SPOOL/[0-9A-Za-z]*
236 # skip any regular files, like lockfiles
237 # and mail.log and so forth
246 # we'd check that we were in the correct directory
247 if [ "`basename \`pwd\``" != "`basename $d`" ]
249 (echo "uudemon.cleanup: unable to chdir to $d") |
mail $MAILTO
260 # Remove subdirs of subdirs
265 # if it is now empty, remove it.
273 find $SPOOL -name core
-print > $TMP
276 (echo "Subject: cores"; echo; cat $TMP) |
mail $MAILTO
280 # Remove old files and directories
282 #find $PUBDIR -type f -mtime +30 -exec rm -f {} \;
283 find $PUBDIR/* -depth -type d
-exec rmdir {} \
; >/dev
/null
2>&1
284 find $SPOOL/* -depth -type d
-exec rmdir {} \
; >/dev
/null
2>&1
285 find $SEQDIR -type f
-mtime +30 -exec rm -f {} \
;
286 find $WORKDIR -type f
-mtime +1 -exec rm -f {} \
;
287 find $STATDIR -type f
-mtime +2 -exec rm -f {} \
;
288 find $CORRUPT -type f
-mtime +10 -exec rm -f {} \
;
291 rmdir $SPOOL/[0-9A-Za-z]* >/dev
/null
2>&1
294 # Mail a daily summary of status
296 grep passwd
${O_LOGS}-1 > $TMP
297 grep "REQUEST.*/" ${O_LOGS}-1 >> $TMP
300 (echo "Subject: uucp requests"; echo; cat $TMP) |
mail $MAILTO
304 awk '/(DENIED)/ {print prev}
305 {prev = $0}' ${O_LOGS}-1 > $TMP
308 (echo "Subject: uucp DENIED"; echo; cat $TMP) |
mail $MAILTO
314 (echo "Subject: uu-status"; echo; cat $TMP) |
mail $MAILTO
320 (echo "Subject: $CORRUPT"; echo; cat $TMP) |
mail $MAILTO
323 if [ -s $OLD/errors
-o -s $OLD/Foreign
]
325 (echo "Subject: uucp Admin"; \
326 echo; echo tail errors
; tail $OLD/errors
; \
327 echo; echo tail Foreign
; tail $OLD/Foreign
; \
330 # don't run if no system directories exist
331 if [ "`echo $SPOOL/*`" != "$SPOOL/*" ]
333 (echo "Subject: uucleanup ran; $SPOOL du"; echo; du
$SPOOL) | \
338 # Dispose of mail to nuucp
340 rm -f $MAILDIR/nuucp
$TMP