Project

General

Profile

« Previous | Next » 

Revision 31628b0f

Added by Benoît PECCATTE about 8 years ago

Fixes #8076: rudder agent status

View differences:

share/commands/agent-enable
. "${BASEDIR}/../lib/common.sh"
QUIET=false
OPTIONS=""
while getopts "sqc" opt; do
case $opt in
......
;;
q)
QUIET=true
OPTION="${OPTIONS} -q"
;;
c)
clear_colors
OPTION="${OPTIONS} -c"
;;
esac
done
rm -f /opt/rudder/etc/disable-agent
if [ -x /usr/bin/startsrc ]
then
CMD="startsrc -s rudder-agent"
elif [ -x /usr/sbin/service ]
then
CMD="service rudder-agent start"
elif [ -x /etc/init.d/rudder-agent ]
then
CMD="/etc/init.d/rudder-agent start"
fi
if [ "${START}" = "y" ]
then
if [ -n "${CMD}" ]
then
$CMD
else
printf "${RED}error${NORMAL}: Don't know how to start rudder agent.\n" 1>&2
echo "Agent not started !" 1>&2
fi
[ "$QUIET" = false ] && printf "${GREEN}ok${NORMAL}: Rudder agent has been enabled.\n"
"${BASEDIR}/agent-start" ${OPTIONS}
else
if [ -n "${CMD}" ]
then
[ "$QUIET" = false ] && printf "${GREEN}ok${NORMAL}: Rudder agent has been enabled but not started, use '$CMD' or wait for next cron run.\n"
[ "$QUIET" = false ] && echo "You can use the -s option to automatically start it"
else
[ "$QUIET" = false ] && printf "${GREEN}ok${NORMAL}: Rudder agent has been enabled but not started, wait for next cron run.\n"
fi
[ "$QUIET" = false ] && printf "${GREEN}ok${NORMAL}: Rudder agent has been enabled but not started, wait for next cron run.\n"
fi
share/commands/agent-start
#!/bin/sh
# @description start the agent
# @man Start the agent service using the appropriate service manager.
# @man +
# @man *Options*:
# @man +
# @man *-q*: run the agent in quiet mode (display only error messages)
# @man +
# @man *-c*: run the agent without color output
. "${BASEDIR}/../lib/common.sh"
QUIET=false
while getopts "qc" opt; do
case $opt in
q)
QUIET=true
;;
c)
clear_colors
;;
esac
done
service_action "rudder-agent" "start"
exit $?
share/commands/agent-status
#!/bin/sh
# @description show the agent status
# @man +
# @man *Options*:
# @man +
# @man *-q*: run the agent in quiet mode (display only error messages)
# @man +
# @man *-c*: run the agent without color output
. "${BASEDIR}/../lib/common.sh"
QUIET=false
while getopts "qc" opt; do
case $opt in
q)
QUIET=true
;;
c)
clear_colors
;;
esac
done
service_action "rudder-agent" "status"
exit $?
share/commands/agent-stop
#!/bin/sh
# @description stop the agent
# @man Stop the agent service using the appropriate service manager.
# @man +
# @man *Options*:
# @man +
# @man *-q*: run the agent in quiet mode (display only error messages)
# @man +
# @man *-c*: run the agent without color output
. "${BASEDIR}/../lib/common.sh"
QUIET=false
while getopts "qc" opt; do
case $opt in
q)
QUIET=true
;;
c)
clear_colors
;;
esac
done
service_action "rudder-agent" "stop"
exit $?
share/lib/common.sh
NORMAL=""
}
service_action() {
service="$1"
action="$2"
if [ -x /usr/sbin/service ]; then
CMD="service ${service} ${action}"
elif [ -x /etc/init.d/${service} ]; then
CMD="/etc/init.d/${service} ${action}"
elif [ "${action}" = "start" ] && [ -x /usr/bin/startsrc ]; then
CMD="startsrc -s ${service}"
elif [ "${action}" = "stop" ] && [ -x /usr/bin/stopsrc ]; then
CMD="stopsrc -s ${service}"
fi
if [ -n "${CMD}" ]
then
$CMD
RET="$?"
if [ "${action}" = "start" ] || [ "${action}" = "stop" ]; then
if [ $RET -eq 0 ]
then
[ "$QUIET" = false ] && printf "${GREEN}ok${NORMAL}: service ${service} has been ${action}ed\n"
else
[ "$QUIET" = false ] && printf "${RED}error${NORMAL}: service ${service} could not be ${action}ed\n"
fi
fi
return $RET
else
printf "${RED}error${NORMAL}: Don't know how to ${action} ${service}.\n" 1>&2
return 1
fi
}
# Colors configuration (enable colors only if stdout is a terminal)
if [ -t 1 ]; then
COLOR="-Calways"

Also available in: Unified diff