2 # Begin $rc_base/init.d/functions - Run Level Control Functions
4 # Based on functions script from LFS-3.1 and earlier.
5 # Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
7 # With code based on Matthias Benkmann's simpleinit-msb @
8 # http://winterdrache.de/linux/newboot/index.html
12 export PATH
="/bin:/usr/bin:/sbin:/usr/sbin"
17 COLUMNS
=${COLUMNS##* }
18 COL
=$
[ $COLUMNS - 10 ]
19 WCOL
=$
[ $COLUMNS - 30 ]
20 SET_COL
="echo -en \\033[${COL}G"
21 SET_WCOL
="echo -en \\033[${WCOL}G"
22 CURS_UP
="echo -en \\033[A"
24 NORMAL
="echo -en \\033[0;39m"
25 SUCCESS
="echo -en \\033[1;32m"
26 WARNING
="echo -en \\033[1;33m"
27 FAILURE
="echo -en \\033[1;31m"
33 echo "You should not be reading this error message. It means"
34 echo "that an unforseen error took place in $i,"
35 echo "which exited with a return value of $error_value"
37 echo "If you're able to track this error down to a bug in one"
38 echo "of the files provided by the LFS book, please be so kind"
39 echo "to inform us at lfs-dev@linuxfromscratch.org"
43 echo "Press Enter to continue..."
51 echo "$i is not a valid symlink"
57 echo "$i is not executable, skipping"
66 if [ $error_value = 0 ]
80 echo "Usage: $0 {success|warning|failure}"
99 echo "Already running"
129 pidlist
=$
(pidof
-o $$
-o $PPID -x $base)
136 echo "Usage: loadproc {program}"
148 print_status warning running
156 echo "Usage: killproc {program} [signal]"
165 signal
=${signal##SIG}
171 if [ -n "$pidlist" ]; then
176 kill -$signal $pid 2>/dev
/null
178 for ((i
=0; $i<5000; i
=$i+1)); do :; done
180 for ((i
=0; $i<$KILLDELAY; i
=$i+1)); do
181 kill -0 $pid 2>/dev
/null ||
break
185 if [ -n "$fallback" ]; then kill -$fallback $pid 2>/dev
/null
; fi
187 kill -0 $pid 2>/dev
/null
&& failure
=1
191 if [ $failure = 0 ]; then rm -f /var
/run
/$base.pid
; fi
197 print_status warning not_running
205 echo "Usage: reloadproc {program} [signal]"
213 signal
=${signal##SIG}
225 kill -$signal $pid || failure
=1
232 print_status warning not_running
240 echo "Usage: statusproc {program}"
249 echo "$base is running with Process ID(s) $pidlist"
251 if [ -s /var
/run
/$base.pid
]
253 echo "$1 is not running but /var/run/$base.pid exists"
256 echo "$1 is not running"
261 # End $rc_base/init.d/functions