|
|
1.1 ! root 1: #!/bin/sh ! 2: # @(#)uudemon.clea 1.7 ! 3: # ! 4: # This demon cleans up uucp directories. ! 5: # It is started by /usr/lib/crontab; ! 6: # it can be run daily, weekly, whatever depending on the system ! 7: # uucp load. ! 8: # The log files get large so you may have to up the ulimit. ! 9: # e.g. ! 10: # ! 11: # 45 23 * * * ulimit 5000; /bin/su uucp -c "/usr/lib/uucp/uudemon.cleanu" ! 12: # ! 13: ! 14: MAILTO=${mailto:-uucp} ! 15: export PATH ! 16: PATH=/bin:/usr/bin:/usr/lib/uucp:/usr/lbin ! 17: TMP=/tmp/uu$$ ! 18: WISDOM=/tmp/uv$$ ! 19: >$WISDOM; chmod 0700 $WISDOM ! 20: ! 21: # ! 22: # These are taken from the Makefile. If changed in Makefile ! 23: # they must be changed here also. ! 24: # ! 25: PUBDIR=/usr/spool/uucppublic ! 26: SPOOL=/usr/spool/uucp ! 27: LOCKS=/usr/spool/locks ! 28: XQTDIR=/usr/spool/uucp/.Xqtdir ! 29: CORRUPT=/usr/spool/uucp/.Corrupt ! 30: LOGDIR=/usr/spool/uucp/.Log ! 31: SEQDIR=/usr/spool/uucp/.Sequence ! 32: STATDIR=/usr/spool/uucp/.Status ! 33: WORKDIR=/usr/spool/uucp/.Workspace ! 34: ADMIN=/usr/spool/uucp/.Admin ! 35: ! 36: # OLD is the directory for archiving old admin/log files ! 37: OLD=$SPOOL/.Old ! 38: O_LOGS=$OLD/Old-Log ! 39: ! 40: mv $ADMIN/xferstats $OLD/xferstats ! 41: mv $ADMIN/audit $OLD/audit ! 42: mv $ADMIN/errors $OLD/errors ! 43: mv $ADMIN/Foreign $OLD/Foreign ! 44: ! 45: > $ADMIN/xferstats ! 46: > $ADMIN/audit ! 47: > $ADMIN/errors ! 48: > $ADMIN/Foreign ! 49: ! 50: # ! 51: # The list in the for controls how many old LOG files are retained. ! 52: # O_LOGS-2 goes to O_LOGS-3, O_LOGS-1 goes to O_LOGS-2. ! 53: # Todays goes to O_LOGS-1 ! 54: # ! 55: max=${1:-1} ! 56: for i in `seq $max -1 2` ! 57: do ! 58: j=`expr $i - 1` ! 59: mv ${O_LOGS}-$j ${O_LOGS}-$i ! 60: done ! 61: ! 62: # ! 63: # Combine all log files into O_LOGS-1. ! 64: # Add a name separator between each system. ! 65: # ! 66: > ${O_LOGS}-1 ! 67: for i in uucico uucp uux uuxqt ! 68: do ! 69: cd $LOGDIR/$i ! 70: for j in * ! 71: do ! 72: if [ "$j" = "*" ] ! 73: then ! 74: break ! 75: fi ! 76: echo "********** $j **********" >> ${O_LOGS}-1 ! 77: cat $j >> ${O_LOGS}-1 ! 78: rm -f $j ! 79: done ! 80: done ! 81: ! 82: # Execute the system directory cleanup program ! 83: # See uucleanup.1m for details. ! 84: uucleanup -D7 -C7 -X2 -o2 -W1 ! 85: # Use the grep instead of the mv to ignore warnings to uucp ! 86: # grep -v 'warning message sent to uucp' $ADMIN/uucleanup > $OLD/uucleanup ! 87: mv $ADMIN/uucleanup $OLD/uucleanup ! 88: if [ -s $OLD/uucleanup ] ! 89: then ! 90: (echo "cleanup:"; cat $OLD/uucleanup) >>$WISDOM ! 91: fi ! 92: >$ADMIN/uucleanup ! 93: ! 94: # cleanup funny directories that may have been created in the spool areas ! 95: for d in $SPOOL/[A-z]* ! 96: do ! 97: if [ -z "`ls $d`" ]; then ! 98: continue ! 99: fi ! 100: ! 101: cd $d ! 102: for s in * ! 103: do ! 104: if [ "$s" = "*" ] ! 105: then ! 106: break ! 107: fi ! 108: if [ -d $s ] ! 109: then ! 110: rm -fr $s ! 111: fi ! 112: done ! 113: ! 114: # if it is now empty, remove it. ! 115: cd .. ! 116: rmdir $d ! 117: done 2>&1 >/dev/null ! 118: ! 119: # ! 120: # Find old cores ! 121: # ! 122: find $SPOOL -name core -print > $TMP ! 123: if [ -s $TMP ] ! 124: then ! 125: (echo "cores:"; cat $TMP) >>$WISDOM ! 126: fi ! 127: ! 128: # ! 129: # Remove old files and directories ! 130: # ! 131: find $PUBDIR -type f -mtime +30 -exec rm -f "{}" \; ! 132: find $PUBDIR/* -type d -exec rmdir "{}" \; ! 133: find $SEQDIR -mtime +30 -exec rm -f "{}" \; ! 134: find $WORKDIR -mtime +1 -exec rm -f "{}" \; ! 135: find $STATDIR -mtime +2 -exec rm -f "{}" \; ! 136: find $CORRUPT -mtime +10 -exec rm -f "{}" \; ! 137: ! 138: rm -f $LOCKS/LTMP* ! 139: rmdir $SPOOL/[A-z]* 2>/dev/null ! 140: ! 141: # ! 142: # Mail a daily summary of status ! 143: # ! 144: grep passwd ${O_LOGS}-1 > $TMP ! 145: # grep "REQUEST.*/" ${O_LOGS}-1 >> $TMP ! 146: if [ -s $TMP ] ! 147: then ! 148: (echo "passwd requests:"; cat $TMP) >>$WISDOM ! 149: fi ! 150: ! 151: awk '/(DENIED)/ {print prev} ! 152: {prev = $0}' ${O_LOGS}-1 > $TMP ! 153: if [ -s $TMP ] ! 154: then ! 155: (echo "denied:"; cat $TMP) >>$WISDOM ! 156: fi ! 157: # ! 158: # uustat -q > $TMP ! 159: # if [ -s $TMP ] ! 160: # then ! 161: # (echo "Subject: uu-status"; cat $TMP) >>$WISDOM ! 162: # fi ! 163: ! 164: ls $CORRUPT > $TMP ! 165: if [ -s $TMP ] ! 166: then ! 167: (echo "$CORRUPT:"; cat $TMP) >>$WISDOM ! 168: fi ! 169: ! 170: tail $OLD/errors 2>/dev/null > $TMP ! 171: tail $OLD/Foreign 2>/dev/null >> $TMP ! 172: if [ -s $TMP ] ! 173: then ! 174: (echo "Admin stuff:"; cat $TMP) >>$WISDOM ! 175: fi ! 176: # (echo "Subject: uucleanup ran; $SPOOL du"; du $SPOOL) >>$WISDOM ! 177: ! 178: if [ -s $WISDOM ]; then ! 179: mail $MAILTO <$WISDOM ! 180: fi ! 181: rm -f $WISDOM ! 182: ! 183: # ! 184: # Dispose of mail to uucp and nuucp ! 185: # ! 186: # rm -f $MAILDIR/uucp $MAILDIR/nuucp $TMP ! 187: rm -f $TMP
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.