Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 5 additions & 28 deletions init.d/codedeploy-agent
Original file line number Diff line number Diff line change
Expand Up @@ -17,69 +17,46 @@
# the deployment artifacts on to this instance.
### END INIT INFO

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

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

prog="codedeploy-agent"
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 [ $USER ]; then
daemon --user=$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
nohup $BIN start >/dev/null </dev/null 2>&1 # Try to start the server
exit $?
}

stop() {
echo -n $"Stopping $prog:"
cd $AGENT_ROOT
if [ $USER ]; then
daemon --user=$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
nohup $BIN stop >/dev/null </dev/null 2>&1 # Try to stop the server
exit $?
}

restart() {
echo -n $"Restarting $prog:"
cd $AGENT_ROOT
if [ $USER ]; then
daemon --user=$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
nohup $BIN restart >/dev/null </dev/null 2>&1 # Try to restart the server
exit $?
}

status() {
cd $AGENT_ROOT
if [ $USER ]; then
daemon --user=$USER $BIN status # Status of the server
else
$BIN status # Status of the server
fi
$BIN status # Status of the server
exit $?
}

update() {
echo -n $"Updating $prog:"
cd $AGENT_ROOT
if [ $USER ]; then
daemon --user=$USER sudo $INSTALLER auto #Update the agent
else
$INSTALLER auto #Update the agent
fi
$INSTALLER auto #Update the agent
}

case "$1" in
Expand Down
23 changes: 5 additions & 18 deletions lib/instance_agent/platform/linux_util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,12 @@ def self.supported_oses()
['linux']
end

def self.prepare_script_command(script, absolute_cmd_path)
runas = !!script.runas
sudo = !!script.sudo

if runas && sudo
return 'sudo su ' + script.runas + ' -c ' + absolute_cmd_path
end

if runas && !sudo
return 'su ' + script.runas + ' -c ' + absolute_cmd_path
def self.prepare_script_command(script, absolute_path)
script_command = absolute_path
if(!script.runas.nil?)
script_command = 'su ' + script.runas + ' -c ' + absolute_path
end

if !runas && sudo
return 'sudo ' + absolute_cmd_path
end

# If neither sudo or runas is specified, execute the
# command as the code deploy agent user
absolute_cmd_path
script_command
end

def self.quit()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def parse_hooks(hooks_hash)
current_hook_scripts << InstanceAgent::Plugins::CodeDeployPlugin::ApplicationSpecification::ScriptInfo.new(script['location'].to_s.strip,
{
:runas => script.has_key?('runas') && !script['runas'].nil? ? script['runas'].to_s.strip : nil,
:sudo => script['sudo'],
:timeout => script['timeout']
})
else
Expand Down Expand Up @@ -141,4 +140,4 @@ def parse_context(context)
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ module ApplicationSpecification
#Helper Class for storing data parsed from hook script maps
class ScriptInfo

attr_reader :location, :runas, :sudo, :timeout
attr_reader :location, :runas, :timeout
def initialize(location, opts = {})
location = location.to_s
if(location.empty?)
raise AppSpecValidationException, 'Scripts need a location value'
end
@location = location
@runas = opts[:runas]
@sudo = opts[:sudo]
@timeout = opts[:timeout] || 3600
@timeout = @timeout.to_i
if(@timeout <= 0)
Expand All @@ -25,4 +24,4 @@ def initialize(location, opts = {})
end
end
end
end
end
35 changes: 0 additions & 35 deletions test/instance_agent/platform/linux_util_test.rb

This file was deleted.