Create needed dirs in bootmisc if they do not exist

This commit is contained in:
Roy Marples 2007-07-30 11:31:29 +00:00
parent 380b7f917d
commit 02fcdeede4

View File

@ -26,11 +26,21 @@ start() {
fi fi
fi fi
if ! echo 2>/dev/null >/var/run/.test.$$ ; then if ! echo 2>/dev/null >/.test.$$ ; then
ewarn "Skipping /var and /tmp initialization (ro root?)" ewarn "Skipping /var and /tmp initialization (ro root?)"
return 0 return 0
fi fi
rm -f /var/run/.test.$$ rm -f /.test.$$
# Ensure that our basic dirs exist
for x in /var/lock /var/run /tmp ; do
if ! [ -d "${x}" ] ; then
if ! mkdir "${x}" ; then
eend 1 "failed to create needed directory ${x}"
return 1
fi
fi
done
if [ "${RC_UNAME}" = "Linux" ] ; then if [ "${RC_UNAME}" = "Linux" ] ; then
# Setup login records # Setup login records
@ -46,7 +56,7 @@ start() {
eend $? eend $?
# Take care of random stuff [ /var/lock | /var/run | pam ] # Take care of random stuff [ /var/lock | /var/run | pam ]
ebegin "Cleaning" /var/lock, /var/run ebegin "Cleaning /var/lock, /var/run"
rm -rf /var/run/console.lock /var/run/console/* rm -rf /var/run/console.lock /var/run/console/*
# Clean up any stale locks. # Clean up any stale locks.
@ -78,48 +88,46 @@ start() {
eend 0 eend 0
# Clean up /tmp directory # Clean up /tmp directory
if [ -d /tmp ] ; then cd /tmp
cd /tmp if [ "${WIPE_TMP}" = "yes" ] ; then
if [ "${WIPE_TMP}" = "yes" ] ; then ebegin "Wiping /tmp directory"
ebegin "Wiping /tmp directory" local startopts="-x . -depth"
local startopts="-x . -depth" [ "${RC_UNAME}" = "Linux" ] && startopts=". -xdev -depth"
[ "${RC_UNAME}" = "Linux" ] && startopts=". -xdev -depth"
# Faster than find # Faster than find
rm -rf [b-ikm-pr-zA-Z]* rm -rf [b-ikm-pr-zA-Z]*
find ${startopts} ! -name . \ find ${startopts} ! -name . \
! -path ./lost+found \ ! -path ./lost+found \
! -path "./lost+found/*" \ ! -path "./lost+found/*" \
! -path ./quota.user \ ! -path ./quota.user \
! -path "./quota.user/*" \ ! -path "./quota.user/*" \
! -path ./aquota.user \ ! -path ./aquota.user \
! -path "./aquota.user/*" \ ! -path "./aquota.user/*" \
! -path ./quota.group \ ! -path ./quota.group \
! -path "./quota.group/*" \ ! -path "./quota.group/*" \
! -path ./aquota.group \ ! -path ./aquota.group \
! -path "./aquota.group/*" \ ! -path "./aquota.group/*" \
! -path ./journal \ ! -path ./journal \
! -path "./journal/*" \ ! -path "./journal/*" \
-delete -delete
eend 0 eend 0
else else
ebegin "Cleaning /tmp directory" ebegin "Cleaning /tmp directory"
rm -rf /tmp/.X*-lock /tmp/esrv* /tmp/kio* /tmp/jpsock.* \ rm -rf /tmp/.X*-lock /tmp/esrv* /tmp/kio* /tmp/jpsock.* \
/tmp/.fam* /tmp/.esd* /tmp/orbit-* /tmp/ssh-* \ /tmp/.fam* /tmp/.esd* /tmp/orbit-* /tmp/ssh-* \
/tmp/ksocket-* /tmp/.*-unix /tmp/ksocket-* /tmp/.*-unix
eend 0 eend 0
fi
# Make sure our X11 stuff have the correct permissions
# Omit the chown as bootmisc is run before network is up
# and users may be using lame LDAP auth #139411
rm -rf /tmp/.ICE-unix /tmp/.X11-unix
mkdir -p /tmp/.ICE-unix /tmp/.X11-unix
chmod 1777 /tmp/.ICE-unix /tmp/.X11-unix
[ -x /sbin/restorecon ] && restorecon /tmp/.ICE-unix /tmp/.X11-unix
fi fi
# Make sure our X11 stuff have the correct permissions
# Omit the chown as bootmisc is run before network is up
# and users may be using lame LDAP auth #139411
rm -rf /tmp/.ICE-unix /tmp/.X11-unix
mkdir -p /tmp/.ICE-unix /tmp/.X11-unix
chmod 1777 /tmp/.ICE-unix /tmp/.X11-unix
[ -x /sbin/restorecon ] && restorecon /tmp/.ICE-unix /tmp/.X11-unix
# Create an 'after-boot' dmesg log # Create an 'after-boot' dmesg log
if [ "${RC_SYS}" != "VPS" ] ; then if [ "${RC_SYS}" != "VPS" ] ; then
dmesg > /var/log/dmesg dmesg > /var/log/dmesg