2007-04-05 16:48:42 +05:30
|
|
|
#!/sbin/runscript
|
|
|
|
# Copyright 1999-2007 Gentoo Foundation
|
|
|
|
# Distributed under the terms of the GNU General Public License v2
|
|
|
|
|
|
|
|
depend() {
|
|
|
|
use hostname
|
|
|
|
need localmount
|
|
|
|
before logger
|
|
|
|
after clock sysctl
|
|
|
|
}
|
|
|
|
|
2007-09-09 21:22:05 +05:30
|
|
|
cleanup_tmp_dir() {
|
|
|
|
local dir=$1
|
|
|
|
|
2007-09-24 20:57:06 +05:30
|
|
|
mkdir -p "${dir}"
|
|
|
|
cd "${dir}"
|
2007-09-09 21:22:05 +05:30
|
|
|
if [ "${WIPE_TMP}" = "yes" ] ; then
|
|
|
|
ebegin "Wiping ${dir} directory"
|
|
|
|
local startopts="-x . -depth"
|
|
|
|
[ "${RC_UNAME}" = "Linux" ] && startopts=". -xdev -depth"
|
|
|
|
|
|
|
|
# Faster than find
|
|
|
|
rm -rf [b-ikm-pr-zA-Z]*
|
|
|
|
|
|
|
|
find ${startopts} ! -name . \
|
|
|
|
! -path ./lost+found \
|
|
|
|
! -path "./lost+found/*" \
|
|
|
|
! -path ./quota.user \
|
|
|
|
! -path "./quota.user/*" \
|
|
|
|
! -path ./aquota.user \
|
|
|
|
! -path "./aquota.user/*" \
|
|
|
|
! -path ./quota.group \
|
|
|
|
! -path "./quota.group/*" \
|
|
|
|
! -path ./aquota.group \
|
|
|
|
! -path "./aquota.group/*" \
|
|
|
|
! -path ./journal \
|
|
|
|
! -path "./journal/*" \
|
|
|
|
-delete
|
|
|
|
eend 0
|
|
|
|
else
|
|
|
|
ebegin "Cleaning ${dir} directory"
|
2007-09-24 20:57:06 +05:30
|
|
|
rm -rf "${dir}"/.X*-lock "${dir}"/esrv* "${dir}"/kio* \
|
|
|
|
"${dir}"/jpsock.* "${dir}"/.fam* "${dir}"/.esd* \
|
|
|
|
"${dir}"/orbit-* "${dir}"/ssh-* "${dir}"/ksocket-*
|
|
|
|
"${dir}"/.*-unix
|
2007-09-09 21:22:05 +05:30
|
|
|
eend 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2007-04-05 16:48:42 +05:30
|
|
|
start() {
|
|
|
|
# Put a nologin file in /etc to prevent people from logging
|
|
|
|
# in before system startup is complete.
|
|
|
|
if [ "${DELAYLOGIN}" = "yes" ] ; then
|
2007-09-24 20:57:06 +05:30
|
|
|
echo "System bootup in progress - please wait" > /etc/nologin
|
2007-04-05 16:48:42 +05:30
|
|
|
cp /etc/nologin /etc/nologin.boot
|
|
|
|
fi
|
|
|
|
|
2007-04-10 16:20:07 +05:30
|
|
|
if [ -e /etc/sysctl.conf -a ! -x /etc/init.d/sysctl ] ; then
|
2007-04-26 19:47:15 +05:30
|
|
|
if [ "${RC_SYS}" != "VPS" ] ; then
|
|
|
|
ebegin "Configuring kernel parameters"
|
2007-05-16 20:23:47 +05:30
|
|
|
sysctl -p /etc/sysctl.conf >/dev/null
|
2007-04-26 19:47:15 +05:30
|
|
|
eend $?
|
|
|
|
fi
|
2007-04-10 16:20:07 +05:30
|
|
|
fi
|
|
|
|
|
2007-09-24 20:57:06 +05:30
|
|
|
if ! mkdir /.test.$$ 2>/dev/null ; then
|
2007-04-05 16:48:42 +05:30
|
|
|
ewarn "Skipping /var and /tmp initialization (ro root?)"
|
|
|
|
return 0
|
|
|
|
fi
|
2007-09-24 20:57:06 +05:30
|
|
|
rmdir /.test.$$
|
2007-07-30 17:01:29 +05:30
|
|
|
|
|
|
|
# Ensure that our basic dirs exist
|
2007-08-02 14:11:31 +05:30
|
|
|
for x in /var/lock /var/log /var/run /tmp ; do
|
2007-07-30 17:01:29 +05:30
|
|
|
if ! [ -d "${x}" ] ; then
|
|
|
|
if ! mkdir "${x}" ; then
|
|
|
|
eend 1 "failed to create needed directory ${x}"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-08-23 15:55:09 +05:30
|
|
|
# Setup login records
|
|
|
|
printf "" >/var/run/utmp
|
|
|
|
[ -e /var/log/wtmp ] || printf "" >/var/log/wtmp
|
|
|
|
chgrp utmp /var/run/utmp /var/log/wtmp
|
|
|
|
chmod 0664 /var/run/utmp /var/log/wtmp
|
2007-04-05 16:48:42 +05:30
|
|
|
|
|
|
|
ebegin "Updating environment"
|
2007-07-09 16:09:35 +05:30
|
|
|
# Use our version, not portage version.
|
|
|
|
/sbin/env-update --fork-ldconfig
|
2007-04-05 16:48:42 +05:30
|
|
|
eend $?
|
|
|
|
|
|
|
|
# Take care of random stuff [ /var/lock | /var/run | pam ]
|
2007-07-30 17:01:29 +05:30
|
|
|
ebegin "Cleaning /var/lock, /var/run"
|
2007-04-05 16:48:42 +05:30
|
|
|
rm -rf /var/run/console.lock /var/run/console/*
|
|
|
|
|
|
|
|
# Clean up any stale locks.
|
|
|
|
find /var/lock -type f -print0 | xargs -0 rm -f --
|
|
|
|
|
|
|
|
# Clean up /var/run and create /var/run/utmp so we can login.
|
2007-07-26 02:28:23 +05:30
|
|
|
for x in $(find /var/run ! -type d ! -name utmp ! -name innd.pid \
|
|
|
|
! -name random-seed ! -name ld-elf.so.hints ! -name ld.so.hints); do
|
2007-04-05 16:48:42 +05:30
|
|
|
[ ! -f "${x}" ] && continue
|
|
|
|
# Do not remove pidfiles of already running daemons
|
|
|
|
case "${x}" in
|
|
|
|
*.pid)
|
|
|
|
start-stop-daemon --test --quiet --stop --pidfile "${x}"
|
|
|
|
[ $? -eq 0 ] && continue
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
rm -f "${x}"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Reset pam_console permissions if we are actually using it
|
2007-07-26 02:28:23 +05:30
|
|
|
if [ -x /sbin/pam_console_apply ] && ! [ -c /dev/.devfsd ] ; then
|
|
|
|
if grep -v -e '^[[:space:]]*#' /etc/pam.d/* | grep -q 'pam_console.so' ; then
|
|
|
|
pam_console_apply -r
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Create the .keep to stop portage from removing /var/lock
|
2007-07-16 22:37:15 +05:30
|
|
|
printf "" >/var/lock/.keep
|
2007-04-05 16:48:42 +05:30
|
|
|
eend 0
|
|
|
|
|
2007-09-09 21:22:05 +05:30
|
|
|
# Clean up /tmp directories
|
|
|
|
local tmp
|
|
|
|
for tmp in ${WIPE_TMP_DIRS-/tmp} ; do
|
2007-09-24 20:57:06 +05:30
|
|
|
cleanup_tmp_dir "${tmp}"
|
2007-09-09 21:22:05 +05:30
|
|
|
done
|
2007-09-09 21:38:32 +05:30
|
|
|
chmod +t /tmp /var/tmp
|
|
|
|
|
|
|
|
# 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
|
2007-07-30 17:01:29 +05:30
|
|
|
|
2007-04-05 16:48:42 +05:30
|
|
|
# Create an 'after-boot' dmesg log
|
2007-04-26 19:52:54 +05:30
|
|
|
if [ "${RC_SYS}" != "VPS" ] ; then
|
|
|
|
dmesg > /var/log/dmesg
|
2007-07-13 05:34:20 +05:30
|
|
|
chmod 640 /var/log/dmesg
|
2007-04-26 19:52:54 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
|
|
|
# Check for /etc/resolv.conf, and create if missing
|
2007-07-16 22:37:15 +05:30
|
|
|
[ -e /etc/resolv.conf ] || printf "" >/etc/resolv.conf
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
# Reset pam_console permissions if we are actually using it
|
2007-07-26 22:00:05 +05:30
|
|
|
if [ -x /sbin/pam_console_apply ] && ! [ -c /dev/.devfsd ] ; then
|
|
|
|
if grep -v -e '^[[:space:]]*#' /etc/pam.d/* | grep -q 'pam_console.so' ; then
|
2007-07-27 11:52:05 +05:30
|
|
|
/sbin/pam_console_apply -r
|
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
|
|
|
|
|
|
|
# Write a halt record if we're shutting down
|
2007-07-26 22:00:05 +05:30
|
|
|
case "${RC_SOFTLEVEL}" in
|
2007-04-05 16:48:42 +05:30
|
|
|
reboot|shutdown)
|
|
|
|
[ "${RC_UNAME}" = "Linux" ] && halt -w
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# vim: set ts=4 :
|