Skip to content

Commit d1319ad

Browse files
committed
reverting .sh file that should have not changed
1 parent af18deb commit d1319ad

1 file changed

Lines changed: 57 additions & 39 deletions

File tree

Tools/src/create_darwin.sh

Lines changed: 57 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,67 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
2+
set -e
3+
set -u
4+
set -x
5+
set -o pipefail
6+
echo "****************************************"
7+
echo "Creating tar file for Mac OS X ${ARCH} "
8+
echo "****************************************"
29

10+
AGENT_VERSION=$(cat ${PREPKGPATH}/CWAGENT_VERSION | sed -e "s/-/+/g")
11+
echo "BUILD_SPACE: ${BUILD_SPACE} agent_version: ${AGENT_VERSION} pre-package location:${PREPKGPATH}"
312

4-
echo "Moving amazon-cloudwatch-agent-ctl binary and config.json to /tmp..."
5-
sudo mv /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl /tmp/
6-
sudo mv /opt/aws/amazon-cloudwatch-agent/bin/config.json /tmp/
7-
sudo mv /opt/aws/amazon-cloudwatch-agent/bin/CWAGENT_VERSION /tmp/
8-
# Step 3: Remove everything from /opt/aws/amazon-cloudwatch-agent/bin
9-
echo "Removing everything from /opt/aws/amazon-cloudwatch-agent/bin..."
10-
sudo rm -rf /opt/aws/amazon-cloudwatch-agent/bin/*
13+
mkdir -p ${BUILD_SPACE}/bin/darwin/${ARCH}/
1114

12-
# Step 4: Replace everything in bin with contents from /local/home/siprmp/amazon-cloudwatch-agent/build/bin/linux_amd64/
13-
echo "Copying files from /local/home/siprmp/amazon-cloudwatch-agent/build/bin/linux_amd64/ to /opt/aws/amazon-cloudwatch-agent/bin/..."
14-
sudo cp -r /home/ec2-user/amazon-cloudwatch-agent/build/bin/linux_amd64/* /opt/aws/amazon-cloudwatch-agent/bin/
15+
echo "Creating darwin folders"
16+
MACHINE_ROOT="/opt/aws/amazon-cloudwatch-agent/"
17+
BUILD_ROOT="${BUILD_SPACE}/private/darwin_${ARCH}"
18+
TAR_NAME="amazon-cloudwatch-agent.tar.gz"
1519

16-
# Step 5: Move amazon-cloudwatch-agent-ctl binary and config.json back to the bin directory
17-
echo "Moving amazon-cloudwatch-agent-ctl binary and config.json back to /opt/aws/amazon-cloudwatch-agent/bin/..."
18-
sudo mv /tmp/amazon-cloudwatch-agent-ctl /opt/aws/amazon-cloudwatch-agent/bin/
19-
sudo mv /tmp/config.json /opt/aws/amazon-cloudwatch-agent/bin/
20-
sudo mv /tmp/CWAGENT_VERSION /opt/aws/amazon-cloudwatch-agent/bin/
20+
echo "Creating darwin workspace"
21+
mkdir -p ${BUILD_ROOT}${MACHINE_ROOT}logs
22+
mkdir -p ${BUILD_ROOT}${MACHINE_ROOT}bin
23+
mkdir -p ${BUILD_ROOT}${MACHINE_ROOT}etc
24+
mkdir -p ${BUILD_ROOT}${MACHINE_ROOT}etc/amazon-cloudwatch-agent.d
25+
mkdir -p ${BUILD_ROOT}${MACHINE_ROOT}var
26+
mkdir -p ${BUILD_ROOT}${MACHINE_ROOT}doc
27+
mkdir -p ${BUILD_ROOT}/Library/LaunchDaemons
2128

22-
# Step 6: Stop CloudWatch Agent
23-
echo "Stopping CloudWatch Agent..."
24-
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a stop
29+
############################# create the symbolic links
30+
# log
31+
mkdir -p ${BUILD_ROOT}/var/log/amazon
32+
ln -f -s /opt/aws/amazon-cloudwatch-agent/logs ${BUILD_ROOT}/var/log/amazon/amazon-cloudwatch-agent
2533

26-
# Step 7: Remove CloudWatch Agent logs
27-
echo "Removing CloudWatch Agent logs..."
28-
sleep 2
29-
sudo rm /opt/aws/amazon-cloudwatch/logs/amazon-cloudwatch-agent.log
30-
sleep 5
31-
# Step 8: Print the status of CloudWatch Agent
32-
echo "Printing CloudWatch Agent status..."
33-
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status
34+
echo "Copying application files"
35+
cp ${PREPKGPATH}/LICENSE ${BUILD_ROOT}${MACHINE_ROOT}
36+
cp ${PREPKGPATH}/NOTICE ${BUILD_ROOT}${MACHINE_ROOT}
37+
cp ${PREPKGPATH}/THIRD-PARTY-LICENSES ${BUILD_ROOT}${MACHINE_ROOT}
38+
cp ${PREPKGPATH}/RELEASE_NOTES ${BUILD_ROOT}${MACHINE_ROOT}
39+
cp ${PREPKGPATH}/CWAGENT_VERSION ${BUILD_ROOT}${MACHINE_ROOT}bin/
40+
cp ${PREPKGPATH}/amazon-cloudwatch-agent ${BUILD_ROOT}${MACHINE_ROOT}bin/
41+
cp ${PREPKGPATH}/amazon-cloudwatch-agent-ctl ${BUILD_ROOT}${MACHINE_ROOT}bin/
42+
cp ${PREPKGPATH}/config-translator ${BUILD_ROOT}${MACHINE_ROOT}bin/
43+
cp ${PREPKGPATH}/config-downloader ${BUILD_ROOT}${MACHINE_ROOT}bin/
44+
cp ${PREPKGPATH}/amazon-cloudwatch-agent-config-wizard ${BUILD_ROOT}${MACHINE_ROOT}bin/
45+
cp ${PREPKGPATH}/start-amazon-cloudwatch-agent ${BUILD_ROOT}${MACHINE_ROOT}bin/
46+
cp ${PREPKGPATH}/opentelemetry-jmx-metrics.jar ${BUILD_ROOT}${MACHINE_ROOT}bin/
47+
cp ${PREPKGPATH}/common-config.toml ${BUILD_ROOT}${MACHINE_ROOT}etc/
48+
cp ${PREPKGPATH}/amazon-cloudwatch-agent-schema.json ${BUILD_ROOT}${MACHINE_ROOT}doc/
49+
cp ${PREPKGPATH}/com.amazon.cloudwatch.agent.plist ${BUILD_ROOT}/Library/LaunchDaemons/
3450

35-
# Step 9: Echo starting the agent
36-
echo "Starting the CloudWatch Agent..."
51+
echo "Setting permissions as required by launchd"
52+
chmod 600 ${BUILD_ROOT}/Library/LaunchDaemons/*
53+
chmod ug+rx ${BUILD_ROOT}${MACHINE_ROOT}bin/amazon-cloudwatch-agent
54+
chmod ug+rx ${BUILD_ROOT}${MACHINE_ROOT}bin/amazon-cloudwatch-agent-ctl
55+
chmod ug+rx ${BUILD_ROOT}${MACHINE_ROOT}bin/start-amazon-cloudwatch-agent
3756

38-
echo "Printing CloudWatch Agent status before start..."
39-
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status
57+
echo "Creating tar"
58+
(
59+
cd ${BUILD_ROOT}
60+
tar -czf $TAR_NAME *
61+
)
4062

41-
sudo chmod 777 -R /opt/aws/amazon-cloudwatch-agent/bin
63+
echo "Archive created at ${BUILD_ROOT}/${TAR_NAME}"
4264

43-
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -s -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json
44-
45-
echo "Printing CloudWatch Agent status after start..."
46-
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status
47-
48-
echo "Printing CloudWatch Agent logs..."
49-
sudo tail -f /opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log
65+
echo "Copying tarball to bin"
66+
mv ${BUILD_ROOT}/${TAR_NAME} ${BUILD_SPACE}/bin/darwin/${ARCH}/${TAR_NAME}
67+
ls -ltr ${BUILD_SPACE}/bin/darwin/${ARCH}/*.tar.gz

0 commit comments

Comments
 (0)