Skip to content

Commit

Permalink
Support port
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Ho <[email protected]>
  • Loading branch information
derek-ho committed Mar 27, 2024
1 parent 66f8d26 commit d7c6b1c
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -88,15 +90,15 @@ 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

- 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
Expand All @@ -105,60 +107,60 @@ 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
if: ${{ runner.os == 'Windows' && inputs.security-enabled == 'true' }}
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!
Expand Down Expand Up @@ -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

0 comments on commit d7c6b1c

Please sign in to comment.