Source code pulled from OpenBSD for OpenNTPD. The place to contribute to this code is via the OpenBSD CVS tree.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
2.7 KiB

  1. #!/bin/sh -
  2. #
  3. # @(#)daily 5.12 (Berkeley) 5/24/91
  4. #
  5. PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local
  6. host=`hostname -s`
  7. echo "Subject: $host daily run output"
  8. if [ -f /etc/daily.local ];then
  9. echo ""
  10. echo "Running daily.local:"
  11. . /etc/daily.local
  12. fi
  13. echo ""
  14. echo "Removing scratch and junk files:"
  15. if [ -d /tmp -a ! -h /tmp ]; then
  16. cd /tmp && {
  17. find . -type f -atime +3 -exec rm -f -- {} \;
  18. find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
  19. >/dev/null 2>&1; }
  20. fi
  21. if [ -d /var/tmp -a ! -h /var/tmp ]; then
  22. cd /var/tmp && {
  23. find . ! -name . -atime +7 -exec rm -f -- {} \;
  24. find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
  25. >/dev/null 2>&1; }
  26. fi
  27. if [ -d /scratch -a ! -h /scratch ]; then
  28. cd /scratch && {
  29. find . ! -name . -atime +1 -exec rm -f -- {} \;
  30. find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
  31. >/dev/null 2>&1; }
  32. fi
  33. # XXX should go away/be replaced by nvi version
  34. if [ -d /var/preserve -a ! -h /var/preserve ]; then
  35. cd /var/preserve && {
  36. find . ! -name . -mtime +7 -exec rm -f -- {} \; ; }
  37. fi
  38. if [ -d /var/rwho -a ! -h /var/rwho ] ; then
  39. cd /var/rwho && {
  40. find . ! -name . -mtime +7 -exec rm -f -- {} \; ; }
  41. fi
  42. cd /tmp
  43. TMP=daily.$$
  44. find / \( ! -fstype local -o -fstype rdonly -o -fstype fdesc \
  45. -o -fstype kernfs -o -fstype procfs \) -a -prune -o \
  46. -name 'lost+found' -a -prune -o \
  47. -name '*.core' -a -print -o \
  48. \( -name '[#,]*' -o -name '.#*' -o -name a.out \
  49. -o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \
  50. -a -atime +3 -exec rm -f -- {} \; -a -print > $TMP
  51. echo ""
  52. echo "Possible core dumps:"
  53. egrep '\.core' $TMP
  54. echo ""
  55. echo "Deleted files:"
  56. egrep -v '\.core' $TMP
  57. rm -f $TMP
  58. msgs -c
  59. if [ -f /etc/news.expire ]; then
  60. /etc/news.expire
  61. fi
  62. if [ -f /var/account/acct ]; then
  63. echo "" ;
  64. echo "Purging accounting records:" ;
  65. mv /var/account/acct.2 /var/account/acct.3 ;
  66. mv /var/account/acct.1 /var/account/acct.2 ;
  67. mv /var/account/acct.0 /var/account/acct.1 ;
  68. cp /var/account/acct /var/account/acct.0 ;
  69. sa -sq ;
  70. fi
  71. echo ""
  72. echo "Running calendar:"
  73. calendar -a
  74. # Rotation of mail log now handled automatically by cron and 'newsyslog'
  75. if [ -d /var/spool/uucp -a -f /etc/uuclean.daily ]; then
  76. echo ""
  77. echo "Cleaning up UUCP:"
  78. echo /etc/uuclean.daily | su daemon
  79. fi
  80. echo ""
  81. echo ""
  82. echo "Checking subsystem status:"
  83. echo ""
  84. echo "disks:"
  85. df -k
  86. echo ""
  87. dump W
  88. echo ""
  89. echo ""
  90. echo "mail:"
  91. mailq
  92. if [ -d /var/spool/uucp ]; then
  93. echo ""
  94. echo "uucp:"
  95. uustat -a
  96. fi
  97. echo ""
  98. echo "network:"
  99. netstat -i
  100. echo ""
  101. ruptime
  102. echo ""
  103. echo "Checking filesystems:"
  104. fsck -n | grep -v '^\*\* Phase'
  105. echo ""
  106. if [ -f /etc/Distfile ]; then
  107. echo "Running rdist:"
  108. rdist -f /etc/Distfile
  109. fi
  110. sh /etc/security 2>&1 | mail -s "daily insecurity output" root