home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume18 / diskhog2 / diskhog < prev    next >
Encoding:
Text File  |  1989-03-26  |  1.4 KB  |  51 lines

  1. #
  2. # script that naughty people get when they don't remove files
  3. #
  4. trap '' 2 3
  5. stty erase ^H kill ^U echoe intr ^? quit ^\
  6. SHELL=/bin/sh
  7. export SHELL PATH
  8. #
  9. # re-check the disk allocation
  10. #
  11. DQUOTAS=/usr/local/lib/disk            # directory containing all the info
  12. HOG=1
  13. echo "\nOvernight check shows you have too much disk space"
  14. while [ "$HOG" = "1" ]
  15. do
  16.     PATH=/bin:/usr/bin:/usr/ucb
  17.     echo "Re-checking your disk usage .... \c"
  18.     ALLOWED=`grep $LOGNAME $DQUOTAS/allowed | awk '{print $2}'`
  19.     DISK=`du -s . | awk '{print $1}'`
  20.     echo "done"
  21.     if [ "$DISK" -gt "$ALLOWED" ]
  22.     then
  23.         echo "You have $DISK blocks, but are allowed only $ALLOWED"
  24.         echo "You must remove some files before you can logon"
  25.         echo "You now have a restricted shell with the following commands"
  26.         ls -C /diskhog /usr/diskhog
  27.         echo "Remove some files and then type CONTROL-D"
  28.  
  29. #
  30. # if we allow interrupts in this shell, we get zapped on return
  31. # so - fork a shell, and allow interrupts there
  32. # we have to give a command to trap, so that spawned commands get SIG_DFL,
  33. # or we can't reset them when we get there!
  34. # You may have to say "trap 3" to unlock the QUIT signal.
  35. #
  36.         trap 'echo "** interrupt ignored **"' 2 3
  37.         /bin/sh << EOF
  38. PATH=/diskhog:/usr/diskhog
  39. SHELL=/bin/rsh
  40. export PATH SHELL
  41. exec /bin/rsh < /dev/tty        # signals get set to SIG_DFL
  42. EOF
  43.         trap '' 2 3        # ignore SIGINT SIGQUIT
  44.     else
  45.         echo "I see that you have removed your excess disk blocks - thankyou"
  46.         nohog
  47.         HOG=0
  48.         chmod og+rx $HOME
  49.     fi
  50. done
  51.