home *** CD-ROM | disk | FTP | other *** search
/ tusportal.tus.k12.pa.us / tusportal.tus.k12.pa.us.tar / tusportal.tus.k12.pa.us / Wyse / latest-image.raw / 0.img / etc / init.d / boot.cleanup < prev    next >
Text File  |  2010-05-05  |  3KB  |  113 lines

  1. #! /bin/sh
  2. #
  3. # Copyright (c) 2001-2005 SuSE Linux AG, Nuernberg, Germany.
  4. # All rights reserved.
  5. #
  6. # /etc/init.d/boot.cleanup
  7. #
  8. ### BEGIN INIT INFO
  9. # Provides:          boot.cleanup
  10. # Required-Start:    boot.rootfsck
  11. # Should-Start:      $local_fs boot.quota
  12. # Required-Stop:     $null
  13. # Should-Stop:       $null
  14. # Default-Start:     B
  15. # Default-Stop:
  16. # Short-Description: do cleanup
  17. # Description: Cleanup left over tempfiles from 
  18. #    last run: screen sockets, temporary rpm-database files,
  19. #    ssh agent infos, various lockfiles, utmp and some more.
  20. ### END INIT INFO
  21.  
  22. . /etc/rc.status
  23. . /etc/sysconfig/cron
  24.  
  25. rc_reset
  26.  
  27. case "$1" in
  28.   start)
  29.     #
  30.     # clean up
  31.     #
  32.     rm -f /var/lib/rpm/__db* 2>/dev/null
  33.     rm -rf /tmp/screens /tmp/uscreens /var/run/screens /var/run/uscreens 2>/dev/null
  34.     rm -f /tmp/.X*lock /var/spool/uucp/LCK* /var/log/sa/sadc.LOCK /fsck_corrected_errors 2>/dev/null
  35.     if test -x /usr/bin/find; then
  36.         find /tmp/ssh-* /tmp/gpg-* -type s -name "*agent*" -maxdepth 1 -exec rm -f {} + 2>/dev/null
  37.         find /var/run /var/lock -type f ! -wholename /var/run/utmp -exec rm -f {} + 2>/dev/null
  38.         if test -d /var/lib/ntp/var/run; then
  39.         find /var/lib/ntp/var/run -type f -exec rm -f {} + 2>/dev/null
  40.         fi
  41.     else
  42.         # fallback for find if we get /usr from nfs
  43.         rec_rem() {
  44.         for f in "$1"/*
  45.         do
  46.         test "$f" = /var/run/utmp && continue
  47.         test -L "$f" && continue
  48.         test -f "$f" && rm -f "$f"
  49.         test -d "$f" && rec_rem "$f"
  50.         done
  51.         }
  52.         #
  53.         test -d /var/run && rec_rem /var/run
  54.         test -d /var/lock && rec_rem /var/lock
  55.     fi
  56.     touch /var/run/utmp
  57.     chmod 664 /var/run/utmp
  58.     chown root:tty /var/run/utmp
  59.  
  60.     # Re-read inittab for jobs and redo utmp records if required
  61.     test "$PREVLEVEL" = "S" && telinit q
  62.  
  63.     # Restore a possibly dynamically modified /etc/resolv.conf
  64.     /sbin/netconfig update
  65.  
  66.     # delete temp files
  67.     # If $CLEAR_TMP_DIRS_AT_BOOTUP = yes, delete files in
  68.     # $TMP_DIRS_TO_CLEAR, if $CLEAR_TMP_DIRS_AT_BOOTUP starts with a "/"
  69.     # delete files in those dirs instead.
  70.     CLEAR_DIRS="$TMP_DIRS_TO_CLEAR"
  71.     if [ "${CLEAR_TMP_DIRS_AT_BOOTUP:0:1}" = "/" ]; then
  72.       CLEAR_DIRS="$CLEAR_TMP_DIRS_AT_BOOTUP"
  73.       CLEAR_TMP_DIRS_AT_BOOTUP=yes
  74.     fi
  75.     if test -x /usr/bin/find; then
  76.         if test "$CLEAR_TMP_DIRS_AT_BOOTUP" = yes; then
  77.         echo -n "Cleaning temporary directories $CLEAR_DIRS"
  78.         for CURDIR in $CLEAR_DIRS ; do
  79.             find $CURDIR -maxdepth 1 -exec rm -rf {} +
  80.         done
  81.         rc_status -v -r
  82.         fi
  83.     fi
  84.     for CURDIR in /tmp /tmp/.X11-unix /tmp/.ICE-unix \
  85.               /var/tmp /var/tmp/vi.recover /var/run/uscreens ; do
  86.         test -d $CURDIR || \
  87.         mkdir $CURDIR && \
  88.         chown root:root $CURDIR && \
  89.         chmod 1777 $CURDIR
  90.     done
  91.     for CURDIR in /var/run/screens ; do
  92.         test -d $CURDIR || \
  93.         mkdir $CURDIR && \
  94.         chown root:root $CURDIR && \
  95.         chmod 755 $CURDIR
  96.     done
  97.     ;;
  98.     stop|restart)
  99.         # skip / nothing to do
  100.     ;;
  101.     status)
  102.     # assume we have been run
  103.     rc_reset
  104.     rc_status -v
  105.     ;;
  106.     *)
  107.     echo "Usage: $0 {start|stop|status|restart}"
  108.     exit 1
  109.     ;;
  110. esac
  111.  
  112. rc_exit
  113.