Skip to content

Commit 4a53136

Browse files
author
Gao Han
committed
Replace USER with CODEDEPLOY_USER to avoid env var conflict
1 parent 41e3296 commit 4a53136

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

init.d/codedeploy-agent

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ RETVAL=0
2222
[ -f /etc/profile ] && [ "`stat --format '%U %G' /etc/profile`" == "root root" ] && source /etc/profile
2323

2424
prog="codedeploy-agent"
25-
# Modify the following USER variable to run the codedeploy process as a non-root user
25+
# Modify the following CODEDEPLOY_USER variable to run the codedeploy process as a non-root user
2626
# Note: You also need to chown /opt/codedeploy /var/log/aws
27-
USER=""
27+
CODEDEPLOY_USER=""
2828
AGENT_ROOT="/opt/codedeploy-agent/"
2929
INSTALLER="/opt/codedeploy-agent/bin/install"
3030
BIN="/opt/codedeploy-agent/bin/codedeploy-agent-wrapper"
3131

3232
start() {
3333
echo -n $"Starting $prog:"
3434
cd $AGENT_ROOT
35-
if [ $USER ]; then
36-
nohup sudo -i -u $USER $BIN start >/dev/null </dev/null 2>&1 # Try to start the server
35+
if [ $CODEDEPLOY_USER ]; then
36+
nohup sudo -i -u $CODEDEPLOY_USER $BIN start >/dev/null </dev/null 2>&1 # Try to start the server
3737
else
3838
nohup $BIN start >/dev/null </dev/null 2>&1 # Try to start the server
3939
fi
@@ -43,8 +43,8 @@ start() {
4343
stop() {
4444
echo -n $"Stopping $prog:"
4545
cd $AGENT_ROOT
46-
if [ $USER ]; then
47-
nohup sudo -i -u $USER $BIN stop >/dev/null </dev/null 2>&1 # Try to stop the server
46+
if [ $CODEDEPLOY_USER ]; then
47+
nohup sudo -i -u $CODEDEPLOY_USER $BIN stop >/dev/null </dev/null 2>&1 # Try to stop the server
4848
else
4949
nohup $BIN stop >/dev/null </dev/null 2>&1 # Try to stop the server
5050
fi
@@ -54,8 +54,8 @@ stop() {
5454
restart() {
5555
echo -n $"Restarting $prog:"
5656
cd $AGENT_ROOT
57-
if [ $USER ]; then
58-
nohup sudo -i -u $USER $BIN restart >/dev/null </dev/null 2>&1 # Try to restart the server
57+
if [ $CODEDEPLOY_USER ]; then
58+
nohup sudo -i -u $CODEDEPLOY_USER $BIN restart >/dev/null </dev/null 2>&1 # Try to restart the server
5959
else
6060
nohup $BIN restart >/dev/null </dev/null 2>&1 # Try to restart the server
6161
fi
@@ -64,8 +64,8 @@ restart() {
6464

6565
status() {
6666
cd $AGENT_ROOT
67-
if [ $USER ]; then
68-
sudo -i -u $USER $BIN status # Status of the server
67+
if [ $CODEDEPLOY_USER ]; then
68+
sudo -i -u $CODEDEPLOY_USER $BIN status # Status of the server
6969
else
7070
$BIN status # Status of the server
7171
fi

0 commit comments

Comments
 (0)