From d7c6b1caabdecfe884268e7d08285d5a5c0885c7 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Wed, 27 Mar 2024 17:03:40 -0400 Subject: [PATCH] Support port Signed-off-by: Derek Ho --- action.yml | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/action.yml b/action.yml index 5131aa0..921b5d2 100644 --- a/action.yml +++ b/action.yml @@ -59,25 +59,27 @@ runs: - name: Extract downloaded tar if: ${{ runner.os == 'Linux' }} run: | - tar -xzf opensearch-*.tar.gz + tar -xzf opensearch-*.tar.gz && mv opensearch-${{ inputs.opensearch-version }}-SNAPSHOT opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }} rm -f opensearch-*.tar.gz shell: bash - name: Extract downloaded zip if: ${{ runner.os == 'Windows' }} run: | - tar -xzf opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-windows-x64-latest.zip - del opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-windows-x64-latest.zip + Expand-Archive -Path "opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-windows-x64-latest.zip" -DestinationPath "temp" + Move-Item -Path "temp/*" -Destination "opensearch-3.0.0-SNAPSHOT${{ inputs.port }}" + Remove-Item -Path "temp" -Recurse + Remove-Item -Path "opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-windows-x64-latest.zip" shell: pwsh - name: Install plugin(s) into OpenSearch for Linux if: ${{ runner.os == 'Linux'}} run: | - chmod +x ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch-plugin + chmod +x ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/bin/opensearch-plugin plugins="${{ inputs.plugins }}" if [ -n "$plugins" ]; then echo "$plugins" | tr ',' '\n' | while read -r plugin; do - /bin/bash -c "yes | ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch-plugin install ${plugin}" + /bin/bash -c "yes | ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/bin/opensearch-plugin install ${plugin}" done fi shell: bash @@ -88,7 +90,7 @@ runs: $pluginNames = "${{ inputs.plugins }}" -split ',' if ($pluginNames.Length -gt 0) { foreach ($plugin in $pluginNames) { - 'y' | .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT\bin\opensearch-plugin.bat install ${plugin} + 'y' | .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}\bin\opensearch-plugin.bat install ${plugin} } } shell: pwsh @@ -96,7 +98,7 @@ runs: - name: Replace security configuration file if applicable if: ${{ inputs.security_config_file != '' }} run: | - mv ${{ inputs.security_config_file }} ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch-security/config.yml + mv ${{ inputs.security_config_file }} ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch-security/config.yml shell: bash # Setup security if it's enabled @@ -105,18 +107,18 @@ runs: run: | echo "running linux security demo configuration setup" export OPENSEARCH_INITIAL_ADMIN_PASSWORD=${{ inputs.admin-password }} - chmod +x ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/plugins/opensearch-security/tools/install_demo_configuration.sh + chmod +x ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/plugins/opensearch-security/tools/install_demo_configuration.sh opensearch_version="${{ inputs.opensearch-version }}" opensearch_major_version=$(echo "$opensearch_version" | awk -F'.' '{print $1}') opensearch_minor_version=$(echo "$opensearch_version" | awk -F'.' '{print $2}') if [ "$opensearch_major_version" -lt 2 ] || ([ "$opensearch_major_version" -eq 2 ] && [ "$opensearch_minor_version" -lt 12 ]); then echo "Running the command without -t option (OpenSearch version is $opensearch_version)" - /bin/bash -c "yes | ./opensearch-${opensearch_version}-SNAPSHOT/plugins/opensearch-security/tools/install_demo_configuration.sh" + /bin/bash -c "yes | ./opensearch-${opensearch_version}-SNAPSHOT${{ inputs.port }}/plugins/opensearch-security/tools/install_demo_configuration.sh" else echo "Running the command with -t option (OpenSearch version is $opensearch_version)" - /bin/bash -c "yes | ./opensearch-${opensearch_version}-SNAPSHOT/plugins/opensearch-security/tools/install_demo_configuration.sh -t" + /bin/bash -c "yes | ./opensearch-${opensearch_version}-SNAPSHOT${{ inputs.port }}/plugins/opensearch-security/tools/install_demo_configuration.sh -t" fi - echo "plugins.security.unsupported.restapi.allow_securityconfig_modification: true" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml + echo "plugins.security.unsupported.restapi.allow_securityconfig_modification: true" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash - name: Setup security demo configuration for Windows @@ -124,41 +126,41 @@ runs: run: | echo "running windows security demo configuration setup" export OPENSEARCH_INITIAL_ADMIN_PASSWORD=${{ inputs.admin-password }} - chmod +x ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/plugins/opensearch-security/tools/install_demo_configuration.bat + chmod +x ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/plugins/opensearch-security/tools/install_demo_configuration.bat opensearch_version="${{ inputs.opensearch-version }}" opensearch_major_version=$(echo "$opensearch_version" | cut -d'.' -f1) opensearch_minor_version=$(echo "$opensearch_version" | cut -d'.' -f2) if [ "$opensearch_major_version" -lt 2 ] || ([ "$opensearch_major_version" -eq 2 ] && [ "$opensearch_minor_version" -lt 12 ]); then echo "Running the command without -t option (OpenSearch version is $opensearch_version)" - /bin/bash -c "yes | ./opensearch-${opensearch_version}-SNAPSHOT/plugins/opensearch-security/tools/install_demo_configuration.bat -y -i -s" + /bin/bash -c "yes | ./opensearch-${opensearch_version}-SNAPSHOT${{ inputs.port }}/plugins/opensearch-security/tools/install_demo_configuration.bat -y -i -s" else echo "Running the command with -t option (OpenSearch version is $opensearch_version)" - /bin/bash -c "yes | ./opensearch-${opensearch_version}-SNAPSHOT/plugins/opensearch-security/tools/install_demo_configuration.bat -t -y -i -s" + /bin/bash -c "yes | ./opensearch-${opensearch_version}-SNAPSHOT${{ inputs.port }}/plugins/opensearch-security/tools/install_demo_configuration.bat -t -y -i -s" fi - echo "plugins.security.unsupported.restapi.allow_securityconfig_modification: true" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml + echo "plugins.security.unsupported.restapi.allow_securityconfig_modification: true" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash - name: Use more space run: | - echo '' >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml - echo "cluster.routing.allocation.disk.threshold_enabled: false" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml + echo '' >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml + echo "cluster.routing.allocation.disk.threshold_enabled: false" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash - name: Replace opensearch.yml file if applicable if: ${{ inputs.port != '' }} run: | - echo -e "\nhttp.port: ${{ inputs.port }}" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml + echo -e "\nhttp.port: ${{ inputs.port }}" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash # Run OpenSearch - name: Run OpenSearch with plugin on Linux if: ${{ runner.os == 'Linux'}} - run: /bin/bash -c "./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch &" + run: /bin/bash -c "./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/bin/opensearch &" shell: bash - name: Run OpenSearch with plugin on Windows if: ${{ runner.os == 'Windows'}} - run: start .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT\bin\opensearch.bat + run: start .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}\bin\opensearch.bat shell: pwsh # Give the OpenSearch process some time to boot up before sending any requires, might need to increase the default time! @@ -195,5 +197,5 @@ runs: shell: pwsh - if: always() - run: cat ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/logs/opensearch.log + run: cat ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/logs/opensearch.log shell: bash \ No newline at end of file