-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from ccloes-intuit/add_sudo_support
Add sudo support
- Loading branch information
Showing
7 changed files
with
97 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[Unit] | ||
Description=AWS CodeDeploy Host Agent | ||
|
||
[Service] | ||
Type=forking | ||
ExecStart=/opt/codedeploy-agent/bin/codedeploy-agent start | ||
ExecStop=/opt/codedeploy-agent/bin/codedeploy-agent stop | ||
RemainAfterExit=no | ||
# Comment out the following line to run the agent as the codedeploy user | ||
# Note: The user must first exist on the system | ||
#User=codedeploy | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'test_helper' | ||
|
||
class LinuxUtilTest < InstanceAgentTestCase | ||
context 'Testing building command with sudo' do | ||
setup do | ||
@script_mock = Struct.new :sudo, :runas | ||
end | ||
|
||
should 'return command with sudo with runas user deploy' do | ||
mock = @script_mock.new true, "deploy" | ||
assert_equal 'sudo su deploy -c my_script.sh', | ||
InstanceAgent::LinuxUtil.prepare_script_command(mock, "my_script.sh") | ||
end | ||
|
||
should 'return command without sudo with runas user deploy' do | ||
mock = @script_mock.new nil, "deploy" | ||
assert_equal 'su deploy -c my_script.sh', | ||
InstanceAgent::LinuxUtil.prepare_script_command(mock, "my_script.sh") | ||
end | ||
|
||
should 'return command without sudo or runas user' do | ||
mock = @script_mock.new nil, nil | ||
assert_equal 'my_script.sh', | ||
InstanceAgent::LinuxUtil.prepare_script_command(mock, "my_script.sh") | ||
end | ||
|
||
should 'return command with sudo' do | ||
mock = @script_mock.new true, nil | ||
assert_equal 'sudo my_script.sh', | ||
InstanceAgent::LinuxUtil.prepare_script_command(mock, "my_script.sh") | ||
end | ||
|
||
end | ||
end | ||
|