/[baselayout]/trunk/init.d/bootmisc
Gentoo

Contents of /trunk/init.d/bootmisc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2756 - (show annotations) (download)
Mon Jul 9 10:39:35 2007 UTC (6 years, 9 months ago) by uberlord
File size: 4030 byte(s)
Take no chances with PATH, use our env-update
1 #!/sbin/runscript
2 # Copyright 1999-2007 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 depend() {
6 use hostname
7 need localmount
8 before logger
9 after clock sysctl
10 }
11
12 start() {
13 # Put a nologin file in /etc to prevent people from logging
14 # in before system startup is complete.
15 if [ "${DELAYLOGIN}" = "yes" ] ; then
16 echo "System bootup in progress - please wait" \
17 > /etc/nologin
18 cp /etc/nologin /etc/nologin.boot
19 fi
20
21 if [ -e /etc/sysctl.conf -a ! -x /etc/init.d/sysctl ] ; then
22 if [ "${RC_SYS}" != "VPS" ] ; then
23 ebegin "Configuring kernel parameters"
24 sysctl -p /etc/sysctl.conf >/dev/null
25 eend $?
26 fi
27 fi
28
29 if ! touch -c /var/run 2> /dev/null ; then
30 ewarn "Skipping /var and /tmp initialization (ro root?)"
31 return 0
32 fi
33
34 if [ "${RC_UNAME}" = "Linux" ] ; then
35 # Setup login records
36 > /var/run/utmp
37 touch /var/log/wtmp
38 chgrp utmp /var/run/utmp /var/log/wtmp
39 chmod 0664 /var/run/utmp /var/log/wtmp
40 fi
41
42 ebegin "Updating environment"
43 # Use our version, not portage version.
44 /sbin/env-update --fork-ldconfig
45 eend $?
46
47 # Take care of random stuff [ /var/lock | /var/run | pam ]
48 ebegin "Cleaning" /var/lock, /var/run
49 rm -rf /var/run/console.lock /var/run/console/*
50
51 # Clean up any stale locks.
52 find /var/lock -type f -print0 | xargs -0 rm -f --
53
54 # Clean up /var/run and create /var/run/utmp so we can login.
55 for x in $(find /var/run ! -type d ! -name utmp ! -name innd.pid ! -name random-seed ! -name ld-elf.so.hints); do
56 [ ! -f "${x}" ] && continue
57 # Do not remove pidfiles of already running daemons
58 case "${x}" in
59 *.pid)
60 start-stop-daemon --test --quiet --stop --pidfile "${x}"
61 [ $? -eq 0 ] && continue
62 ;;
63 esac
64 rm -f "${x}"
65 done
66
67 # Reset pam_console permissions if we are actually using it
68 if [ -x /sbin/pam_console_apply -a ! -c /dev/.devfsd ] ; then
69 if [ -n $(grep -v -e '^[[:space:]]*#' /etc/pam.d/* | grep 'pam_console') ] ; then
70 /sbin/pam_console_apply -r
71 fi
72 fi
73
74 # Create the .keep to stop portage from removing /var/lock
75 > /var/lock/.keep
76 eend 0
77
78 # Clean up /tmp directory
79 if [ -d /tmp ] ; then
80 cd /tmp
81 if [ "${WIPE_TMP}" = "yes" ] ; then
82 ebegin "Wiping /tmp directory"
83 local startopts="-x . -depth"
84 [ "${RC_UNAME}" = "Linux" ] && startopts=". -xdev -depth"
85
86 # Faster than find
87 rm -rf [b-ikm-pr-zA-Z]*
88
89 find ${startopts} ! -name . \
90 ! -path ./lost+found \
91 ! -path "./lost+found/*" \
92 ! -path ./quota.user \
93 ! -path "./quota.user/*" \
94 ! -path ./aquota.user \
95 ! -path "./aquota.user/*" \
96 ! -path ./quota.group \
97 ! -path "./quota.group/*" \
98 ! -path ./aquota.group \
99 ! -path "./aquota.group/*" \
100 ! -path ./journal \
101 ! -path "./journal/*" \
102 -delete
103 eend 0
104 else
105 ebegin "Cleaning /tmp directory"
106 rm -rf /tmp/.X*-lock /tmp/esrv* /tmp/kio* /tmp/jpsock.* \
107 /tmp/.fam* /tmp/.esd* /tmp/orbit-* /tmp/ssh-* \
108 /tmp/ksocket-* /tmp/.*-unix
109 eend 0
110 fi
111
112 # Make sure our X11 stuff have the correct permissions
113 # Omit the chown as bootmisc is run before network is up
114 # and users may be using lame LDAP auth #139411
115 rm -rf /tmp/.ICE-unix /tmp/.X11-unix
116 mkdir -p /tmp/.ICE-unix /tmp/.X11-unix
117 chmod 1777 /tmp/.ICE-unix /tmp/.X11-unix
118 [ -x /sbin/restorecon ] && restorecon /tmp/.ICE-unix /tmp/.X11-unix
119 fi
120
121 # Create an 'after-boot' dmesg log
122 if [ "${RC_SYS}" != "VPS" ] ; then
123 touch /var/log/dmesg
124 chmod 640 /var/log/dmesg
125 dmesg > /var/log/dmesg
126 fi
127
128 # Check for /etc/resolv.conf, and create if missing
129 [ -f /etc/resolv.conf ] || touch /etc/resolv.conf 2>/dev/null
130 }
131
132 stop() {
133 # Reset pam_console permissions if we are actually using it
134 if [ -x /sbin/pam_console_apply -a ! -c /dev/.devfsd ] && \
135 [ -n $(grep -v -e '^[[:space:]]*#' /etc/pam.d/* | grep 'pam_console') ] ; then
136 /sbin/pam_console_apply -r
137 fi
138
139 # Write a halt record if we're shutting down
140 case "${SOFTLEVEL}" in
141 reboot|shutdown)
142 [ "${RC_UNAME}" = "Linux" ] && halt -w
143 ;;
144 esac
145
146 return 0
147 }
148
149 # vim: set ts=4 :

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20