2008-03-03 02:44:01 +05:30
|
|
|
#!@PREFIX@/sbin/runscript
|
2009-04-17 05:09:37 +05:30
|
|
|
# Copyright 2007-2009 Roy Marples <roy@marples.name>
|
2008-01-11 21:01:10 +05:30
|
|
|
# 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-03-03 02:43:21 +05:30
|
|
|
keyword noprefix
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2008-04-09 04:55:48 +05:30
|
|
|
dir_writeable()
|
|
|
|
{
|
|
|
|
mkdir "$1"/.test.$$ 2>/dev/null && rmdir "$1"/.test.$$
|
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
cleanup_tmp_dir()
|
|
|
|
{
|
2008-04-09 05:36:50 +05:30
|
|
|
local dir="$1"
|
2007-09-09 21:22:05 +05:30
|
|
|
|
2008-04-09 04:55:48 +05:30
|
|
|
if ! [ -d "${dir}" ]; then
|
|
|
|
mkdir -p "${dir}" || return $?
|
|
|
|
fi
|
|
|
|
dir_writeable "${dir}" || return 1
|
2008-04-09 05:36:50 +05:30
|
|
|
chmod +t "${dir}"
|
2007-09-24 20:57:06 +05:30
|
|
|
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"
|
2008-04-30 22:14:29 +05:30
|
|
|
local startopts="-x . -depth"
|
2009-02-10 20:36:48 +05:30
|
|
|
[ "${RC_UNAME}" = Linux ] && startopts=". -xdev -depth"
|
2007-09-09 21:22:05 +05:30
|
|
|
|
|
|
|
# Faster than find
|
2009-04-12 18:29:00 +05:30
|
|
|
rm -rf -- [^ajlq\.]*
|
2007-09-09 21:22:05 +05:30
|
|
|
|
|
|
|
find ${startopts} ! -name . \
|
2008-03-18 13:49:29 +05:30
|
|
|
! -path "./lost+found" \
|
2007-09-09 21:22:05 +05:30
|
|
|
! -path "./lost+found/*" \
|
2008-03-18 13:49:29 +05:30
|
|
|
! -path "./quota.user" \
|
2007-09-09 21:22:05 +05:30
|
|
|
! -path "./quota.user/*" \
|
2008-03-18 13:49:29 +05:30
|
|
|
! -path "./aquota.user" \
|
2007-09-09 21:22:05 +05:30
|
|
|
! -path "./aquota.user/*" \
|
2008-03-18 13:49:29 +05:30
|
|
|
! -path "./quota.group" \
|
2007-09-09 21:22:05 +05:30
|
|
|
! -path "./quota.group/*" \
|
2008-03-18 13:49:29 +05:30
|
|
|
! -path "./aquota.group" \
|
2007-09-09 21:22:05 +05:30
|
|
|
! -path "./aquota.group/*" \
|
2008-03-18 13:49:29 +05:30
|
|
|
! -path "./journal" \
|
2007-09-09 21:22:05 +05:30
|
|
|
! -path "./journal/*" \
|
2008-03-18 13:49:29 +05:30
|
|
|
! -path "./.private" \
|
|
|
|
! -path "./.private/*" \
|
2008-04-30 22:14:29 +05:30
|
|
|
-exec rm -rf {} \;
|
2007-09-09 21:22:05 +05:30
|
|
|
eend 0
|
|
|
|
else
|
|
|
|
ebegin "Cleaning ${dir} directory"
|
2008-01-25 18:03:53 +05:30
|
|
|
rm -rf -- "${dir}"/.X*-lock "${dir}"/esrv* "${dir}"/kio* \
|
2007-09-24 20:57:06 +05:30
|
|
|
"${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
|
|
|
|
}
|
|
|
|
|
2009-04-17 05:09:37 +05:30
|
|
|
mkutmp()
|
|
|
|
{
|
|
|
|
: >"$1"
|
2009-04-18 06:26:48 +05:30
|
|
|
# Not all systems have the utmp group
|
|
|
|
chgrp utmp "$1" 2>/dev/null
|
2009-04-17 05:09:37 +05:30
|
|
|
chmod 0664 "$1"
|
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
start()
|
|
|
|
{
|
2009-04-17 05:09:37 +05:30
|
|
|
local logw=false runw=false
|
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
|
|
|
|
2008-04-09 04:55:48 +05:30
|
|
|
if dir_writeable /var/run; then
|
|
|
|
ebegin "Creating user login records"
|
2009-04-17 05:09:37 +05:30
|
|
|
local xtra=
|
2009-04-17 15:18:34 +05:30
|
|
|
[ "${RC_UNAME}" = NetBSD ] && xtra=x
|
2009-04-17 05:09:37 +05:30
|
|
|
for x in "" $xtra; do
|
|
|
|
mkutmp /var/run/utmp${x}
|
|
|
|
done
|
|
|
|
[ -e /var/log/wtmp ] && mkutmp /var/log/wtmp
|
2008-04-09 04:55:48 +05:30
|
|
|
eend 0
|
|
|
|
|
|
|
|
ebegin "Cleaning /var/run"
|
|
|
|
for x in $(find /var/run ! -type d ! -name utmp \
|
2008-05-12 20:41:04 +05:30
|
|
|
! -name random-seed ! -name dev.db \
|
2008-04-09 04:55:48 +05:30
|
|
|
! -name ld-elf.so.hints ! -name ld.so.hints);
|
2008-10-02 02:42:54 +05:30
|
|
|
do
|
|
|
|
# Clean stale sockets
|
2008-10-15 14:05:21 +05:30
|
|
|
if [ -S "${x}" ]; then
|
|
|
|
if type fuser >/dev/null 2>&1; then
|
|
|
|
fuser "${x}" 2>/dev/null || rm "${x}"
|
|
|
|
else
|
|
|
|
rm "${x}"
|
|
|
|
fi
|
2008-10-02 02:42:54 +05:30
|
|
|
fi
|
2008-04-09 04:55:48 +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}" && continue
|
2007-04-05 16:48:42 +05:30
|
|
|
;;
|
2008-04-09 04:55:48 +05:30
|
|
|
esac
|
|
|
|
rm -f -- "${x}"
|
|
|
|
done
|
|
|
|
eend 0
|
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-09-09 21:22:05 +05:30
|
|
|
# Clean up /tmp directories
|
2007-11-20 17:50:50 +05:30
|
|
|
local tmp=
|
2009-02-23 15:06:48 +05:30
|
|
|
for tmp in ${clean_tmp_dirs:-${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
|
|
|
|
2008-04-09 04:55:48 +05:30
|
|
|
if dir_writeable /tmp; then
|
|
|
|
# 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
|
|
|
|
|
|
|
|
if ${logw} || dir_writeable /var/log; then
|
|
|
|
# Create an 'after-boot' dmesg log
|
2009-02-10 20:36:48 +05:30
|
|
|
if [ "${RC_SYS}" != VSERVER -a "${RC_SYS}" != OPENVZ ]; then
|
2008-04-09 04:55:48 +05:30
|
|
|
dmesg > /var/log/dmesg
|
|
|
|
chmod 640 /var/log/dmesg
|
|
|
|
fi
|
2007-04-26 19:52:54 +05:30
|
|
|
fi
|
2008-01-11 04:52:46 +05:30
|
|
|
|
|
|
|
rm -f /etc/nologin
|
2008-04-09 05:36:50 +05:30
|
|
|
return 0
|
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
|
2009-02-10 20:36:48 +05:30
|
|
|
if [ "${RC_RUNLEVEL}" = shutdown ]; then
|
|
|
|
[ "${RC_UNAME}" = Linux ] && halt -w
|
2009-02-10 20:46:25 +05:30
|
|
|
if [ "${RC_SYS}" = OPENVZ ]; then
|
|
|
|
yesno ${RC_REBOOT} && printf "" >/reboot
|
|
|
|
fi
|
2009-02-10 20:36:48 +05:30
|
|
|
fi
|
2007-11-20 18:25:56 +05:30
|
|
|
|
2007-04-05 16:48:42 +05:30
|
|
|
return 0
|
|
|
|
}
|