#!/bin/sh # We ignore errors in the rpm context because the package will be considered "installed" # even if the postinst script fails. Therefore, the postinst script must be written such # that it cannot fail # set -e # Post install script for Redhat like distros. Tested on CentOS 7. # Make sure the OPENSEARCH_HOME environment variable is set if [ -z "$OPENSEARCH_HOME" ]; then OPENSEARCH_HOME=/usr/share/opensearch fi # Make sure the OPENSEARCH_PATH_CONF environment variable is set if [ -z "$OPENSEARCH_PATH_CONF" ]; then OPENSEARCH_PATH_CONF=/etc/opensearch fi # Prepare the RCA reader process for execution mv "$OPENSEARCH_HOME"/plugins/opensearch-performance-analyzer/performance-analyzer-rca $OPENSEARCH_HOME mkdir -p "$OPENSEARCH_HOME"/data mkdir -p "/var/lib/opensearch" touch "$OPENSEARCH_HOME"/data/rca_enabled.conf echo 'true' > "$OPENSEARCH_HOME"/data/rca_enabled.conf echo 'true' > /var/lib/opensearch/performance_analyzer_enabled.conf echo 'true' > /var/lib/opensearch/rca_enabled.conf chown opensearch /var/lib/opensearch/performance_analyzer_enabled.conf chown opensearch /var/lib/opensearch/rca_enabled.conf chown -R opensearch "$OPENSEARCH_HOME/performance-analyzer-rca" chmod a+rw /tmp if ! grep -q '## OpenSearch Performance Analyzer' $OPENSEARCH_PATH_CONF/jvm.options; then CLK_TCK=`/usr/bin/getconf CLK_TCK` echo >> $OPENSEARCH_PATH_CONF/jvm.options echo '## OpenSearch Performance Analyzer' >> $OPENSEARCH_PATH_CONF/jvm.options echo "-Dclk.tck=$CLK_TCK" >> $OPENSEARCH_PATH_CONF/jvm.options echo "-Djdk.attach.allowAttachSelf=true" >> $OPENSEARCH_PATH_CONF/jvm.options echo "-Djava.security.policy=file://$OPENSEARCH_PATH_CONF/opensearch-performance-analyzer/opensearch_security.policy" >> $OPENSEARCH_PATH_CONF/jvm.options fi IS_UPGRADE=false case "$1" in 1) # If $1=1 this is an install IS_UPGRADE=false ;; 2) # If $1=2 this is an upgrade IS_UPGRADE=true ;; *) echo "post install script called with unknown argument \`$1'" >&2 exit 1 ;; esac if [ "x$IS_UPGRADE" != "xtrue" ]; then if command -v systemctl > /dev/null; then echo '# Enabling OpenSearch performance analyzer to start and stop along with opensearch.service' systemctl daemon-reload systemctl enable opensearch-performance-analyzer.service || true elif command -v chkconfig >/dev/null; then echo "### Non systemd distro. Please start and stop performance analyzer manually using the command: " echo "sh /usr/share/opensearch/bin/opensearch-performance-analyzer/performance-analyzer-agent /usr/share/opensearch -d" fi fi