CHips L MINI SHELL

CHips L pro

Current Path : /proc/3/task/3/cwd/proc/2/cwd/etc/rc3.d/
Upload File :
Current File : //proc/3/task/3/cwd/proc/2/cwd/etc/rc3.d/K02pxp-agent

#!/bin/bash
# pxp-agent        Init script for running the PCP Execution Protocol (PXP) agent daemon
#
# chkconfig: - 98 02
#
# description: Agent for the PCP Execution Protocol (PXP), based on
#              the Puppet Communications Protocol (PCP).
# processname: pxp-agent
# config: /etc/sysconfig/pxp-agent

# Source function library.
. /etc/rc.d/init.d/functions

[ -f /etc/sysconfig/pxp-agent ] && . /etc/sysconfig/pxp-agent

exec=/opt/puppetlabs/puppet/bin/pxp-agent
prog="pxp-agent"
desc="PXP agent"

lockfile=/var/lock/subsys/$prog
piddir=/var/run/puppetlabs
pidfile="${piddir}/${prog}.pid"
logdir=/var/log/puppetlabs
pid=$(cat $pidfile 2> /dev/null)
RETVAL=0

[ -x $exec ] || exit 5

# Determine if we can use the -p option to daemon, killproc, and status.
# RHEL < 5 can't.
if status | grep -q -- '-p' 2>/dev/null; then
    daemonopts="--pidfile $pidfile"
    pidopts="-p $pidfile"
    USEINITFUNCTIONS=true
fi

start() {
    echo -n $"Starting PXP agent: "
    mkdir -p $piddir $logdir
    daemon $daemonopts $exec ${PXP_AGENT_OPTIONS}
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch ${lockfile}
    return $RETVAL
}

stop() {
    echo -n $"Stopping PXP agent: "
    if [ "$USEINITFUNCTIONS" = "true" ]; then
        killproc $pidopts $exec
        RETVAL=$?
    else
        if [ -n "${pid}" ]; then
            kill -TERM $pid >/dev/null 2>&1
            RETVAL=$?
        fi
    fi

    pids=$(pgrep -u `whoami` -x $prog)
    # Ensure we killed all pxp-agent processes owned by the current user
    if [ -n "${pids}" ]; then
        trap '' TERM
        pkill -TERM  -u `whoami` -f $exec 2>/dev/null
        trap TERM
    fi

    echo
    [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
    return $RETVAL
}

reload() {
    echo -n $"Reloading PXP agent: "
    if [ "$USEINITFUNCTIONS" = "true" ]; then
        killproc $pidopts $exec -HUP
        RETVAL=$?
    else
        if [ -n "${pid}" ]; then
            kill -HUP $pid >/dev/null 2>&1
            RETVAL=$?
        else
            RETVAL=0
        fi
    fi
    echo
    return $RETVAL
}

restart() {
    stop
    start
}

rh_status() {
    if [ "$USEINITFUNCTIONS" = "true" ]; then
        status $pidopts $exec
        RETVAL=$?
        return $RETVAL
    else
        if [ -n "${pid}" ]; then
            if `ps -p $pid | grep $pid > /dev/null 2>&1`; then
                echo "${desc} (pid ${pid}) is running..."
                RETVAL=0
                return $RETVAL
            fi
        fi
        if [ -f "${pidfile}" ] ; then
            echo "${desc} dead but pid file exists"
            RETVAL=1
            return $RETVAL
        fi
        if [ -f "${lockfile}" ]; then
            echo "${desc} dead but subsys locked"
            RETVAL=2
            return $RETVAL
        fi
        echo "${desc} is stopped"
        RETVAL=3
        return $RETVAL
    fi
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}

case "$1" in
    start)
        start
    ;;
    stop)
        stop
    ;;
    restart)
        restart
    ;;
    reload|force-reload)
        reload
    ;;
    condrestart|try-restart)
        rh_status_q || exit 0
        restart
    ;;
    status)
        rh_status
    ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart}"
        exit 1
esac

exit $RETVAL

Copyright 2K16 - 2K18 Indonesian Hacker Rulez