-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
83 additions
and
3 deletions.
There are no files selected for viewing
86 changes: 83 additions & 3 deletions
86
examples/ec2-vpc-region-vpcN-new/apps/test-instances/install-ssm.sh
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 |
|---|---|---|
| @@ -1,16 +1,96 @@ | ||
| #!/bin/bash -x | ||
|
|
||
| # passwd -d root | ||
| sudo yum install -y iperf iperf3 bind-utils curl nc awscli jq fping nmap | ||
| VERSION="1.3.2" | ||
|
|
||
| echo "# starring install-ssm.sh v$VERSION at $(date)" | ||
|
|
||
| echo "# disabling root password" | ||
| passwd -d root | ||
|
|
||
| echo "# installing packages" | ||
| sudo yum install -y --skip-broken iperf3 bind-utils curl nc awscli jq lsof policycoreutils-python | ||
|
|
||
| echo "# configuring AWS CLI" | ||
| REGION=$(curl --silent http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r .region) | ||
| aws configure --profile default set region $REGION | ||
| aws configure --profile default set output json | ||
| sudo aws configure --profile default set region $REGION | ||
| sudo aws configure --profile default set output json | ||
|
|
||
| sudo yum install -y https://s3.$REGION.amazonaws.com/amazon-ssm-$REGION/latest/linux_amd64/amazon-ssm-agent.rpm | ||
| echo "# setup ssm" | ||
|
|
||
| sudo yum install -y https://s3.$REGION.amazonaws.com/amazon-ssm-$REGION/latest/linux_amd64/amazon-ssm-agent.rpm | ||
| sudo systemctl enable amazon-ssm-agent | ||
| sudo systemctl start amazon-ssm-agent | ||
| sudo systemctl status amazon-ssm-agent | ||
|
|
||
| echo "# setup sysctl" | ||
| cat > /etc/sysctl.d/10-iperf3-sysctl.conf <<EOF | ||
| net.core.wmem_max = 4194304 | ||
| net.core.rmem_max = 12582912 | ||
| net.ipv4.tcp_rmem = 4096 87380 4194304 | ||
| net.ipv4.tcp_wmem = 4096 87380 4194304 | ||
| EOF | ||
|
|
||
| /sbin/sysctl -p /etc/sysctl.d/10-iperf3-sysctl.conf | ||
|
|
||
| echo "# setup iperf3 service" | ||
| sudo adduser iperf3 -s /sbin/nologin | ||
|
|
||
| cat > /tmp/iperf3.service <<EOF | ||
| [Unit] | ||
| Description=iperf3 Service | ||
| After=network.target | ||
| [Service] | ||
| Type=forking | ||
| # User=iperf3 | ||
| ExecStart=/usr/bin/iperf3 -s -D | ||
| ExecStop=/usr/bin/kill -KILL $MAINPID | ||
| Restart=on-abort | ||
| [Install] | ||
| WantedBy=multi-user.target | ||
| EOF | ||
|
|
||
| sudo cp /tmp/iperf3.service /etc/systemd/system/iperf3.service | ||
| rm /tmp/iperf3.service | ||
|
|
||
| sudo systemctl daemon-reload && sleep 1 | ||
| sudo systemctl start iperf3.service | ||
| sudo systemctl enable iperf3.service | ||
| # sudo systemctl status iperf3 | ||
|
|
||
| echo "# setup iperf3@ service" | ||
|
|
||
| cat > /tmp/iperf3@.service <<EOF | ||
| [Unit] | ||
| Description=iperf3 Service on port %i | ||
| After=network.target | ||
| [Service] | ||
| Type=forking | ||
| # User=iperf3 | ||
| # PermissionsStartOnly=true | ||
| # ExecStartPre=-/usr/bin/mkdir -p /var/run/iperf3 | ||
| # ExecStartPre=/usr/bin/chown iperf3 /var/run/iperf3 | ||
| ## this -I only works on a newer version of iperf3 (amazon linux2) | ||
| # ExecStart=/usr/bin/iperf3 -s -D -p %i -I /var/run/iperf3/iperf3.%i.pid | ||
| ExecStart=/usr/bin/iperf3 -s -D -p %i | ||
| ExecStop=/usr/bin/kill -KILL $MAINPID | ||
| # PIDFile=/var/run/iperf3/iperf3.%i.pid | ||
| Restart=on-abort | ||
| [Install] | ||
| WantedBy=multi-user.target | ||
| EOF | ||
|
|
||
| sudo cp /tmp/iperf3@.service /etc/systemd/system/iperf3@.service | ||
| rm /tmp/iperf3@.service | ||
|
|
||
| sudo systemctl daemon-reload && sleep 2 | ||
| for i in {5202..5210} | ||
| do | ||
| sudo systemctl start iperf3@${i}.service | ||
| sudo systemctl enable iperf3@${i}.service | ||
| done |