From 8a5b577bba7017816b2beaa056d493c170b5d5c9 Mon Sep 17 00:00:00 2001 From: Abhilash Balaji Date: Mon, 19 Jun 2023 14:53:50 +0200 Subject: [PATCH 1/6] feat: init walking workload fix: init dc fix --- terrastick/Deployment/scripts/das.sh | 2 +- .../PlayerEmulations/TrClient/TClient.cs | 28 +++++++++++++++---- .../TrProtocol/Models/Vector2.cs | 7 +++++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/terrastick/Deployment/scripts/das.sh b/terrastick/Deployment/scripts/das.sh index 5bfb1cbf..575c7c39 100755 --- a/terrastick/Deployment/scripts/das.sh +++ b/terrastick/Deployment/scripts/das.sh @@ -149,7 +149,7 @@ remote_commands=$(cat <(_ => Send(new SendPassword { Password = password })); //On(_=> ) connected = true; diff --git a/terrastick/PlayerEmulations/TrProtocol/Models/Vector2.cs b/terrastick/PlayerEmulations/TrProtocol/Models/Vector2.cs index 80692b30..ec67582d 100644 --- a/terrastick/PlayerEmulations/TrProtocol/Models/Vector2.cs +++ b/terrastick/PlayerEmulations/TrProtocol/Models/Vector2.cs @@ -18,4 +18,11 @@ public override string ToString() { return $"[{X}, {Y}]"; } + public static Vector2 Lerp(Vector2 origin,Vector2 dest, float amount) + { + var X = origin.X + (dest.X - origin.X) * amount; + var Y = origin.Y + (dest.Y - origin.Y) * amount; + return new Vector2(X, Y); + + } } From 9fb737e5e5aadaad923f24bcb750a6adc2f08c27 Mon Sep 17 00:00:00 2001 From: Abhilash Balaji Date: Tue, 20 Jun 2023 17:22:09 +0200 Subject: [PATCH 2/6] init walk workload --- .../PlayerEmulations/TrClient/TClient.cs | 51 +++++++++++++++++-- .../PlayerEmulations/TrClientTest/Program.cs | 2 +- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/terrastick/PlayerEmulations/TrClient/TClient.cs b/terrastick/PlayerEmulations/TrClient/TClient.cs index 58ebb9d7..205ddafc 100644 --- a/terrastick/PlayerEmulations/TrClient/TClient.cs +++ b/terrastick/PlayerEmulations/TrClient/TClient.cs @@ -6,6 +6,7 @@ using System.Net.Sockets; using System.Text; using System.Threading; +using System.Threading.Tasks; using TrProtocol; using TrProtocol.Models; using TrProtocol.Packets; @@ -241,6 +242,14 @@ void UpdateSpawn(UpdatePlayer pkt) this.RunTeleportWorkLoad(int.Parse(time)); } + if (pkt.Text._text.Contains("start") && this.workload == "WLK") + { + this.ChatText("Starting walk work load"); + string time = pkt.Text._text.Split(' ')[2]; + + this.RunWalkWorkLoadAsync(int.Parse(time)); + + } }); @@ -248,6 +257,34 @@ void UpdateSpawn(UpdatePlayer pkt) } + private async Task RunWalkWorkLoadAsync(int v) + { + int secs = v; + Random rand = new Random(); + int spawnTime = rand.Next(500, 1000); + var timer = new PeriodicTimer(TimeSpan.FromMilliseconds(spawnTime)); + + while (await timer.WaitForNextTickAsync()) + { + var xPos = this.SpawnX; + var yPos = this.SpawnY; + var rand1 = new Random(); + // random delta between -10 and 10 + var deltaX = rand1.Next(-10, 10); + + var newXPos = (rand.Next() >= 0.5) ? xPos + deltaX : xPos - deltaX; + await this.WalkPlayer(xPos, yPos, newXPos, yPos); + this.ChatText("Teleported to " + newXPos + " " + yPos); + if (secs-- == 0) + { + this.ChatText("WORKLOAD COMPLETE"); + break; + } + } + timer.Dispose(); + } + + public bool connected = false; public void GameLoop(string host, int port, string password) @@ -310,14 +347,16 @@ public void TeleportPlayer(int x, int y) // Home Position Y Single Home Position for Potion of Return, only sent if UsedPotionofReturn flag is true }); + this.SpawnX = x; + this.SpawnY = y; } - public void WalkPlayer(int x1,int y1,int x2,int y2) + public async Task WalkPlayer(int x1,int y1,int x2,int y2) { var lerp = new Vector2 { X = x1, Y = y1 }; var lerp2 = new Vector2 { X = x2, Y = y2 }; - var timer = new PeriodicTimer(TimeSpan.FromMilliseconds(10)); - while (timer.WaitForNextTickAsync().Result) + var timer = new PeriodicTimer(TimeSpan.FromMilliseconds(1000)); + while (await timer.WaitForNextTickAsync()) { lerp = Vector2.Lerp(lerp, lerp2, 0.5f); Send(new UpdatePlayer @@ -328,9 +367,11 @@ public void WalkPlayer(int x1,int y1,int x2,int y2) Bit3 = 0, Bit4 = 0, SelectedItem = 0, - Position = lerp, - Velocity = new Vector2 { X = 0, Y = 0 } + Position = new Vector2 { X = lerp.X, Y = lerp.Y }, + Velocity = new Vector2 { X = lerp2.X - lerp.X, Y = lerp2.Y - lerp.Y } }); + this.SpawnX = (int)lerp.X; + this.SpawnY = (int)lerp.Y; } } private void GameLoopInternal(string password) diff --git a/terrastick/PlayerEmulations/TrClientTest/Program.cs b/terrastick/PlayerEmulations/TrClientTest/Program.cs index 43ea1f64..47bfa5af 100644 --- a/terrastick/PlayerEmulations/TrClientTest/Program.cs +++ b/terrastick/PlayerEmulations/TrClientTest/Program.cs @@ -19,7 +19,7 @@ class Program static void Main(string[] args) { string ip = "127.0.0.1"; - string workload = "TEL"; + string workload = "WLK"; string name = "BOT"; string logpath = "terrastick_bot_logs"; From 5c5bb8e7d3694f9a9edd13e49f4aecaf6a3be686 Mon Sep 17 00:00:00 2001 From: Abhilash Balaji Date: Thu, 22 Jun 2023 12:29:19 +0200 Subject: [PATCH 3/6] hostname added to botname --- terrastick/PlayerEmulations/TrClient/TClient.cs | 5 ++--- terrastick/PlayerEmulations/TrClientTest/Program.cs | 5 +++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/terrastick/PlayerEmulations/TrClient/TClient.cs b/terrastick/PlayerEmulations/TrClient/TClient.cs index 205ddafc..f1e05c1e 100644 --- a/terrastick/PlayerEmulations/TrClient/TClient.cs +++ b/terrastick/PlayerEmulations/TrClient/TClient.cs @@ -261,8 +261,7 @@ private async Task RunWalkWorkLoadAsync(int v) { int secs = v; Random rand = new Random(); - int spawnTime = rand.Next(500, 1000); - var timer = new PeriodicTimer(TimeSpan.FromMilliseconds(spawnTime)); + var timer = new PeriodicTimer(TimeSpan.FromMilliseconds(v * 1000)); while (await timer.WaitForNextTickAsync()) { @@ -270,7 +269,7 @@ private async Task RunWalkWorkLoadAsync(int v) var yPos = this.SpawnY; var rand1 = new Random(); // random delta between -10 and 10 - var deltaX = rand1.Next(-10, 10); + var deltaX = rand1.Next(-100, 100); var newXPos = (rand.Next() >= 0.5) ? xPos + deltaX : xPos - deltaX; await this.WalkPlayer(xPos, yPos, newXPos, yPos); diff --git a/terrastick/PlayerEmulations/TrClientTest/Program.cs b/terrastick/PlayerEmulations/TrClientTest/Program.cs index 47bfa5af..00513828 100644 --- a/terrastick/PlayerEmulations/TrClientTest/Program.cs +++ b/terrastick/PlayerEmulations/TrClientTest/Program.cs @@ -19,8 +19,9 @@ class Program static void Main(string[] args) { string ip = "127.0.0.1"; - string workload = "WLK"; - string name = "BOT"; + string workload = "TEL"; + // name is botname and last 5 characters of hostname + string name = "BOT_" + Environment.MachineName.Substring(Environment.MachineName.Length - 5); string logpath = "terrastick_bot_logs"; if (Environment.GetEnvironmentVariable("TERRASTICK_IP") != null) From 7730fc98f8937ac3e9bb01cdcc5d63436aaffe39 Mon Sep 17 00:00:00 2001 From: Abhilash Balaji Date: Thu, 22 Jun 2023 14:08:35 +0200 Subject: [PATCH 4/6] fix: dc issues fixed --- .../Deployment/scripts/configs/das-config.txt | 14 +++++++------- terrastick/Deployment/scripts/das.sh | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/terrastick/Deployment/scripts/configs/das-config.txt b/terrastick/Deployment/scripts/configs/das-config.txt index 1968f9f8..7f57fc85 100644 --- a/terrastick/Deployment/scripts/configs/das-config.txt +++ b/terrastick/Deployment/scripts/configs/das-config.txt @@ -1,10 +1,10 @@ -VUNET_USERNAME=aba448 -NUM_NODES=4 -RESERVE_DURATION=00:30:00 +VUNET_USERNAME=abi354 +NUM_NODES=6 +RESERVE_DURATION=00:10:00 DAS_VERSION_TO_USE=5 -DAS5_USERNAME=aba448 -DAS6_USERNAME=aba448 +DAS5_USERNAME=abi354 +DAS6_USERNAME=abi354 WORLD_NAME=2022DistSys -TERRASTICK_VERSION=terrastick-test-v0.5 +TERRASTICK_VERSION=terrastick-test-v0.7 TERRASTICK_WORKLOAD=TEL -TERRASTICK_IP=10.141.0.0 \ No newline at end of file +TERRASTICK_IP=10.141.0.0 diff --git a/terrastick/Deployment/scripts/das.sh b/terrastick/Deployment/scripts/das.sh index 575c7c39..d3f057b4 100755 --- a/terrastick/Deployment/scripts/das.sh +++ b/terrastick/Deployment/scripts/das.sh @@ -149,7 +149,7 @@ remote_commands=$(cat < Date: Thu, 22 Jun 2023 20:31:10 +0200 Subject: [PATCH 5/6] re-write-of-aws-sh --- terrastick/Deployment/scripts/aws.sh | 542 ++++++++++++++++++--------- 1 file changed, 375 insertions(+), 167 deletions(-) diff --git a/terrastick/Deployment/scripts/aws.sh b/terrastick/Deployment/scripts/aws.sh index 75816c36..90959f6f 100755 --- a/terrastick/Deployment/scripts/aws.sh +++ b/terrastick/Deployment/scripts/aws.sh @@ -1,5 +1,9 @@ #!/bin/bash +# Define the required variables +EXP_TIME=$(date +%Y-%m-%d-%H-%M-%S) +DIR_NAME="terraria-experiment-$EXP_TIME" + # load the config file . ./configs/aws-config.txt @@ -15,123 +19,261 @@ INSTANCE_TYPE=$INSTANCE_TYPE AMI_ID=$BASE_AMI_ID NUM_BOT_INSTANCES=$NUM_BOT_INSTANCES -# Check if the key pair exists and create it if not -KEY_PAIR_EXISTS=$(aws ec2 describe-key-pairs \ - --region "$AWS_REGION" \ - --filters "Name=key-name,Values=$KEY_PAIR_NAME" \ - --query 'KeyPairs[0].KeyName' \ - --output text) +# Function to create key pair +create_key_pair() { + local key_pair_name=$1 + local region=$2 -if [ "$KEY_PAIR_EXISTS" == "None" ]; then - echo "Creating a temp folder..." - mkdir -p temp - echo "Creating new key pair: $KEY_PAIR_NAME..." - aws ec2 create-key-pair \ - --region "$AWS_REGION" \ - --key-name $KEY_PAIR_NAME \ - --query 'KeyMaterial' \ - --output text > temp/$KEY_PAIR_NAME.pem - - chmod 400 temp/$KEY_PAIR_NAME.pem - ssh-keygen -y -f temp/$KEY_PAIR_NAME.pem > temp/$KEY_PAIR_NAME.pub - - # Set the correct permissions for the key pair - chmod 400 temp/$KEY_PAIR_NAME.pem -else - echo "Key pair $KEY_PAIR_NAME already exists." -fi - -# Check if the security group exists and create it if not -SECURITY_GROUP_ID=$(aws ec2 describe-security-groups \ - --region "$AWS_REGION" \ - --filters "Name=group-name,Values=$SECURITY_GROUP_NAME" \ - --query 'SecurityGroups[0].GroupId' \ - --output text) + local key_pair_exists=$(aws ec2 describe-key-pairs \ + --region "$region" \ + --filters "Name=key-name,Values=$key_pair_name" \ + --query 'KeyPairs[0].KeyName' \ + --output text) -if [ "$SECURITY_GROUP_ID" == "None" ]; then - echo "Creating new security group: $SECURITY_GROUP_NAME..." - SECURITY_GROUP_ID=$(aws ec2 create-security-group \ + if [ "$key_pair_exists" == "None" ]; then + echo "Creating a temp folder..." + mkdir -p temp + echo "Creating new key pair: $key_pair_name..." + aws ec2 create-key-pair \ + --region "$region" \ + --key-name $key_pair_name \ + --query 'KeyMaterial' \ + --output text > temp/$key_pair_name.pem + + chmod 400 temp/$key_pair_name.pem + ssh-keygen -y -f temp/$key_pair_name.pem > temp/$key_pair_name.pub + + # Set the correct permissions for the key pair + chmod 400 temp/$key_pair_name.pem + else + echo "Key pair $key_pair_name already exists." + fi +} + +cleanup_instances() { + instance_type=$1 + echo "Cleaning up ${instance_type} instances..." + instance_ids=$(aws ec2 describe-instances --filters "Name=tag:EXP_TIME,Values=$LAST_EXP_TIME" "Name=tag:TYPE,Values=$instance_type" --query "Reservations[].Instances[].InstanceId" --output text | tr '\t' ' ') + + if [ -n "$instance_ids" ]; then + aws ec2 terminate-instances --instance-ids $instance_ids || { echo "Failed to terminate $instance_type instances."; exit 1; } + echo "$instance_type instances cleaned up successfully." + else + echo "No $instance_type instances found to clean up." + fi +} + + +# Function to clean up previous experiment +cleanup_previous_experiment() { + if [ -f temp/last_exp_time.txt ]; then + . temp/last_exp_time.txt + + if [ -n "$LAST_EXP_TIME" ]; then + echo "Last experiment time: $LAST_EXP_TIME" + echo "The previous experiment will be cleaned up..." + + cleanup_instances "server" + cleanup_instances "bot" + cleanup_instances "prometheus" + + echo "Cleanup completed. LAST_EXP_TIME entry will be removed." + rm temp/last_exp_time.txt # Delete the last experiment time file after cleanup + else + echo "It appears to be the first time running the experiment as LAST_EXP_TIME is not set." + fi + else + echo "First time running the experiment. No cleanup needed." + fi +} + +# Function to ask the user if they want to start a new experiment +start_new_experiment() { + local exp_time=$1 + + while true; do + read -r -p "Do you want to start a new experiment? [y/N] " START_NEW_EXP + case $START_NEW_EXP in + [Yy]* ) + echo "Starting new experiment..." + echo "LAST_EXP_TIME=$exp_time" > temp/last_exp_time.txt + break;; + [Nn]* ) + echo "Not starting new experiment. Exiting script." + exit;; + * ) echo "Please answer yes or no.";; + esac + done +} + +# Function to manage the security group +manage_security_group() { + SECURITY_GROUP_ID=$(aws ec2 describe-security-groups \ --region "$AWS_REGION" \ - --group-name $SECURITY_GROUP_NAME \ - --description "Security group for Terraria server and bot" \ - --query 'GroupId' \ + --filters "Name=group-name,Values=$SECURITY_GROUP_NAME" \ + --query 'SecurityGroups[0].GroupId' \ --output text) - # getting the default vpc cidr block - DEFAULT_VPC_CIDR=$(aws ec2 describe-vpcs \ - --filters Name=isDefault,Values=true \ - --query 'Vpcs[0].CidrBlock' \ + if [ "$SECURITY_GROUP_ID" == "None" ]; then + echo "Creating new security group: $SECURITY_GROUP_NAME..." + SECURITY_GROUP_ID=$(aws ec2 create-security-group \ + --region "$AWS_REGION" \ + --group-name $SECURITY_GROUP_NAME \ + --description "Security group for Terraria server and bot" \ + --query 'GroupId' \ + --output text) + + # getting the default vpc cidr block + DEFAULT_VPC_CIDR=$(aws ec2 describe-vpcs \ + --filters Name=isDefault,Values=true \ + --query 'Vpcs[0].CidrBlock' \ + --region "$AWS_REGION" \ + --output text) + + # Add rules to the security group to allow necessary traffic + aws ec2 authorize-security-group-ingress \ + --region "$AWS_REGION" \ + --group-id "$SECURITY_GROUP_ID" \ + --protocol tcp \ + --port 7777 \ + --cidr "$DEFAULT_VPC_CIDR" + + aws ec2 authorize-security-group-ingress \ + --region "$AWS_REGION" \ + --group-id "$SECURITY_GROUP_ID" \ + --protocol tcp \ + --port 9256 \ + --cidr "$DEFAULT_VPC_CIDR" + + aws ec2 authorize-security-group-ingress \ + --region "$AWS_REGION" \ + --group-id "$SECURITY_GROUP_ID" \ + --protocol tcp \ + --port 9090 \ + --cidr "$DEFAULT_VPC_CIDR" + else + echo "Security group $SECURITY_GROUP_NAME already exists." + fi +} + +# Function to create an instance +create_instance() { + instance_name=$1 + instance_type=$2 + instance_id=$(aws ec2 run-instances \ --region "$AWS_REGION" \ + --image-id "$AMI_ID" \ + --count 1 \ + --instance-type "$INSTANCE_TYPE" \ + --key-name $KEY_PAIR_NAME \ + --security-group-ids "$SECURITY_GROUP_ID" \ + --query 'Instances[0].InstanceId' \ --output text) - - # Add rules to the security group to allow necessary traffic - aws ec2 authorize-security-group-ingress \ + tag_instance "$instance_id" "$instance_name" "$instance_type" + echo $instance_id +} + +# Function to tag an instance +tag_instance() { + instance_id=$1 + instance_name=$2 + instance_type=$3 + aws ec2 create-tags \ --region "$AWS_REGION" \ - --group-id "$SECURITY_GROUP_ID" \ - --protocol tcp \ - --port 22 \ - --cidr "0.0.0.0/0" # Adjust the CIDR block to restrict access as needed + --resources "$instance_id" \ + --tags Key=Name,Value="$instance_name" Key=EXP_TIME,Value="$EXP_TIME" Key=TYPE,Value="$instance_type" +} + +# Function to create bot instances +create_bot_instances() { + declare -a bot_instance_ids + for ((i=1; i<=$NUM_BOT_INSTANCES; i++)) + do + bot_instance_id=$(create_instance "bot$i" "bot") + bot_instance_ids+=($bot_instance_id) + done + echo "${bot_instance_ids[@]}" +} + +# Function to get an instance state +get_instance_state() { + instance_id=$1 + instance_name=$2 + echo "$instance_name state:" + aws ec2 describe-instances --instance-ids "$instance_id" --query 'Reservations[].Instances[].State.Name' +} + +# Function to wait for instances to be running +wait_for_instances() { + instance_ids=("$@") + for instance_id in "${instance_ids[@]}" + do + aws ec2 wait instance-running --instance-ids "$instance_id" + done +} - aws ec2 authorize-security-group-ingress \ +# Function for AWS Availability +get_aws_availability_zone() { + instance_id=$1 + echo $(aws ec2 describe-instances \ --region "$AWS_REGION" \ - --group-id "$SECURITY_GROUP_ID" \ - --protocol tcp \ - --port 7777 \ - --cidr "$DEFAULT_VPC_CIDR" -else - echo "Security group $SECURITY_GROUP_NAME already exists." -fi - -# Create the Terraria server instance -echo "Creating Terraria server instance..." -TERRARIA_SERVER_INSTANCE_ID=$(aws ec2 run-instances \ - --region "$AWS_REGION" \ - --image-id "$AMI_ID" \ - --count 1 \ - --instance-type "$INSTANCE_TYPE" \ - --key-name $KEY_PAIR_NAME \ - --security-group-ids "$SECURITY_GROUP_ID" \ - --query 'Instances[0].InstanceId' \ - --output text) - -echo "Terraria server instance created with ID: $TERRARIA_SERVER_INSTANCE_ID" - -# Create bot instances -declare -a BOT_INSTANCE_IDS -for ((i=1; i<=$NUM_BOT_INSTANCES; i++)) -do - BOT_INSTANCE_ID=$(aws ec2 run-instances \ - --region "$AWS_REGION" \ - --image-id "$AMI_ID" \ - --count 1 \ - --instance-type "$INSTANCE_TYPE" \ - --key-name $KEY_PAIR_NAME \ - --security-group-ids "$SECURITY_GROUP_ID" \ - --query 'Instances[0].InstanceId' \ - --output text) - BOT_INSTANCE_IDS+=($BOT_INSTANCE_ID) -done - -echo "Terraria bot instances created with IDs: ${BOT_INSTANCE_IDS[@]}" + --instance-ids "$instance_id" \ + --query 'Reservations[0].Instances[0].Placement.AvailabilityZone' \ + --output text) +} -# Print the instance states -echo "Server instance state:" -aws ec2 describe-instances --instance-ids "$TERRARIA_SERVER_INSTANCE_ID" --query 'Reservations[].Instances[].State.Name' -for BOT_INSTANCE_ID in "${BOT_INSTANCE_IDS[@]}" -do - echo "Bot instance $BOT_INSTANCE_ID state:" - aws ec2 describe-instances --instance-ids "$BOT_INSTANCE_ID" --query 'Reservations[].Instances[].State.Name' -done +# for setting SSH Public Key +set_ssh_public_key() { + instance_id=$1 + availability_zone=$2 + aws ec2-instance-connect send-ssh-public-key \ + --region "$AWS_REGION" \ + --instance-id "$instance_id" \ + --availability-zone "$availability_zone" \ + --instance-os-user ubuntu \ + --ssh-public-key file://temp/$KEY_PAIR_NAME.pub +} -# Wait for instances to be running -aws ec2 wait instance-running --instance-ids "$TERRARIA_SERVER_INSTANCE_ID" -for BOT_INSTANCE_ID in "${BOT_INSTANCE_IDS[@]}" -do - aws ec2 wait instance-running --instance-ids "$BOT_INSTANCE_ID" -done +# for getting public DNS +get_public_dns() { + instance_id=$1 + echo $(aws ec2 describe-instances \ + --region "$AWS_REGION" \ + --instance-ids "$instance_id" \ + --query 'Reservations[0].Instances[0].PublicDnsName' \ + --output text) +} + +# for SSH availability check +check_ssh_availability() { + public_dns=$1 + until ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -o ConnectTimeout=5 -i temp/$KEY_PAIR_NAME.pem ubuntu@"$public_dns" true; do + echo "Waiting for SSH to be available..." + sleep 5 + done +} + +# for running remote commands +run_remote_commands() { + public_dns=$1 + commands=$2 + ssh -i temp/$KEY_PAIR_NAME.pem ubuntu@"$public_dns" -o StrictHostKeyChecking=no -t "$commands" +} + +# for bot instance setup +setup_bot_instance() { + bot_instance_id=$1 + aws_availability_zone_bot=$(get_aws_availability_zone $bot_instance_id) + set_ssh_public_key $bot_instance_id $aws_availability_zone_bot + bot_public_dns=$(get_public_dns $bot_instance_id) + check_ssh_availability $bot_public_dns + run_remote_commands $bot_public_dns "$remote_install_commands_bot" + BOT_PUBLIC_DNS_ADDRESSES+=("$bot_public_dns") +} remote_install_commands_server=$(cat <> ~/.bashrc echo "export PATH=\$PATH:\$HOME/.dotnet:\$HOME/.dotnet/tools" >> ~/.bashrc source ~/.bashrc + dir_name="$DIR_NAME" + mkdir -p "\$dir_name" + cd "\$dir_name" + mkdir -p server bot + cd server + curl -sL https://github.com/Pryaxis/TShock/releases/download/v5.1.3/TShock-5.1.3-for-Terraria-1.4.4.9-linux-x64-Release.zip -o TShock-5.1.3-for-Terraria-1.4.4.9-linux-x64-Release.zip + unzip TShock-5.1.3-for-Terraria-1.4.4.9-linux-x64-Release.zip + tar -xvf TShock-Beta-linux-x64-Release.tar + rm TShock-Beta-linux-x64-Release.tar TShock-5.1.3-for-Terraria-1.4.4.9-linux-x64-Release.zip + curl -sL https://github.com/ncabatoff/process-exporter/releases/download/v0.7.10/process-exporter-0.7.10.linux-amd64.tar.gz -o process-exporter.gz + tar -xvf process-exporter.gz && rm process-exporter.gz + cd ServerPlugins + curl -sL https://github.com/atlarge-research/yardstick/releases/download/$TERRASTICK_VERSION/server-side-packet-monitor.zip -o server-side-packet-monitor.zip + unzip -n server-side-packet-monitor.zip && rm server-side-packet-monitor.zip + cd ../../bot + curl -sL https://github.com/atlarge-research/yardstick/archive/refs/tags/$TERRASTICK_VERSION.zip -o terrastick.zip + unzip terrastick.zip && rm terrastick.zip + mv yardstick-$TERRASTICK_VERSION/terrastick/Deployment/worlds ../server/ + mv yardstick-$TERRASTICK_VERSION/terrastick/Deployment/metrics-configs/server-process-exporter.yaml ../server/process-exporter-0.7.10.linux-amd64/ +CMD +) + +# start the server instance +remote_start_commands_server=$(cat <> ~/.bashrc + echo "Added the variable \$variable_name to the bash RC file." + else + # Variable is already set + echo "The variable \$variable_name is already set in the bash RC file." + fi + done cd ~ wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh chmod +x dotnet-install.sh ./dotnet-install.sh --version latest - echo "export DOTNET_ROOT=\$HOME/.dotnet" >> ~/.bashrc - echo "export PATH=\$PATH:\$HOME/.dotnet:\$HOME/.dotnet/tools" >> ~/.bashrc source ~/.bashrc + dir_name="$DIR_NAME" + mkdir -p "\$dir_name" + cd "\$dir_name" + mkdir -p bot + cd bot + curl -sL https://github.com/atlarge-research/yardstick/archive/refs/tags/$TERRASTICK_VERSION.zip -o terrastick.zip + unzip terrastick.zip && rm terrastick.zip + cd yardstick-$TERRASTICK_VERSION/terrastick/PlayerEmulations/TrClientTest && dotnet build -r linux-x64 -c Release --no-self-contained || echo "Build failed" CMD ) -AWS_AVAILABILITY_ZONE_SERVER=$(aws ec2 describe-instances \ - --region "$AWS_REGION" \ - --instance-ids "$TERRARIA_SERVER_INSTANCE_ID" \ - --query 'Reservations[0].Instances[0].Placement.AvailabilityZone' \ - --output text) - -# Install dotnet on the server and bot instances -aws ec2-instance-connect send-ssh-public-key \ - --region "$AWS_REGION" \ - --instance-id "$TERRARIA_SERVER_INSTANCE_ID" \ - --availability-zone "$AWS_AVAILABILITY_ZONE_SERVER" \ - --instance-os-user ubuntu \ - --ssh-public-key file://temp/$KEY_PAIR_NAME.pub - -TERRARIA_SERVER_PUBLIC_DNS=$(aws ec2 describe-instances \ - --region "$AWS_REGION" \ - --instance-ids "$TERRARIA_SERVER_INSTANCE_ID" \ - --query 'Reservations[0].Instances[0].PublicDnsName' \ - --output text) - -until ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -o ConnectTimeout=5 -i temp/$KEY_PAIR_NAME.pem ubuntu@"$TERRARIA_SERVER_PUBLIC_DNS" true; do - echo "Waiting for SSH to be available..." - sleep 5 -done +# start the bot instance -# Now you can run your remote commands: -ssh -i temp/$KEY_PAIR_NAME.pem ubuntu@"$TERRARIA_SERVER_PUBLIC_DNS" -o StrictHostKeyChecking=no -t "$remote_install_commands_server" +remote_start_commands_bot=$(cat <> ~/.bashrc + echo "export PATH=\$PATH:\$HOME/.dotnet:\$HOME/.dotnet/tools" >> ~/.bashrc + echo "export TERRASTICK_IP=$TERRARIA_SERVER_PRIVATE_IP" >> ~/.bashrc + source ~/.bashrc + dir_name="$DIR_NAME" + mkdir -p "\$dir_name" + cd "\$dir_name" + mkdir -p prometheus bot + cd prometheus + curl -sL https://github.com/prometheus/prometheus/releases/download/v2.37.8/prometheus-2.37.8.linux-amd64.tar.gz -o prometheus.gz + tar -xvf prometheus.gz && rm prometheus.gz + cd ../bot + curl -sL https://github.com/atlarge-research/yardstick/archive/refs/tags/$TERRASTICK_VERSION.zip -o terrastick.zip + unzip terrastick.zip && rm terrastick.zip + mv yardstick-$TERRASTICK_VERSION/terrastick/Deployment/metrics-configs/prometheus-terrastick.yml ../prometheus/prometheus-2.37.8.linux-amd64/ +CMD +) +remote_start_commands_prometheus=$(cat < Date: Thu, 22 Jun 2023 20:34:02 +0200 Subject: [PATCH 6/6] added config template files --- terrastick/Deployment/scripts/configs/aws-config.txt | 7 ------- .../Deployment/scripts/configs/aws-config.txt.template | 10 ++++++++++ terrastick/Deployment/scripts/configs/das-config.txt | 10 ---------- .../Deployment/scripts/configs/das-config.txt.template | 10 ++++++++++ 4 files changed, 20 insertions(+), 17 deletions(-) delete mode 100644 terrastick/Deployment/scripts/configs/aws-config.txt create mode 100644 terrastick/Deployment/scripts/configs/aws-config.txt.template delete mode 100644 terrastick/Deployment/scripts/configs/das-config.txt create mode 100644 terrastick/Deployment/scripts/configs/das-config.txt.template diff --git a/terrastick/Deployment/scripts/configs/aws-config.txt b/terrastick/Deployment/scripts/configs/aws-config.txt deleted file mode 100644 index a4cb8971..00000000 --- a/terrastick/Deployment/scripts/configs/aws-config.txt +++ /dev/null @@ -1,7 +0,0 @@ -PROFILE_NAME=school -ACCESS_KEY_ID=AKIAWH2ZZNMQ6QMIKRDY -SECRET_ACCESS_KEY=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 -REGION=eu-central-1 -NUM_BOT_INSTANCES=2 -INSTANCE_TYPE=t2.micro -BASE_AMI_ID=ami-0ec7f9846da6b0f61 diff --git a/terrastick/Deployment/scripts/configs/aws-config.txt.template b/terrastick/Deployment/scripts/configs/aws-config.txt.template new file mode 100644 index 00000000..700bae48 --- /dev/null +++ b/terrastick/Deployment/scripts/configs/aws-config.txt.template @@ -0,0 +1,10 @@ +PROFILE_NAME=default +ACCESS_KEY_ID= +SECRET_ACCESS_KEY= +REGION=eu-central-1 +NUM_BOT_INSTANCES=2 +INSTANCE_TYPE=t2.micro +BASE_AMI_ID=ami-0ec7f9846da6b0f61 +WORLD_NAME=2022DistSys +TERRASTICK_VERSION=terrastick-test-v0.7 +TERRASTICK_WORKLOAD=TEL diff --git a/terrastick/Deployment/scripts/configs/das-config.txt b/terrastick/Deployment/scripts/configs/das-config.txt deleted file mode 100644 index 1968f9f8..00000000 --- a/terrastick/Deployment/scripts/configs/das-config.txt +++ /dev/null @@ -1,10 +0,0 @@ -VUNET_USERNAME=aba448 -NUM_NODES=4 -RESERVE_DURATION=00:30:00 -DAS_VERSION_TO_USE=5 -DAS5_USERNAME=aba448 -DAS6_USERNAME=aba448 -WORLD_NAME=2022DistSys -TERRASTICK_VERSION=terrastick-test-v0.5 -TERRASTICK_WORKLOAD=TEL -TERRASTICK_IP=10.141.0.0 \ No newline at end of file diff --git a/terrastick/Deployment/scripts/configs/das-config.txt.template b/terrastick/Deployment/scripts/configs/das-config.txt.template new file mode 100644 index 00000000..84fb9e84 --- /dev/null +++ b/terrastick/Deployment/scripts/configs/das-config.txt.template @@ -0,0 +1,10 @@ +VUNET_USERNAME= +NUM_NODES=4 +RESERVE_DURATION=00:10:00 +DAS_VERSION_TO_USE=5 +DAS5_USERNAME= +DAS6_USERNAME= +WORLD_NAME=2022DistSys +TERRASTICK_VERSION=terrastick-test-v0.7 +TERRASTICK_WORKLOAD=TEL +TERRASTICK_IP=10.141.0.0 \ No newline at end of file