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

Contents of /trunk/init.d/bootmisc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2913 - (hide annotations) (download)
Mon Sep 24 15:27:06 2007 UTC (11 years, 1 month ago) by uberlord
File size: 4415 byte(s)
Use mkdir to test. Also, quote for robustness
1 uberlord 2547 #!/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 vapier 2869 cleanup_tmp_dir() {
13     local dir=$1
14    
15 uberlord 2913 mkdir -p "${dir}"
16     cd "${dir}"
17 vapier 2869 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 uberlord 2913 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 vapier 2869 eend 0
47     fi
48     }
49    
50 uberlord 2547 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 uberlord 2913 echo "System bootup in progress - please wait" > /etc/nologin
55 uberlord 2547 cp /etc/nologin /etc/nologin.boot
56     fi
57    
58 uberlord 2568 if [ -e /etc/sysctl.conf -a ! -x /etc/init.d/sysctl ] ; then
59 uberlord 2662 if [ "${RC_SYS}" != "VPS" ] ; then
60     ebegin "Configuring kernel parameters"
61 uberlord 2710 sysctl -p /etc/sysctl.conf >/dev/null
62 uberlord 2662 eend $?
63     fi
64 uberlord 2568 fi
65    
66 uberlord 2913 if ! mkdir /.test.$$ 2>/dev/null ; then
67 uberlord 2547 ewarn "Skipping /var and /tmp initialization (ro root?)"
68     return 0
69     fi
70 uberlord 2913 rmdir /.test.$$
71 uberlord 2547
72 uberlord 2798 # Ensure that our basic dirs exist
73 uberlord 2809 for x in /var/lock /var/log /var/run /tmp ; do
74 uberlord 2798 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 uberlord 2848 # 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 uberlord 2547
88     ebegin "Updating environment"
89 uberlord 2756 # Use our version, not portage version.
90     /sbin/env-update --fork-ldconfig
91 uberlord 2547 eend $?
92    
93     # Take care of random stuff [ /var/lock | /var/run | pam ]
94 uberlord 2798 ebegin "Cleaning /var/lock, /var/run"
95 uberlord 2547 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 uberlord 2794 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 uberlord 2547 [ ! -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 uberlord 2794 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 uberlord 2547 fi
119     fi
120    
121     # Create the .keep to stop portage from removing /var/lock
122 uberlord 2784 printf "" >/var/lock/.keep
123 uberlord 2547 eend 0
124    
125 vapier 2869 # Clean up /tmp directories
126     local tmp
127     for tmp in ${WIPE_TMP_DIRS-/tmp} ; do
128 uberlord 2913 cleanup_tmp_dir "${tmp}"
129 vapier 2869 done
130 vapier 2871 chmod +t /tmp /var/tmp
131 uberlord 2547
132 vapier 2871 # 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 uberlord 2547 # Create an 'after-boot' dmesg log
141 uberlord 2663 if [ "${RC_SYS}" != "VPS" ] ; then
142 uberlord 2775 dmesg > /var/log/dmesg
143 uberlord 2663 chmod 640 /var/log/dmesg
144     fi
145 uberlord 2547
146     # Check for /etc/resolv.conf, and create if missing
147 uberlord 2784 [ -e /etc/resolv.conf ] || printf "" >/etc/resolv.conf
148 uberlord 2547 }
149    
150     stop() {
151     # Reset pam_console permissions if we are actually using it
152 uberlord 2796 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 uberlord 2797 /sbin/pam_console_apply -r
155     fi
156 uberlord 2547 fi
157    
158     # Write a halt record if we're shutting down
159 uberlord 2796 case "${RC_SOFTLEVEL}" in
160 uberlord 2547 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