2007-04-05 16:48:42 +05:30
|
|
|
#!/sbin/runscript
|
2008-01-11 21:01:10 +05:30
|
|
|
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
|
|
|
# All rights reserved. Released under the 2-clause BSD license.
|
2007-11-14 20:52:04 +05:30
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
depend()
|
|
|
|
{
|
2007-04-05 16:48:42 +05:30
|
|
|
use hostname
|
|
|
|
need localmount
|
|
|
|
before logger
|
|
|
|
after clock sysctl
|
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
cleanup_tmp_dir()
|
|
|
|
{
|
2007-09-09 21:22:05 +05:30
|
|
|
local dir=$1
|
|
|
|
|
2007-09-24 20:57:06 +05:30
|
|
|
mkdir -p "${dir}"
|
|
|
|
cd "${dir}"
|
2007-12-09 19:19:20 +05:30
|
|
|
if yesno ${wipe_tmp:-${WIPE_TMP:-yes}}; then
|
2007-09-09 21:22:05 +05:30
|
|
|
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/*" \
|
2008-01-11 04:52:46 +05:30
|
|
|
-exec rm -rf -- {} \; \
|
|
|
|
-type d -prune
|
2007-09-09 21:22:05 +05:30
|
|
|
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* \
|
2007-10-23 15:35:47 +05:30
|
|
|
"${dir}"/orbit-* "${dir}"/ssh-* "${dir}"/ksocket-* \
|
2007-09-24 20:57:06 +05:30
|
|
|
"${dir}"/.*-unix
|
2007-09-09 21:22:05 +05:30
|
|
|
eend 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
start()
|
|
|
|
{
|
2007-10-27 15:23:56 +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-11-20 17:50:50 +05:30
|
|
|
for x in /var/log /var/run /tmp; do
|
2007-10-27 15:23:56 +05:30
|
|
|
if ! [ -d "${x}" ]; then
|
2007-11-20 17:50:50 +05:30
|
|
|
if ! mkdir -p "${x}"; then
|
2007-07-30 17:01:29 +05:30
|
|
|
eend 1 "failed to create needed directory ${x}"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-11-20 18:25:56 +05:30
|
|
|
ebegin "Creating user login records"
|
2007-12-14 19:42:38 +05:30
|
|
|
cp /dev/null /var/run/utmp
|
|
|
|
[ -e /var/log/wtmp ] || cp /dev/null /var/log/wtmp
|
2007-11-20 18:25:56 +05:30
|
|
|
chmod 0644 /var/run/utmp /var/log/wtmp
|
|
|
|
eend 0
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-11-20 17:50:50 +05:30
|
|
|
ebegin "Cleaning /var/run"
|
2007-07-26 02:28:23 +05:30
|
|
|
for x in $(find /var/run ! -type d ! -name utmp ! -name innd.pid \
|
2008-01-11 17:43:46 +05:30
|
|
|
! -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)
|
2008-01-11 17:43:46 +05:30
|
|
|
start-stop-daemon --test --quiet --stop \
|
|
|
|
--pidfile "${x}"
|
2007-04-05 16:48:42 +05:30
|
|
|
[ $? -eq 0 ] && continue
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
rm -f "${x}"
|
|
|
|
done
|
|
|
|
eend 0
|
|
|
|
|
2007-09-09 21:22:05 +05:30
|
|
|
# Clean up /tmp directories
|
2007-11-20 17:50:50 +05:30
|
|
|
local tmp=
|
2007-11-23 17:34:11 +05:30
|
|
|
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-10-27 15:23:56 +05:30
|
|
|
if [ "${RC_SYS}" != "VPS" ]; then
|
2007-04-26 19:52:54 +05:30
|
|
|
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
|
2008-01-11 04:52:46 +05:30
|
|
|
|
|
|
|
rm -f /etc/nologin
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
stop()
|
|
|
|
{
|
2007-04-05 16:48:42 +05:30
|
|
|
# Write a halt record if we're shutting down
|
2007-07-26 22:00:05 +05:30
|
|
|
case "${RC_SOFTLEVEL}" in
|
2007-10-27 15:23:56 +05:30
|
|
|
reboot|shutdown) [ "${RC_UNAME}" = "Linux" ] && halt -w;;
|
2007-04-05 16:48:42 +05:30
|
|
|
esac
|
2007-11-20 18:25:56 +05:30
|
|
|
|
2007-04-05 16:48:42 +05:30
|
|
|
return 0
|
|
|
|
}
|