Current Path : /etc/init.d/ |
|
Current File : //etc/init.d/ir_agent |
#!/bin/bash
#
# ir_agent Rapid7 Insight Agent
#
# chkconfig: 12345 90 90
# description: Rapid7 Insight Agent
# processname: ir_agent
# pidfile: /var/run/com.rapid7.ir_agent.pid
# Source function library.
. /etc/init.d/functions
prog="ir_agent"
executable="/opt/rapid7/ir_agent/ir_agent"
pidfile="/var/run/com.rapid7.ir_agent.pid"
start() {
echo -n $"Starting $prog: "
if [ -e /var/lock/subsys/ir_agent ] ; then
local pid=$(pidofproc -p "${pidfile}" "$executable")
if [ ! -z "${pid}" ] && checkpid "${pid}" ; then
echo -n $"ir_agent already running.";
failure $"ir_agent already running.";
echo
return 1
fi
fi
daemon --pidfile $pidfile $executable > /dev/null 2>&1 &
RETVAL=$?
if [ "$RETVAL" -eq 0 ] ; then
touch /var/lock/subsys/ir_agent
success
else
failure
fi
echo
return $RETVAL
}
wait_for_termination() {
local pid="$1" max_sec="$2"
[ -z "${pid}" ] && return 0
local waited_sec=0 poll_sec=1
while checkpid "${pid}" && [ "${waited_sec}" -le "${max_sec}" ] ; do
sleep "${poll_sec}"
waited_sec=$(($waited_sec + $poll_sec))
done
checkpid "${pid}" && return 1
return 0
}
stop() {
echo -n $"Stopping $prog: "
if [ ! -e /var/lock/subsys/ir_agent ]; then
echo -n $"ir_agent is not running."
failure $"ir_agent is not running."
echo
return 1;
fi
#: Get current pid (if any)
local pid=$(pidofproc -p "${pidfile}" "$executable")
#: Terminate the process, returns immediately
killproc $executable -INT
RETVAL=$?
echo
if [ "$RETVAL" -eq 0 ] ; then
if ! wait_for_termination "${pid}" "30" ; then
echo -n $"Killing $prog: "
killproc $executable -KILL
RETVAL=$?
echo
fi
rm -f /var/lock/subsys/ir_agent
fi
return $RETVAL
}
rhstatus() {
status -p $pidfile $prog
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading ir_agent daemon: "
killproc $executable -INT
RETVAL=$?
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
status)
rhstatus
;;
condrestart)
[ -f /var/lock/subsys/ir_agent ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}"
exit 1
esac
Copyright 2K16 - 2K18 Indonesian Hacker Rulez