ACC SHELL
Path : /etc/rc.d/ |
|
Current File : //etc/rc.d/boot.cleanup |
#! /bin/sh
#
# Copyright (c) 2001-2005 SuSE Linux AG, Nuernberg, Germany.
# All rights reserved.
#
# /etc/init.d/boot.cleanup
#
### BEGIN INIT INFO
# Provides: boot.cleanup
# Required-Start: boot.rootfsck
# Should-Start: $local_fs boot.quota
# Required-Stop: $null
# Should-Stop: $null
# Default-Start: B
# Default-Stop:
# Short-Description: do cleanup
# Description: Cleanup left over tempfiles from
# last run: screen sockets, temporary rpm-database files,
# ssh agent infos, various lockfiles, utmp and some more.
### END INIT INFO
. /etc/rc.status
. /etc/sysconfig/cron
rc_reset
case "$1" in
start|stop|restart)
if test "$1" = "start" -o "$RUNLEVEL" = "6" ; then
#
# clean up
#
rm -f /var/lib/rpm/__db*
rm -rf /tmp/screens /tmp/uscreens /var/run/screens /var/run/uscreens 2>/dev/null
rm -f /tmp/.X*lock /var/spool/uucp/LCK* /var/log/sa/sadc.LOCK /fsck_corrected_errors 2>/dev/null
if test -x /usr/bin/find -a -x /usr/bin/xargs; then
{
find /tmp/ssh-* /tmp/gpg-* -type s -name "*agent*" -maxdepth 1 -print0
find /var/run /var/lock -type f ! -wholename /var/run/utmp -print0
if test -d /var/lib/ntp/var/run; then
find /var/lib/ntp/var/run -type f -print0
fi
} 2>/dev/null | xargs -0r rm -f
else
# fallback for find if we get /usr from nfs
rec_rem() {
for f in "$1"/*
do
test "$f" = /var/run/utmp && continue
test -L "$f" && continue
test -f "$f" && rm -f "$f"
test -d "$f" && rec_rem "$f"
done
}
#
test -d /var/run && rec_rem /var/run
test -d /var/lock && rec_rem /var/lock
fi
touch /var/run/utmp
chmod 664 /var/run/utmp
chown root:tty /var/run/utmp
# Re-read inittab for jobs and redo utmp records if required
test "$PREVLEVEL" = "S" && telinit q
# FASTBOOT: This costs us ~1s, and could be done by a simple "mv"
# if at all necessary.
#
# # Restore a possibly dynamically modified /etc/resolv.conf
test "$DO_FASTBOOT" != "yes" && /sbin/netconfig update
# delete temp files
# If $CLEAR_TMP_DIRS_AT_BOOTUP = yes, delete files in
# $TMP_DIRS_TO_CLEAR, if $CLEAR_TMP_DIRS_AT_BOOTUP starts with a "/"
# delete files in those dirs instead.
CLEAR_DIRS="$TMP_DIRS_TO_CLEAR"
if [ "${CLEAR_TMP_DIRS_AT_BOOTUP:0:1}" = "/" ]; then
CLEAR_DIRS="$CLEAR_TMP_DIRS_AT_BOOTUP"
CLEAR_TMP_DIRS_AT_BOOTUP=yes
fi
if test -x /usr/bin/find -a -x /usr/bin/xargs ; then
if test "$CLEAR_TMP_DIRS_AT_BOOTUP" = yes; then
echo -n "Cleaning temporary directories $CLEAR_DIRS"
find $CLEAR_DIRS -mindepth 1 -maxdepth 1 -print0 2>/dev/null | xargs -0r rm -rf
rc_status -v -r
fi
fi
for script in /etc/tmpdirs.d/* ; do
test -f $script && builtin . $script
done
fi
;;
status)
# assume we have been run
rc_reset
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
rc_exit
ACC SHELL 2018