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

Contents of /trunk/init.d/bootmisc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2794 - (show annotations) (download)
Wed Jul 25 20:58:23 2007 UTC (7 years, 4 months ago) by uberlord
File size: 4095 byte(s)
Merge some of reb's OpenBSD fixes in
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 printf "" >/var/run/utmp
38 [ -e /var/log/wtmp ] || printf "" >/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 \
57 ! -name random-seed ! -name ld-elf.so.hints ! -name ld.so.hints); do
58 [ ! -f "${x}" ] && continue
59 # Do not remove pidfiles of already running daemons
60 case "${x}" in
61 *.pid)
62 start-stop-daemon --test --quiet --stop --pidfile "${x}"
63 [ $? -eq 0 ] && continue
64 ;;
65 esac
66 rm -f "${x}"
67 done
68
69 # Reset pam_console permissions if we are actually using it
70 if [ -x /sbin/pam_console_apply ] && ! [ -c /dev/.devfsd ] ; then
71 if grep -v -e '^[[:space:]]*#' /etc/pam.d/* | grep -q 'pam_console.so' ; then
72 pam_console_apply -r
73 fi
74 fi
75
76 # Create the .keep to stop portage from removing /var/lock
77 printf "" >/var/lock/.keep
78 eend 0
79
80 # Clean up /tmp directory
81 if [ -d /tmp ] ; then
82 cd /tmp
83 if [ "${WIPE_TMP}" = "yes" ] ; then
84 ebegin "Wiping /tmp directory"
85 local startopts="-x . -depth"
86 [ "${RC_UNAME}" = "Linux" ] && startopts=". -xdev -depth"
87
88 # Faster than find
89 rm -rf [b-ikm-pr-zA-Z]*
90
91 find ${startopts} ! -name . \
92 ! -path ./lost+found \
93 ! -path "./lost+found/*" \
94 ! -path ./quota.user \
95 ! -path "./quota.user/*" \
96 ! -path ./aquota.user \
97 ! -path "./aquota.user/*" \
98 ! -path ./quota.group \
99 ! -path "./quota.group/*" \
100 ! -path ./aquota.group \
101 ! -path "./aquota.group/*" \
102 ! -path ./journal \
103 ! -path "./journal/*" \
104 -delete
105 eend 0
106 else
107 ebegin "Cleaning /tmp directory"
108 rm -rf /tmp/.X*-lock /tmp/esrv* /tmp/kio* /tmp/jpsock.* \
109 /tmp/.fam* /tmp/.esd* /tmp/orbit-* /tmp/ssh-* \
110 /tmp/ksocket-* /tmp/.*-unix
111 eend 0
112 fi
113
114 # Make sure our X11 stuff have the correct permissions
115 # Omit the chown as bootmisc is run before network is up
116 # and users may be using lame LDAP auth #139411
117 rm -rf /tmp/.ICE-unix /tmp/.X11-unix
118 mkdir -p /tmp/.ICE-unix /tmp/.X11-unix
119 chmod 1777 /tmp/.ICE-unix /tmp/.X11-unix
120 [ -x /sbin/restorecon ] && restorecon /tmp/.ICE-unix /tmp/.X11-unix
121 fi
122
123 # Create an 'after-boot' dmesg log
124 if [ "${RC_SYS}" != "VPS" ] ; then
125 dmesg > /var/log/dmesg
126 chmod 640 /var/log/dmesg
127 fi
128
129 # Check for /etc/resolv.conf, and create if missing
130 [ -e /etc/resolv.conf ] || printf "" >/etc/resolv.conf
131 }
132
133 stop() {
134 # Reset pam_console permissions if we are actually using it
135 if [ -x /sbin/pam_console_apply -a ! -c /dev/.devfsd ] && \
136 [ -n $(grep -v -e '^[[:space:]]*#' /etc/pam.d/* | grep 'pam_console') ] ; then
137 /sbin/pam_console_apply -r
138 fi
139
140 # Write a halt record if we're shutting down
141 case "${SOFTLEVEL}" in
142 reboot|shutdown)
143 [ "${RC_UNAME}" = "Linux" ] && halt -w
144 ;;
145 esac
146
147 return 0
148 }
149
150 # vim: set ts=4 :

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20