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" |
47 |
svcfstype="tmpfs" |
svcfstype="tmpfs" |
48 |
svcsize=1024 |
svcsize=1024 |
49 |
|
|
50 |
|
rc_echo() { echo $@; } |
51 |
|
rc_print() { rc_echo -e "${COLOREDSTAR}$@"; } |
52 |
|
|
53 |
# dummy function; needed if splashutils are not installed |
# dummy function; needed if splashutils are not installed |
54 |
splash() { |
splash() { return 0; } |
|
return 0 |
|
|
} |
|
|
|
|
55 |
|
|
56 |
#source splash functions if exists |
# source splash functions if exists |
57 |
[ -f /etc/init.d/splash-functions ] && source /etc/init.d/splash-functions |
[ -f /etc/init.d/splash-functions ] && source /etc/init.d/splash-functions |
58 |
|
|
|
|
|
|
|
|
59 |
print_error_msg() |
print_error_msg() |
60 |
{ |
{ |
61 |
return 0 |
return 0 |
95 |
local SVCD_INITSCRIPT |
local SVCD_INITSCRIPT |
96 |
local x |
local x |
97 |
|
|
|
|
|
98 |
#do this only if proc is mounted |
#do this only if proc is mounted |
99 |
[ ! -f /proc/mounts ] && return 0 |
[ ! -f /proc/mounts ] && return 0 |
100 |
|
|
104 |
then |
then |
105 |
#check if statedir exists |
#check if statedir exists |
106 |
[ ! -d ${svcdir}/started ] && mkdir ${svcdir}/started |
[ ! -d ${svcdir}/started ] && mkdir ${svcdir}/started |
107 |
|
|
108 |
#get real name of the initscript, not from the symlink |
#get real name of the initscript, not from the symlink |
109 |
if [ -L "$0" ] |
if [ -L "$0" ] |
110 |
then |
then |
133 |
|
|
134 |
evaluate_retval() |
evaluate_retval() |
135 |
{ |
{ |
136 |
error_value=$? |
local error_value="$1" |
137 |
|
[[ -z ${error_value} ]] && error_value=$? |
138 |
|
|
139 |
if [ $error_value = 0 ] |
if [[ ${error_value} = 0 ]] |
140 |
then |
then |
141 |
print_status success |
print_status success |
142 |
else |
else |
143 |
print_status failure |
print_status failure |
144 |
|
|
145 |
|
if [[ ${SPLASH_VERBOSE_ON_ERRORS} = 1 ]] |
146 |
|
then |
147 |
|
splash "rc_verbose" "${runlevel}" |
148 |
|
fi |
149 |
fi |
fi |
150 |
|
|
151 |
return $error_value |
return ${error_value} |
152 |
} |
} |
153 |
|
|
154 |
print_status() |
print_status() |
289 |
else |
else |
290 |
signal=${2##-} |
signal=${2##-} |
291 |
signal=${signal##SIG} |
signal=${signal##SIG} |
|
|
|
292 |
fi |
fi |
293 |
|
|
294 |
getpids $1 |
getpids $1 |
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 |
|
{ |
403 |
|
local filesys |
404 |
|
local i |
405 |
|
filesys=$1 |
406 |
|
|
407 |
|
i="$(cat /proc/mounts | grep ${filesys} | cut -d ' ' -f3)" |
408 |
|
[[ ${i} != ${filesys} ]] && return 1 |
409 |
|
|
410 |
|
return 0 |
411 |
|
} |
412 |
|
|
413 |
|
# searches /proc/mounts for mounted fs names (like udev, proc) |
414 |
|
is_fs_mounted() |
415 |
|
{ |
416 |
|
local filesys |
417 |
|
local i |
418 |
|
filesys=$1 |
419 |
|
|
420 |
|
i="$(cat /proc/mounts | grep ${filesys} | cut -d ' ' -f1)" |
421 |
|
[[ ${i} != ${filesys} ]] && return 1 |
422 |
|
|
423 |
|
return 0 |
424 |
|
} |
425 |
|
|
426 |
|
# checks if kernel supports fs xy |
427 |
|
kernel_supports_fs() |
428 |
|
{ |
429 |
|
local filesys |
430 |
|
local i |
431 |
|
filesys=$1 |
432 |
|
|
433 |
|
i="$(cat /proc/filesystems | grep ${filesys} | cut -d $'\t' -f2)" |
434 |
|
[[ ${i} != ${filesys} ]] && return 1 |
435 |
|
|
436 |
|
return 0 |
437 |
|
} |
438 |
|
|
439 |
|
# bool is_older_than(reference, files/dirs to check) |
440 |
|
# |
441 |
|
# return 0 if any of the files/dirs are newer than |
442 |
|
# the reference file |
443 |
|
# |
444 |
|
# EXAMPLE: if is_older_than a.out *.o ; then ... |
445 |
|
is_older_than() |
446 |
|
{ |
447 |
|
local x= |
448 |
|
local ref="$1" |
449 |
|
shift |
450 |
|
|
451 |
|
for x in "$@" |
452 |
|
do |
453 |
|
[[ ${x} -nt ${ref} ]] && return 0 |
454 |
|
|
455 |
|
if [[ -d ${x} ]] |
456 |
|
then |
457 |
|
is_older_than "${ref}" "${x}"/* && return 0 |
458 |
|
fi |
459 |
|
done |
460 |
|
|
461 |
|
return 1 |
462 |
|
} |
463 |
|
|
464 |
|
start_devicemanager() { touch /dev/.none; return 0; } |
465 |
|
stop_devicemanager() { return 0; } |