slitaz-boot-scripts view etc/init.d/rc.functions @ rev 147

rc.functions/active_pidfile: filter pid
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Mar 10 17:38:08 2009 +0000 (2009-03-10)
parents 31520720987c
children 599ec52ec156
line source
1 # /etc/init.d/rc.functions: SliTaz boot scripts functions.
2 #
4 # Status functions.
5 status()
6 {
7 local CHECK=$?
8 echo -en "\\033[70G[ "
9 if [ $CHECK = 0 ]; then
10 echo -en "\\033[1;33mOK"
11 else
12 echo -en "\\033[1;31mFailed"
13 fi
14 echo -e "\\033[0;39m ]"
15 }
17 # Another way to sleep.
18 usleep_progress()
19 {
20 CHAR='='
21 for i in `seq 79-1`
22 do
23 echo -n "$CHAR"
24 usleep 28000
25 done
26 echo "$CHAR"
27 }
29 # Check daemon with pidfile: usage check_pidfile $PIDFILE $DAEMON
30 active_pidfile()
31 {
32 if [ ! -e $1 ]; then
33 return 1
34 elif grep -qs "Name:.$(basename $2)$" \
35 /proc/$(cat $1 | sed 's/[^0-9]//g')/status ; then
36 return 0
37 else
38 rm -f $1
39 return 2
40 fi
41 }