slitaz-boot-scripts annotate etc/init.d/rc.functions @ rev 127

active_pidfile: avoid error msg
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Dec 01 23:27:32 2008 +0000 (2008-12-01)
parents 03088acac44f
children 10b04a333b4d
rev   line source
pankso@23 1 # /etc/init.d/rc.functions: SliTaz boot scripts functions.
pankso@23 2 #
pankso@23 3
pankso@23 4 # Status functions.
pankso@23 5 status()
pankso@23 6 {
pankso@23 7 local CHECK=$?
pankso@23 8 echo -en "\\033[70G[ "
pankso@23 9 if [ $CHECK = 0 ]; then
pankso@23 10 echo -en "\\033[1;33mOK"
pankso@23 11 else
pankso@23 12 echo -en "\\033[1;31mFailed"
pankso@23 13 fi
pankso@23 14 echo -e "\\033[0;39m ]"
pankso@23 15 }
pankso@23 16
MikeDSmith25@107 17 # Another way to sleep.
pankso@23 18 usleep_progress()
pankso@23 19 {
pankso@23 20 CHAR='='
pankso@28 21 for i in `seq 79-1`
pankso@23 22 do
pankso@23 23 echo -n "$CHAR"
pankso@23 24 usleep 28000
pankso@23 25 done
pankso@23 26 echo "$CHAR"
pankso@23 27 }
pascal@121 28
pascal@121 29 # Check daemon with pidfile: usage check_pidfile $PIDFILE $DAEMON
pascal@121 30 active_pidfile()
pascal@121 31 {
pascal@127 32 if [ ! -e $1 ]; then
pascal@127 33 return 1
pascal@127 34 elif grep -qs "Name:.$(basename $2)$" /proc/$(cat $1)/status ; then
pascal@121 35 return 0
pascal@121 36 else
pascal@121 37 rm -f $1
pascal@127 38 return 2
pascal@121 39 fi
pascal@121 40 }