HEX
Server: Apache/2.2.15 (CentOS)
System: Linux ip-10-0-2-146.eu-west-1.compute.internal 2.6.32-754.35.1.el6.centos.plus.x86_64 #1 SMP Sat Nov 7 11:33:42 UTC 2020 x86_64
User: root (0)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: //proc/11691/root/etc/rc5.d/S98codedeploy-agent
#!/bin/bash

# Init file for codedeploy-agent
#
# chkconfig: 2345 98 02
# description: codedeploy-agent processes the deployments created by AWS CodeDeploy and installs \
# the deployment artifacts on to this instance.

### BEGIN INIT INFO
# Provides:          codedeploy-agent
# Required-Start:    $all
# Required-Stop:     $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: AWS CodeDeploy Host Agent
# Description:       codedeploy-agent processes the deployments created by AWS CodeDeploy and installs
#                    the deployment artifacts on to this instance.
### END INIT INFO

COMMAND=$1
RETVAL=0
[ -f /etc/profile ] && [ "`stat --format '%U %G' /etc/profile`" == "root root" ] && source /etc/profile

prog="codedeploy-agent"
# Modify the following CODEDEPLOY_USER variable to run the codedeploy process as a non-root user
# Note: You also need to chown /opt/codedeploy /var/log/aws 
CODEDEPLOY_USER=""
AGENT_ROOT="/opt/codedeploy-agent/"
INSTALLER="/opt/codedeploy-agent/bin/install"
BIN="/opt/codedeploy-agent/bin/codedeploy-agent"

start() {
        echo -n $"Starting $prog:"
        cd $AGENT_ROOT
        if [ $CODEDEPLOY_USER ]; then
          nohup sudo -i -u $CODEDEPLOY_USER $BIN start >/dev/null </dev/null 2>&1 # Try to start the server
        else
          nohup $BIN start >/dev/null </dev/null 2>&1  # Try to start the server
        fi
        exit $?
}

stop() {
        echo -n $"Stopping $prog:"
        cd $AGENT_ROOT
        if [ $CODEDEPLOY_USER ]; then
          nohup sudo -i -u $CODEDEPLOY_USER $BIN stop >/dev/null </dev/null 2>&1  # Try to stop the server
        else
          nohup $BIN stop >/dev/null </dev/null 2>&1  # Try to stop the server
        fi
        exit $?
}

restart() {
        echo -n $"Restarting $prog:"
        cd $AGENT_ROOT
        if [ $CODEDEPLOY_USER ]; then
          nohup sudo -i -u $CODEDEPLOY_USER $BIN restart >/dev/null </dev/null 2>&1  # Try to restart the server
        else
          nohup $BIN restart >/dev/null </dev/null 2>&1  # Try to restart the server
        fi
        exit $?
}

status() {
        cd $AGENT_ROOT
        if [ $CODEDEPLOY_USER ]; then
          sudo -i -u $CODEDEPLOY_USER $BIN status # Status of the server
        else
          $BIN status # Status of the server
        fi
        exit $?
}

update() {
        echo -n $"Updating $prog:"
        cd $AGENT_ROOT
        $INSTALLER auto #Update the agent
}

case "$COMMAND" in
        start)
                start
                ;;
        start-no-update)
                start
                ;;
        start-with-update)
                update
                start
                ;;
        stop)
                stop
                ;;
        restart)
                restart
                ;;
        force-reload)
                stop
                start
                ;;
        status)
                status
                ;;
        *)
                echo $"Usage: $0 {start|stop|status|restart}"
esac