1 |
#!/bin/bash |
#!/bin/bash |
2 |
|
# $Id$ |
3 |
|
|
4 |
# Begin $rc_base/init.d/functions - Run Level Control Functions |
# Begin $rc_base/init.d/functions - Run Level Control Functions |
5 |
|
|
6 |
# Based on functions script from LFS-3.1 and earlier. |
# Based on functions script from LFS-3.1 and earlier. |
40 |
|
|
41 |
COLOREDSTAR="${COLBLUE}(${COLGREEN}*${COLBLUE})${COLDEFAULT} " |
COLOREDSTAR="${COLBLUE}(${COLGREEN}*${COLBLUE})${COLDEFAULT} " |
42 |
|
|
43 |
#location to save the started services |
# location to save the started services |
44 |
svcdir="/var/lib/init.d" |
svcdir="/var/lib/init.d" |
45 |
svclib="/lib/rcscripts" |
svclib="/lib/rcscripts" |
46 |
svcmount="no" |
svcmount="no" |
49 |
|
|
50 |
|
|
51 |
# dummy function; needed if splashutils are not installed |
# dummy function; needed if splashutils are not installed |
52 |
splash() { |
splash() { return 0; } |
|
return 0 |
|
|
} |
|
|
|
|
53 |
|
|
54 |
#source splash functions if exists |
# source splash functions if exists |
55 |
[ -f /etc/init.d/splash-functions ] && source /etc/init.d/splash-functions |
[ -f /etc/init.d/splash-functions ] && source /etc/init.d/splash-functions |
56 |
|
|
|
|
|
|
|
|
57 |
print_error_msg() |
print_error_msg() |
58 |
{ |
{ |
59 |
return 0 |
return 0 |
93 |
local SVCD_INITSCRIPT |
local SVCD_INITSCRIPT |
94 |
local x |
local x |
95 |
|
|
|
|
|
96 |
#do this only if proc is mounted |
#do this only if proc is mounted |
97 |
[ ! -f /proc/mounts ] && return 0 |
[ ! -f /proc/mounts ] && return 0 |
98 |
|
|
102 |
then |
then |
103 |
#check if statedir exists |
#check if statedir exists |
104 |
[ ! -d ${svcdir}/started ] && mkdir ${svcdir}/started |
[ ! -d ${svcdir}/started ] && mkdir ${svcdir}/started |
105 |
|
|
106 |
#get real name of the initscript, not from the symlink |
#get real name of the initscript, not from the symlink |
107 |
if [ -L "$0" ] |
if [ -L "$0" ] |
108 |
then |
then |
131 |
|
|
132 |
evaluate_retval() |
evaluate_retval() |
133 |
{ |
{ |
134 |
error_value=$? |
local error_value="$1" |
135 |
|
[[ -z ${error_value} ]] && error_value=$? |
136 |
|
|
137 |
if [ $error_value = 0 ] |
if [[ ${error_value} = 0 ]] |
138 |
then |
then |
139 |
print_status success |
print_status success |
140 |
else |
else |
141 |
print_status failure |
print_status failure |
142 |
fi |
fi |
143 |
|
|
144 |
return $error_value |
return ${error_value} |
145 |
} |
} |
146 |
|
|
147 |
print_status() |
print_status() |
282 |
else |
else |
283 |
signal=${2##-} |
signal=${2##-} |
284 |
signal=${signal##SIG} |
signal=${signal##SIG} |
|
|
|
285 |
fi |
fi |
286 |
|
|
287 |
getpids $1 |
getpids $1 |
342 |
fi |
fi |
343 |
} |
} |
344 |
|
|
345 |
|
kernel_version() |
346 |
|
{ |
347 |
|
local KV="$(uname -r | cut -d- -f1)" |
348 |
|
echo "${KV}" |
349 |
|
} |
350 |
|
|
351 |
kernel_major_version() |
kernel_major_version() |
352 |
{ |
{ |
353 |
local KV |
local KV |
354 |
KV="$(uname -r|cut -d. -f1-2)" |
KV="$(uname -r | cut -d. -f1-2)" |
355 |
echo "${KV}" |
echo "${KV}" |
356 |
} |
} |
357 |
|
|
358 |
dolisting() |
dolisting() |
359 |
{ |
{ |
360 |
local x= |
local x= |
361 |
local y= |
local y= |
389 |
|
|
390 |
echo "${mylist}" |
echo "${mylist}" |
391 |
} |
} |
392 |
|
|
393 |
|
# searches /proc/mounts for mounted fstypes (like ext3) |
394 |
|
is_fstype_mounted() |
395 |
|
{ |
396 |
|
local filesys |
397 |
|
local i |
398 |
|
filesys=$1 |
399 |
|
|
400 |
|
i="$(cat /proc/mounts | grep ${filesys} | cut -d ' ' -f3)" |
401 |
|
[[ ${i} != ${filesys} ]] && return 1 |
402 |
|
|
403 |
|
return 0 |
404 |
|
} |
405 |
|
|
406 |
|
# searches /proc/mounts for mounted fs names (like udev, proc) |
407 |
|
is_fs_mounted() |
408 |
|
{ |
409 |
|
local filesys |
410 |
|
local i |
411 |
|
filesys=$1 |
412 |
|
|
413 |
|
i="$(cat /proc/mounts | grep ${filesys} | cut -d ' ' -f1)" |
414 |
|
[[ ${i} != ${filesys} ]] && return 1 |
415 |
|
|
416 |
|
return 0 |
417 |
|
} |
418 |
|
|
419 |
|
# checks if kernel supports fs xy |
420 |
|
kernel_supports_fs() |
421 |
|
{ |
422 |
|
local filesys |
423 |
|
local i |
424 |
|
filesys=$1 |
425 |
|
|
426 |
|
i="$(cat /proc/filesystems | grep ${filesys} | cut -d $'\t' -f2)" |
427 |
|
[[ ${i} != ${filesys} ]] && return 1 |
428 |
|
|
429 |
|
return 0 |
430 |
|
} |
431 |
|
|
432 |
|
# bool is_older_than(reference, files/dirs to check) |
433 |
|
# |
434 |
|
# return 0 if any of the files/dirs are newer than |
435 |
|
# the reference file |
436 |
|
# |
437 |
|
# EXAMPLE: if is_older_than a.out *.o ; then ... |
438 |
|
is_older_than() |
439 |
|
{ |
440 |
|
local x= |
441 |
|
local ref="$1" |
442 |
|
shift |
443 |
|
|
444 |
|
for x in "$@" |
445 |
|
do |
446 |
|
[[ ${x} -nt ${ref} ]] && return 0 |
447 |
|
|
448 |
|
if [[ -d ${x} ]] |
449 |
|
then |
450 |
|
is_older_than "${ref}" "${x}"/* && return 0 |
451 |
|
fi |
452 |
|
done |
453 |
|
|
454 |
|
return 1 |
455 |
|
} |
456 |
|
|
457 |
|
start_devicemanager() { touch /dev/.none; return 0; } |
458 |
|
stop_devicemanager() { return 0; } |