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

Contents of /trunk/init.d/bootmisc

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20