## Screen Dimensions
# Find current screen size
if [ -z "${COLUMNS}" ]; then
- COLUMNS=$(stty size)
+ COLUMNS=$(stty size < /dev/console)
COLUMNS=${COLUMNS##* }
fi
# When using remote connections, such as a serial port, stty size returns 0
-if [ "${COLUMNS}" = "0" ]; then
+if [ "${COLUMNS}" = "0" ]; then
COLUMNS=80
fi
# LOGLEVEL="1" --> Prevents all messages, expect panic messages, from
# appearing on the console.
# LOGLEVEL="8" --> Allow all messages to appear on the console.
-LOGLEVEL="4"
+LOGLEVEL="3"
# Timezone
export TZ="America/Montreal"
echo "Usage: print_status {success|warning|failure}"
return ${EXIT_CODE_FAILURE}
fi
-
+
case "$1" in
success)
${SUCCESS}
pid="${pid} ${apid}"
fi
done
-
+
# If the $pid variable contains anything (from the previous for loop) it
# means the daemon is already running.
if [ ! -n "${pid}" ]; then
fi
killproc_path ${1} /var/run ${2}
-
+
return ${?}
}
msg_log "Usage: killproc_path {program} {pid-directory} [signal]"
return ${EXIT_CODE_FAILURE}
fi
-
+
# Find the basename of the first parameter (the daemon's name without the
# path).
base=$(/usr/bin/basename ${1})
else
nolevel=1
fi
-
+
# The pidlist variable will contains the output of the pidof command. pidof
# will try to find the PID's that belong to a certain string; $base in this
# case.
pid="${pid} ${apid}"
fi
done
-
+
# If $pid contains something from the previous for loop it means one or
# more PID's were found that belongs to the processes to be killed.
if [ -n "${pid}" ]; then
msg_log "Usage: reloadproc {program} [signal]"
return ${EXIT_CODE_FAILURE}
fi
-
+
# Find the basename of the first parameter (the daemon's name without
# the path that was provided so /usr/sbin/syslogd becomes plain 'syslogd'
# after basename ran).
else
killlevel="-SIGHUP"
fi
-
+
# The pidlist variable will contains the output of the pidof command. pidof
# will try to find the PID's that belong to a certain string; $base in this
# case.
pid="${pid} ${apid}"
fi
done
-
+
# If $pid contains something from the previous for loop it means one or
# more PID's were found that belongs to the processes to be reloaded.
if [ -n "${pid}" ]; then
if [ ${?} -ne 0 ]; then
sleep 2
- if statusproc ${base} | grep "not running" 1> /dev/null 2>&1; then
+ if statusproc ${base} | grep -q "stopped"; then
return ${EXIT_CODE_FAILURE}
fi
fi
msg_log "Not running"
return ${EXIT_CODE_WARNING}
fi
-
+
return ${EXIT_CODE_SUCCESS}
}
fi
statusproc_path ${1} /var/run
-
+
return ${?}
}
msg_log "Usage: status {program} {pid-directory}"
return ${EXIT_CODE_FAILURE}
fi
-
+
# Find the basename of the first parameter (the daemon's name without the
# path).
base=$(/usr/bin/basename ${1})
if [ -f ${piddir}/${base}.pid ]; then
pid=$(head -1 ${piddir}/${base}.pid)
if [ -n "${pid}" ]; then
- echo "${base} not running but ${piddir}/${base}.pid exists"
+ echo "${base} stopped but ${piddir}/${base}.pid exists"
return ${EXIT_CODE_FAILURE}
fi
- else
- echo "${base} is not running"
fi
+
+ echo "${base} is stopped"
+ return ${EXIT_CODE_FAILURE}
}