- if [ -f ${kill_script} ]; then
- # "suffix" will contain the script name without the leading Kxx.
- suffix="${kill_script##*/K[0-9][0-9]}"
-
- # If there is a S script in the previous runlevel corresponding
- # to this K script, determine what it's full path is.
- previous_start="/etc/rc.d/rc${previous}.d/S[0-9][0-9]${suffix}"
-
- # If no start script was found in the previous run level it could
- # be that something was started in rcsysinit.d (sysinit level) so we'll
- # determine the path for that possibility as well.
- sysinit_start="/etc/rc.d/rcsysinit.d/S[0-9][0-9]${suffix}"
-
- # Stop the service if there is a start script in the previous run
- # level or in the sysinit level. Otherwise, don't execute this K
- # script because the service is not active.
- if [ -f ${previous_start} -o -f ${sysinit_start} ]; then
- startup ${kill_script} stop
- retval=${?}
- if [ ${retval} -ne ${EXIT_CODE_SUCCESS} -a ${retval} -ne ${EXIT_CODE_WARNING} ]; then
- print_error_msg ${kill_script} ${retval}
- fi
- fi
+ check_script_status ${kill_script}
+ if [ ${?} != ${EXIT_CODE_SUCCESS} ]; then
+ continue
+ fi
+
+ # "suffix" will contain the script name without the leading Kxx.
+ suffix="${kill_script##*/K[0-9][0-9]}"
+
+ # If there is a S script in the previous runlevel corresponding
+ # to this K script, determine what it's full path is.
+ previous_start="/etc/rc.d/rc${previous}.d/S[0-9][0-9]${suffix}"
+
+ # If no start script was found in the previous run level it could
+ # be that something was started in rcsysinit.d (sysinit level) so we'll
+ # determine the path for that possibility as well.
+ sysinit_start="/etc/rc.d/rcsysinit.d/S[0-9][0-9]${suffix}"
+
+ # Stop the service if there is a start script in the previous run
+ # level or in the sysinit level. Otherwise, don't execute this K
+ # script because the service is not active.
+ if [ "${runlevel}" != "0" -a "${runlevel}" != "6" ]; then
+ if [ ! -f ${previous_start} -a ! -f ${sysinit_start} ]; then
+ echo "Warning: script ${kill_script} cannot be stopped because it was not started"
+ echo "in the previous runlevel"
+ continue
+ fi
+ fi
+
+ startup ${kill_script} stop
+ retval=${?}
+ if [ ${retval} -ne ${EXIT_CODE_SUCCESS} -a ${retval} -ne ${EXIT_CODE_WARNING} ]; then
+ print_error_msg ${kill_script} ${retval}