1 |
#!/bin/bash |
#!/bin/bash |
2 |
|
# $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/functions,v 1.6 2006-01-03 18:03:11 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 |
348 |
fi |
fi |
349 |
} |
} |
350 |
|
|
351 |
|
kernel_version() |
352 |
|
{ |
353 |
|
local KV="$(uname -r | cut -d- -f1)" |
354 |
|
echo "${KV}" |
355 |
|
} |
356 |
|
|
357 |
kernel_major_version() |
kernel_major_version() |
358 |
{ |
{ |
359 |
local KV |
local KV |
360 |
KV="$(uname -r|cut -d. -f1-2)" |
KV="$(uname -r | cut -d. -f1-2)" |
361 |
echo "${KV}" |
echo "${KV}" |
362 |
} |
} |
363 |
|
|
364 |
dolisting() |
dolisting() |
365 |
{ |
{ |
366 |
local x= |
local x= |
367 |
local y= |
local y= |
395 |
|
|
396 |
echo "${mylist}" |
echo "${mylist}" |
397 |
} |
} |
398 |
|
|
399 |
|
# searches /proc/mounts for mounted fstypes (like ext3) |
400 |
|
is_fstype_mounted() { |
401 |
|
local filesys |
402 |
|
local i |
403 |
|
filesys=$1 |
404 |
|
|
405 |
|
i="$(cat /proc/mounts | grep ${filesys} | cut -d ' ' -f3)" |
406 |
|
[[ ${i} != ${filesys} ]] && return 1 |
407 |
|
|
408 |
|
return 0 |
409 |
|
} |
410 |
|
|
411 |
|
# searches /proc/mounts for mounted fs names (like udev, proc) |
412 |
|
is_fs_mounted() { |
413 |
|
local filesys |
414 |
|
local i |
415 |
|
filesys=$1 |
416 |
|
|
417 |
|
i="$(cat /proc/mounts | grep ${filesys} | cut -d ' ' -f1)" |
418 |
|
[[ ${i} != ${filesys} ]] && return 1 |
419 |
|
|
420 |
|
return 0 |
421 |
|
} |
422 |
|
|
423 |
|
# checks if kernel supports fs xy |
424 |
|
kernel_supports_fs() { |
425 |
|
local filesys |
426 |
|
local i |
427 |
|
filesys=$1 |
428 |
|
|
429 |
|
i="$(cat /proc/filesystems | grep ${filesys} | cut -d $'\t' -f2)" |
430 |
|
[[ ${i} != ${filesys} ]] && return 1 |
431 |
|
|
432 |
|
return 0 |
433 |
|
} |
434 |
|
|
435 |
|
# bool is_older_than(reference, files/dirs to check) |
436 |
|
# |
437 |
|
# return 0 if any of the files/dirs are newer than |
438 |
|
# the reference file |
439 |
|
# |
440 |
|
# EXAMPLE: if is_older_than a.out *.o ; then ... |
441 |
|
is_older_than() { |
442 |
|
local x= |
443 |
|
local ref="$1" |
444 |
|
shift |
445 |
|
|
446 |
|
for x in "$@" |
447 |
|
do |
448 |
|
[[ ${x} -nt ${ref} ]] && return 0 |
449 |
|
|
450 |
|
if [[ -d ${x} ]] |
451 |
|
then |
452 |
|
is_older_than "${ref}" "${x}"/* && return 0 |
453 |
|
fi |
454 |
|
done |
455 |
|
|
456 |
|
return 1 |
457 |
|
} |