/[baselayout]/trunk/init.d/runscript.sh
Gentoo

Diff of /trunk/init.d/runscript.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 126 Revision 127
69svc_stop() { 69svc_stop() {
70 local x 70 local x
71 local stopfail="no" 71 local stopfail="no"
72 local mydeps 72 local mydeps
73 local mydep 73 local mydep
74 local retval
74 local depservice 75 local depservice
75 if [ ! -L ${svcdir}/started/${myservice} ] 76 if [ ! -L ${svcdir}/started/${myservice} ]
76 then 77 then
77 einfo "${myservice} has not yet been started." 78 einfo "${myservice} has not yet been started."
78 return 1 79 return 1
79 fi 80 fi
80 81
82 #remove symlink to prevent recursion
83 rm -f ${svcdir}/started/${myservice}
84
81 #stop all services that should be before on runlevel change 85 #stop all services that should be before on runlevel change
82 for x in ${svcdir}/after/*/${myservice} 86 for x in ${svcdir}/before/*/${myservice}
83 do 87 do
84 if [ ! -L ${x} ] 88 if [ ! -L ${x} ]
85 then 89 then
86 continue 90 continue
87 fi 91 fi
88 depservice=${x%/*} 92 depservice=${x%/*}
89 if [ -d ${svcdir}/softscripts.new ] 93 if [ -d ${svcdir}/softscripts.new ]
90 then 94 then
91 if [ ! -L ${svcdir}/softscripts.new/${depservice##*/} ] && \ 95 if [ ! -L ${svcdir}/softscripts.new/${depservice##*/} ] && \
92 [ -L ${svcdir}/started/${depservice##*/} ] 96 [ -L ${svcdir}/started/${depservice##*/} ] && \
97 [ ! -L ${svcdir}/need/${depservice##*/}/${myservice} ] && \
98 [ ! -L ${svcdir}/use/${depservice##*/}/${myservice} ] && \
99 [ ! -L ${svcdir}/before/${myservice}/${depservice##*/} ]
93 then 100 then
94 /etc/init.d/${depservice##*/} stop 101 /etc/init.d/${depservice##*/} stop
95 fi 102 fi
96 fi 103 fi
97 done 104 done
141 fi 148 fi
142 done 149 done
143 if [ "$stopfail" = "yes" ] && [ -L ${svcdir}/need/${mydep}/${x} ] 150 if [ "$stopfail" = "yes" ] && [ -L ${svcdir}/need/${mydep}/${x} ]
144 then 151 then
145 eerror "Problems stopping dependent services. \"${myservice}\" still up." 152 eerror "Problems stopping dependent services. \"${myservice}\" still up."
153 ln -sf /etc/init.d/${myservice} ${svcdir}/started/${myservice}
146 exit 1 154 exit 1
147 fi 155 fi
148 fi 156 fi
149 done 157 done
150 done 158 done
151 159
152 #now that deps are stopped, stop our service 160 #now that deps are stopped, stop our service
153 stop 161 stop
154 if [ $? -eq 0 ] 162 retval=$?
163
164# #stop all services that should be after on runlevel change
165# for x in ${svcdir}/after/*/${myservice}
166# do
167# if [ ! -L ${x} ]
155 then 168# then
156 rm ${svcdir}/started/${myservice} 169# continue
157 else
158 return $?
159 fi 170# fi
171# depservice=${x%/*}
172# if [ -d ${svcdir}/softscripts.new ]
173# then
174# if [ ! -L ${svcdir}/softscripts.new/${depservice##*/} ] && \
175# [ -L ${svcdir}/started/${depservice##*/} ] && \
176# [ ! -L ${svcdir}/need/${myservice}/${depservice##*/} ] && \
177# [ ! -L ${svcdir}/use/${myservice}/${depservice##*/} ] && \
178# [ ! -L ${svcdir}/after/${myservice}/${depservice##*/} ]
179# then
180# /etc/init.d/${depservice##*/} stop
181# fi
182# fi
183# done
184
185 if [ $retval -ne 0 ]
186 then
187 ln -sf /etc/init.d/${myservice} ${svcdir}/started/${myservice}
188 fi
189 return $retval
160} 190}
161 191
162svc_start() { 192svc_start() {
163 local retval=0 193 local retval=0
164 local startfail="no" 194 local startfail="no"
166 local y 196 local y
167 local myserv 197 local myserv
168 local depservice 198 local depservice
169 if [ ! -L ${svcdir}/started/${myservice} ] 199 if [ ! -L ${svcdir}/started/${myservice} ]
170 then 200 then
201 #link first to prevent possible recursion
202 ln -sf /etc/init.d/${myservice} ${svcdir}/started/${myservice}
203
171 #start anything that should be started before on runlevel change 204 #start anything that should be started before on runlevel change
172 for x in ${svcdir}/before/*/${myservice} 205 for x in ${svcdir}/after/*/${myservice}
173 do 206 do
174 if [ ! -L ${x} ] 207 if [ ! -L ${x} ]
175 then 208 then
176 continue 209 continue
177 fi 210 fi
178 depservice=${x%/*} 211 depservice=${x%/*}
179 if [ -d ${svcdir}/softscripts.old ] 212 if [ -d ${svcdir}/softscripts.old ]
180 then 213 then
181 if [ ! -L ${svcdir}/softscripts.old/${depservice##*/} ] && \ 214 if [ ! -L ${svcdir}/softscripts.old/${depservice##*/} ] && \
182 [ ! -L ${svcdir}/started/${depservice##*/} ] 215 [ ! -L ${svcdir}/started/${depservice##*/} ] && \
216 [ -L ${svcdir}/softscripts/${depservice##*/} ] && \
217 [ ! -L ${svcdir}/need/${myservice}/${depservice##*/} ] && \
218 [ ! -L ${svcdir}/use/${myservice}/${depservice##*/} ] && \
219 [ ! -L ${svcdir}/after/${myservice}/${depservice##*/} ]
183 then 220 then
184 /etc/init.d/${depservice##*/} start 221 /etc/init.d/${depservice##*/} start
185 fi 222 fi
186 fi 223 fi
187 done 224 done
188
189 #link first to prevent possible recursion
190 ln -s /etc/init.d/${myservice} ${svcdir}/started/${myservice}
191 225
192 #start dependencies, if any 226 #start dependencies, if any
193 for x in `ineed ${myservice}` `valid_iuse ${myservice}` 227 for x in `ineed ${myservice}` `valid_iuse ${myservice}`
194 do 228 do
195 if [ "$x" = "net" ] 229 if [ "$x" = "net" ]
237 elif [ ! -d ${svcdir}/broken/${myservice} ] && [ $retval -eq 0 ] 271 elif [ ! -d ${svcdir}/broken/${myservice} ] && [ $retval -eq 0 ]
238 then 272 then
239 start 273 start
240 retval=$? 274 retval=$?
241 fi 275 fi
276
277 #start anything that should be started after on runlevel change
278 for x in ${svcdir}/before/*/${myservice}
279 do
280 if [ ! -L ${x} ]
281 then
282 continue
283 fi
284 depservice=${x%/*}
285 if [ -d ${svcdir}/softscripts.old ]
286 then
287 if [ ! -L ${svcdir}/softscripts.old/${depservice##*/} ] && \
288 [ ! -L ${svcdir}/started/${depservice##*/} ] && \
289 [ -L ${svcdir}/softscripts/${depservice##*/} ] && \
290 [ ! -L ${svcdir}/need/${depservice##*/}/${myservice} ] && \
291 [ ! -L ${svcdir}/use/${depservice##*/}/${myservice} ] && \
292 [ ! -L ${svcdir}/before/${myservice}/${depservice##*/} ]
293 then
294 /etc/init.d/${depservice##*/} start
295 fi
296 fi
297 done
242 298
243 #remove link if service didn't start; but only if we're not booting 299 #remove link if service didn't start; but only if we're not booting
244 #if we're booting, we need to continue and do our best to get the 300 #if we're booting, we need to continue and do our best to get the
245 #system up. 301 #system up.
246 if [ $retval -ne 0 ] && [ "$SOFTLEVEL" != "boot" ] 302 if [ $retval -ne 0 ] && [ "$SOFTLEVEL" != "boot" ]

Legend:
Removed from v.126  
changed lines
  Added in v.127

  ViewVC Help
Powered by ViewVC 1.1.20