1 |
#!/bin/bash |
#!/bin/bash |
2 |
|
# $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/functions,v 1.5 2005-10-21 15:21:41 niro Exp $ |
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 |
389 |
|
|
390 |
echo "${mylist}" |
echo "${mylist}" |
391 |
} |
} |
392 |
|
|
393 |
|
# searches /proc/mounts for mounted fstypes (like ext3) |
394 |
|
is_fstype_mounted() { |
395 |
|
local filesys |
396 |
|
local i |
397 |
|
filesys=$1 |
398 |
|
|
399 |
|
i="$(cat /proc/mounts | grep ${filesys} | cut -d ' ' -f3)" |
400 |
|
[[ ${i} != ${filesys} ]] && return 1 |
401 |
|
|
402 |
|
return 0 |
403 |
|
} |
404 |
|
|
405 |
|
# searches /proc/mounts for mounted fs names (like udev, proc) |
406 |
|
is_fs_mounted() { |
407 |
|
local filesys |
408 |
|
local i |
409 |
|
filesys=$1 |
410 |
|
|
411 |
|
i="$(cat /proc/mounts | grep ${filesys} | cut -d ' ' -f1)" |
412 |
|
[[ ${i} != ${filesys} ]] && return 1 |
413 |
|
|
414 |
|
return 0 |
415 |
|
} |
416 |
|
|
417 |
|
# checks if kernel supports fs xy |
418 |
|
kernel_supports_fs() { |
419 |
|
local filesys |
420 |
|
local i |
421 |
|
filesys=$1 |
422 |
|
|
423 |
|
i="$(cat /proc/filesystems | grep ${filesys} | cut -d $'\t' -f2)" |
424 |
|
[[ ${i} != ${filesys} ]] && return 1 |
425 |
|
|
426 |
|
return 0 |
427 |
|
} |
428 |
|
|
429 |
|
# bool is_older_than(reference, files/dirs to check) |
430 |
|
# |
431 |
|
# return 0 if any of the files/dirs are newer than |
432 |
|
# the reference file |
433 |
|
# |
434 |
|
# EXAMPLE: if is_older_than a.out *.o ; then ... |
435 |
|
is_older_than() { |
436 |
|
local x= |
437 |
|
local ref="$1" |
438 |
|
shift |
439 |
|
|
440 |
|
for x in "$@" |
441 |
|
do |
442 |
|
[[ ${x} -nt ${ref} ]] && return 0 |
443 |
|
|
444 |
|
if [[ -d ${x} ]] |
445 |
|
then |
446 |
|
is_older_than "${ref}" "${x}"/* && return 0 |
447 |
|
fi |
448 |
|
done |
449 |
|
|
450 |
|
return 1 |
451 |
|
} |