Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append the flags to the end of the password file #263

Merged
merged 6 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .github/workflows/linux_only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,17 @@ jobs:
run: docker compose -p ${{ env.UNIQUE_ID }} -f testing/development/docker-compose.yml build lme --no-cache

- name: Run Docker Compose
run: docker compose -p ${{ env.UNIQUE_ID }} -f testing/development/docker-compose.yml up -d
run: docker compose -p ${{ env.UNIQUE_ID }} -f testing/development/docker-compose.yml up lme -d

- name: List docker containers to wait for them to start
run: |
docker ps

- name: Execute commands inside ubuntu container
run: |
cd testing/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T ubuntu bash -c "echo 'Ubuntu container built'"

# We are not using the ubuntu container so no use waiting for it to start
# - name: Execute commands inside ubuntu container
# run: |
# cd testing/development
# docker compose -p ${{ env.UNIQUE_ID }} exec -T ubuntu bash -c "echo 'Ubuntu container built'"

- name: Install LME in container
run: |
Expand All @@ -98,4 +99,4 @@ jobs:
cd testing/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T -u root lme bash -c "rm -rf /home/admin.ackbar/LME/.pytest_cache"
docker compose -p ${{ env.UNIQUE_ID }} down
docker system prune --force
docker system prune -a --force
18 changes: 17 additions & 1 deletion testing/InstallTestbed.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -383,4 +383,20 @@ $EsPasswords

# Write the passwords to a file
$PasswordPath = "..\..\${ResourceGroup}.password.txt"
$EsPasswords | Out-File -Append -FilePath $PasswordPath
$EsPasswords | Out-File -Append -FilePath $PasswordPath

# Constructing a string that will hold all the command-line parameters to be written to the file
$paramsToWrite = @"
ResourceGroup: $ResourceGroup
DomainController: $DomainController
LinuxVM: $LinuxVM
NumClients: $NumClients
LinuxOnly: $($LinuxOnly.IsPresent)
Version: $Version
Branch: $Branch
"@

# Output the parameters to the end of the password file
$paramsToWrite | Out-File -Append -FilePath $PasswordPath

Get-Content -Path $PasswordPath
40 changes: 14 additions & 26 deletions testing/configure/lib/functions.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
extract_credentials() {
# Set default file path if not provided
local file_path=${1:-'/opt/lme/Chapter 3 Files/output.log'}
local file_path=${1:-'/opt/lme/Chapter 3 Files/output.log'}

# Check if the file exists
if [ ! -f "$file_path" ]; then
echo "File not found: $file_path"
return 1
fi

# Read and extract credentials from the last 18 lines
while IFS= read -r line; do
# Remove leading '## ' and trim whitespaces from the line
line=$(echo "$line" | sed 's/^## //g' | xargs)
if [ ! -f "$file_path" ]; then
echo "File not found: $file_path"
return 1
fi

# Split the line into key and value
key=$(echo "$line" | awk -F ':' '{print $1}')
value=$(echo "$line" | awk -F ':' '{print $2}' | xargs) # xargs to trim whitespaces from value
# Use sed to extract the lines containing the credentials
credentials=$(sed -n '/^## [a-zA-Z_]*:/p' "$file_path")

# Remove non-word characters (keep only word characters)
value=$(echo "$value" | sed 's/[^[:alnum:]_]//g')
# Loop through the extracted lines and assign the values to variables
while IFS=: read -r key value; do
key=$(echo "$key" | sed 's/^## //g' | tr -d '[:space:]')
value=$(echo "$value" | tr -d '\r\n')
export "$key"="$value"
done <<< "$credentials"

case $key in
"elastic") export elastic=$value ;;
"kibana") export kibana=$value ;;
"logstash_system") export logstash_system=$value ;;
"logstash_writer") export logstash_writer=$value ;;
"dashboard_update") export dashboard_update=$value ;;
esac
done < <(tail -n 18 "$file_path" | grep -E "(elastic|kibana|logstash_system|logstash_writer|dashboard_update):")
export ELASTIC_PASSWORD=$elastic
export ELASTIC_PASSWORD=$elastic
}

write_credentials_to_file() {
Expand Down
Loading