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. |
50 |
|
|
51 |
# dummy function; needed if splashutils are not installed |
# dummy function; needed if splashutils are not installed |
52 |
splash() { |
splash() { |
53 |
return 0 |
return 0 |
54 |
} |
} |
55 |
|
|
56 |
|
|
108 |
then |
then |
109 |
#check if statedir exists |
#check if statedir exists |
110 |
[ ! -d ${svcdir}/started ] && mkdir ${svcdir}/started |
[ ! -d ${svcdir}/started ] && mkdir ${svcdir}/started |
111 |
|
|
112 |
#get real name of the initscript, not from the symlink |
#get real name of the initscript, not from the symlink |
113 |
if [ -L "$0" ] |
if [ -L "$0" ] |
114 |
then |
then |
137 |
|
|
138 |
evaluate_retval() |
evaluate_retval() |
139 |
{ |
{ |
140 |
error_value=$? |
local error_value="$1" |
141 |
|
[[ -z ${error_value} ]] && error_value=$? |
142 |
|
|
143 |
if [ $error_value = 0 ] |
if [[ ${error_value} = 0 ]] |
144 |
then |
then |
145 |
print_status success |
print_status success |
146 |
else |
else |
147 |
print_status failure |
print_status failure |
148 |
fi |
fi |
149 |
|
|
150 |
return $error_value |
return ${error_value} |
151 |
} |
} |
152 |
|
|
153 |
print_status() |
print_status() |
349 |
fi |
fi |
350 |
} |
} |
351 |
|
|
352 |
|
kernel_version() |
353 |
|
{ |
354 |
|
local KV="$(uname -r | cut -d- -f1)" |
355 |
|
echo "${KV}" |
356 |
|
} |
357 |
|
|
358 |
kernel_major_version() |
kernel_major_version() |
359 |
{ |
{ |
360 |
local KV |
local KV |
361 |
KV="$(uname -r|cut -d. -f1-2)" |
KV="$(uname -r | cut -d. -f1-2)" |
362 |
echo "${KV}" |
echo "${KV}" |
363 |
} |
} |
364 |
|
|
365 |
dolisting() |
dolisting() |
366 |
{ |
{ |
367 |
local x= |
local x= |
368 |
local y= |
local y= |
396 |
|
|
397 |
echo "${mylist}" |
echo "${mylist}" |
398 |
} |
} |
399 |
|
|
400 |
|
# searches /proc/mounts for mounted fstypes (like ext3) |
401 |
|
is_fstype_mounted() { |
402 |
|
local filesys |
403 |
|
local i |
404 |
|
filesys=$1 |
405 |
|
|
406 |
|
i="$(cat /proc/mounts | grep ${filesys} | cut -d ' ' -f3)" |
407 |
|
[[ ${i} != ${filesys} ]] && return 1 |
408 |
|
|
409 |
|
return 0 |
410 |
|
} |
411 |
|
|
412 |
|
# searches /proc/mounts for mounted fs names (like udev, proc) |
413 |
|
is_fs_mounted() { |
414 |
|
local filesys |
415 |
|
local i |
416 |
|
filesys=$1 |
417 |
|
|
418 |
|
i="$(cat /proc/mounts | grep ${filesys} | cut -d ' ' -f1)" |
419 |
|
[[ ${i} != ${filesys} ]] && return 1 |
420 |
|
|
421 |
|
return 0 |
422 |
|
} |
423 |
|
|
424 |
|
# checks if kernel supports fs xy |
425 |
|
kernel_supports_fs() { |
426 |
|
local filesys |
427 |
|
local i |
428 |
|
filesys=$1 |
429 |
|
|
430 |
|
i="$(cat /proc/filesystems | grep ${filesys} | cut -d $'\t' -f2)" |
431 |
|
[[ ${i} != ${filesys} ]] && return 1 |
432 |
|
|
433 |
|
return 0 |
434 |
|
} |
435 |
|
|
436 |
|
# bool is_older_than(reference, files/dirs to check) |
437 |
|
# |
438 |
|
# return 0 if any of the files/dirs are newer than |
439 |
|
# the reference file |
440 |
|
# |
441 |
|
# EXAMPLE: if is_older_than a.out *.o ; then ... |
442 |
|
is_older_than() { |
443 |
|
local x= |
444 |
|
local ref="$1" |
445 |
|
shift |
446 |
|
|
447 |
|
for x in "$@" |
448 |
|
do |
449 |
|
[[ ${x} -nt ${ref} ]] && return 0 |
450 |
|
|
451 |
|
if [[ -d ${x} ]] |
452 |
|
then |
453 |
|
is_older_than "${ref}" "${x}"/* && return 0 |
454 |
|
fi |
455 |
|
done |
456 |
|
|
457 |
|
return 1 |
458 |
|
} |