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

Contents of /trunk/init.d/bootmisc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2775 - (show annotations) (download)
Fri Jul 13 00:04:20 2007 UTC (7 years, 4 months ago) by uberlord
File size: 4060 byte(s)
Use echo instead of touch - saves on forking
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 ! echo 2>/dev/null >/var/run/.test.$$ ; then
30 ewarn "Skipping /var and /tmp initialization (ro root?)"
31 return 0
32 fi
33 rm -f /var/run/.test.$$
34
35 if [ "${RC_UNAME}" = "Linux" ] ; then
36 # Setup login records
37 echo > /var/run/utmp
38 [ -e /var/log/wtmp ] || echo > /var/log/wtmp
39 chgrp utmp /var/run/utmp /var/log/wtmp
40 chmod 0664 /var/run/utmp /var/log/wtmp
41 fi
42
43 ebegin "Updating environment"
44 # Use our version, not portage version.
45 /sbin/env-update --fork-ldconfig
46 eend $?
47
48 # Take care of random stuff [ /var/lock | /var/run | pam ]
49 ebegin "Cleaning" /var/lock, /var/run
50 rm -rf /var/run/console.lock /var/run/console/*
51
52 # Clean up any stale locks.
53 find /var/lock -type f -print0 | xargs -0 rm -f --
54
55 # Clean up /var/run and create /var/run/utmp so we can login.
56 for x in $(find /var/run ! -type d ! -name utmp ! -name innd.pid ! -name random-seed ! -name ld-elf.so.hints); do
57 [ ! -f "${x}" ] && continue
58 # Do not remove pidfiles of already running daemons
59 case "${x}" in
60 *.pid)
61 start-stop-daemon --test --quiet --stop --pidfile "${x}"
62 [ $? -eq 0 ] && continue
63 ;;
64 esac
65 rm -f "${x}"
66 done
67
68 # Reset pam_console permissions if we are actually using it
69 if [ -x /sbin/pam_console_apply -a ! -c /dev/.devfsd ] ; then
70 if [ -n $(grep -v -e '^[[:space:]]*#' /etc/pam.d/* | grep 'pam_console') ] ; then
71 /sbin/pam_console_apply -r
72 fi
73 fi
74
75 # Create the .keep to stop portage from removing /var/lock
76 echo > /var/lock/.keep
77 eend 0
78
79 # Clean up /tmp directory
80 if [ -d /tmp ] ; then
81 cd /tmp
82 if [ "${WIPE_TMP}" = "yes" ] ; then
83 ebegin "Wiping /tmp directory"
84 local startopts="-x . -depth"
85 [ "${RC_UNAME}" = "Linux" ] && startopts=". -xdev -depth"
86
87 # Faster than find
88 rm -rf [b-ikm-pr-zA-Z]*
89
90 find ${startopts} ! -name . \
91 ! -path ./lost+found \
92 ! -path "./lost+found/*" \
93 ! -path ./quota.user \
94 ! -path "./quota.user/*" \
95 ! -path ./aquota.user \
96 ! -path "./aquota.user/*" \
97 ! -path ./quota.group \
98 ! -path "./quota.group/*" \
99 ! -path ./aquota.group \
100 ! -path "./aquota.group/*" \
101 ! -path ./journal \
102 ! -path "./journal/*" \
103 -delete
104 eend 0
105 else
106 ebegin "Cleaning /tmp directory"
107 rm -rf /tmp/.X*-lock /tmp/esrv* /tmp/kio* /tmp/jpsock.* \
108 /tmp/.fam* /tmp/.esd* /tmp/orbit-* /tmp/ssh-* \
109 /tmp/ksocket-* /tmp/.*-unix
110 eend 0
111 fi
112
113 # Make sure our X11 stuff have the correct permissions
114 # Omit the chown as bootmisc is run before network is up
115 # and users may be using lame LDAP auth #139411
116 rm -rf /tmp/.ICE-unix /tmp/.X11-unix
117 mkdir -p /tmp/.ICE-unix /tmp/.X11-unix
118 chmod 1777 /tmp/.ICE-unix /tmp/.X11-unix
119 [ -x /sbin/restorecon ] && restorecon /tmp/.ICE-unix /tmp/.X11-unix
120 fi
121
122 # Create an 'after-boot' dmesg log
123 if [ "${RC_SYS}" != "VPS" ] ; then
124 dmesg > /var/log/dmesg
125 chmod 640 /var/log/dmesg
126 fi
127
128 # Check for /etc/resolv.conf, and create if missing
129 [ -e /etc/resolv.conf ] || echo >/etc/resolv.conf
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