Files
Arquivotheca.Solaris-2.5/cmd/initpkg/init.d/RMTMPFILES
seta75D 7c4988eac0 Init
2021-10-11 19:38:01 -03:00

79 lines
2.1 KiB
Plaintext
Executable File

#ident "@(#)RMTMPFILES 1.16 95/02/24 SMI" /* SVr4.0 1.1.4.2 */
# Clean up temporary files.
set `/usr/bin/who -r`
if [ $9 != "S" -a $9 != "1" ]
then
exit
fi
# Traditional SunOS 4.x behavior has been to not remove directories in
# the /tmp directory; only simple files were removed. This lead to an
# inconsistency when the tmpfs file system was used (which isn't persistent
# across boots. The following adopts the traditional System V behavior
# of removing everything in /tmp.
# clean up /tmp
# if /tmp or any of its subdirectories are mount points do not remove /tmp
M=`/sbin/mount | /usr/bin/egrep '^/tmp(/| )' | /usr/bin/wc -l`
if [ $M -eq 0 ]
then
# just remove files under directory if symbolic link
if [ -h /tmp ]
then
/usr/bin/rm -rf /tmp/*
else
/usr/bin/rm -rf /tmp
/usr/bin/mkdir /tmp
/usr/bin/chmod 1777 /tmp
/usr/bin/chgrp sys /tmp
/usr/bin/chown sys /tmp
fi
fi
# Clean up /etc directory
# The file /etc/rem_name_to_major is not valid across boots
# so must be removed.
if [ -f /etc/rem_name_to_major ]
then
/usr/bin/rm -f /etc/rem_name_to_major
fi
# The file /etc/nologin will disable all login processes
# so must be removed.
if [ -f /etc/nologin ]
then
/usr/bin/rm -f /etc/nologin
fi
# Traditional SunOS 4.x behavior has been to not alter the contents of
# /var/tmp (/usr/tmp) at boot time. This behavior is maintained as the
# current default behavior. It the traditional System V behavior of
# removing everything in /var/tmp is desired, remove the following
# 'exit'.
exit
# clean up /var/tmp
# if /var/tmp or any of its subdirectories
# is a mount point do not remove it.
M=`/sbin/mount | /usr/bin/egrep '^/var/tmp(/| )' | /usr/bin/wc -l`
if [ $M -eq 0 ]
then
cd /var/tmp || exit 0
# We carefully remove all files except the Ex* files (editor
# temporary files), which expreserve will process later (in
# S80PRESERVE). Of course, it would be simpler to just run
# expreserve before this script, but that doesn't work --
# expreserve requires the name service, which is not available
# until much later.
/usr/bin/ls -a | /usr/bin/egrep -v '^(Ex.*|\.|\.\.)$' |
/usr/bin/xargs /usr/bin/rm -rf -- 2> /dev/null
fi