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 $ |
# $Id$ |
3 |
|
|
4 |
# Begin $rc_base/init.d/functions - Run Level Control Functions |
# Begin $rc_base/init.d/functions - Run Level Control Functions |
5 |
|
|
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 |
|
|
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() |
203 |
|
|
204 |
getpids() |
getpids() |
205 |
{ |
{ |
206 |
base=${1##*/} |
local base=${1##*/} |
207 |
pidlist=$(pidof -o $$ -o $PPID -x $base) |
local opts |
208 |
|
if [[ $(readlink /bin/pidof) = *busybox ]] |
209 |
|
then |
210 |
|
opts="" |
211 |
|
else |
212 |
|
opts="-x" |
213 |
|
fi |
214 |
|
pidlist=$(pidof -o $$ -o $PPID ${opts} $base) |
215 |
} |
} |
216 |
|
|
217 |
loadproc() |
loadproc() |
273 |
done |
done |
274 |
|
|
275 |
base=${1##*/} |
base=${1##*/} |
276 |
if [ $failure = 0 ]; then rm -f /var/run/$base.pid; fi |
if [ $failure = 0 ]; then rm -f /run/$base.pid; fi |
277 |
|
|
278 |
(exit $failure) |
(exit $failure) |
279 |
evaluate_retval |
evaluate_retval |
296 |
else |
else |
297 |
signal=${2##-} |
signal=${2##-} |
298 |
signal=${signal##SIG} |
signal=${signal##SIG} |
|
|
|
299 |
fi |
fi |
300 |
|
|
301 |
getpids $1 |
getpids $1 |
332 |
then |
then |
333 |
echo "$base is running with Process ID(s) $pidlist" |
echo "$base is running with Process ID(s) $pidlist" |
334 |
else |
else |
335 |
if [ -s /var/run/$base.pid ] |
if [ -s /run/$base.pid ] |
336 |
then |
then |
337 |
echo "$1 is not running but /var/run/$base.pid exists" |
echo "$1 is not running but /run/$base.pid exists" |
338 |
return 1 |
return 1 |
339 |
else |
else |
340 |
echo "$1 is not running" |
echo "$1 is not running" |
356 |
fi |
fi |
357 |
} |
} |
358 |
|
|
359 |
|
kernel_version() |
360 |
|
{ |
361 |
|
local KV="$(uname -r | cut -d- -f1)" |
362 |
|
echo "${KV}" |
363 |
|
} |
364 |
|
|
365 |
kernel_major_version() |
kernel_major_version() |
366 |
{ |
{ |
367 |
local KV |
local KV |
368 |
KV="$(uname -r|cut -d. -f1-2)" |
KV="$(uname -r | cut -d. -f1-2)" |
369 |
echo "${KV}" |
echo "${KV}" |
370 |
} |
} |
371 |
|
|
372 |
dolisting() |
dolisting() |
373 |
{ |
{ |
374 |
local x= |
local x= |
375 |
local y= |
local y= |
405 |
} |
} |
406 |
|
|
407 |
# searches /proc/mounts for mounted fstypes (like ext3) |
# searches /proc/mounts for mounted fstypes (like ext3) |
408 |
is_fstype_mounted() { |
is_fstype_mounted() |
409 |
|
{ |
410 |
local filesys |
local filesys |
411 |
local i |
local i |
412 |
filesys=$1 |
filesys=$1 |
418 |
} |
} |
419 |
|
|
420 |
# searches /proc/mounts for mounted fs names (like udev, proc) |
# searches /proc/mounts for mounted fs names (like udev, proc) |
421 |
is_fs_mounted() { |
is_fs_mounted() |
422 |
|
{ |
423 |
local filesys |
local filesys |
424 |
local i |
local i |
425 |
filesys=$1 |
filesys=$1 |
431 |
} |
} |
432 |
|
|
433 |
# checks if kernel supports fs xy |
# checks if kernel supports fs xy |
434 |
kernel_supports_fs() { |
kernel_supports_fs() |
435 |
|
{ |
436 |
local filesys |
local filesys |
437 |
local i |
local i |
438 |
filesys=$1 |
filesys=$1 |
449 |
# the reference file |
# the reference file |
450 |
# |
# |
451 |
# EXAMPLE: if is_older_than a.out *.o ; then ... |
# EXAMPLE: if is_older_than a.out *.o ; then ... |
452 |
is_older_than() { |
is_older_than() |
453 |
|
{ |
454 |
local x= |
local x= |
455 |
local ref="$1" |
local ref="$1" |
456 |
shift |
shift |
467 |
|
|
468 |
return 1 |
return 1 |
469 |
} |
} |
470 |
|
|
471 |
|
start_devicemanager() { touch /dev/.none; return 0; } |
472 |
|
stop_devicemanager() { return 0; } |