Compare commits

..

No commits in common. "811bae40618341ef8943fd9614eef300e9612460" and "2de1954a33f379b7eddd58950e191faca404949a" have entirely different histories.

2 changed files with 17 additions and 89 deletions

View File

@ -5,22 +5,6 @@
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/ # T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# GPLv3 or later. # GPLv3 or later.
# #
{
echo "Started at $(date +'%Y-%m-%d %H:%M:%S')" >> opensearch-installer.log
while getopts m: option
do
case "${option}"
in
m) MODE=${OPTARG};;
\?) echo "Usage: sudo bash ./$0 [-m debug]" && exit;;
esac
done
#DEBUG
if [ "$MODE" = "debug" ]; then
set -x
fi
# Reset # Reset
Color_Off='\e[0m' # Text Reset Color_Off='\e[0m' # Text Reset
@ -34,9 +18,6 @@ Purple='\e[0;35m' # Purple
Cyan='\e[0;36m' # Cyan Cyan='\e[0;36m' # Cyan
MEM_AVAILABLE="$(grep MemTotal /proc/meminfo| grep -o '[0-9]\+')" MEM_AVAILABLE="$(grep MemTotal /proc/meminfo| grep -o '[0-9]\+')"
DIST=$(lsb_release -sc)
TODAY=$(date +%s)
NEXT_LTS_DATE=$(date -d 2024-04-01 +%s)
OPNSDIR="/opt/opensearch" OPNSDIR="/opt/opensearch"
INDEX_USER="$(tr -dc '[:lower:]' < /dev/urandom | fold -w 24 | head -n1)" INDEX_USER="$(tr -dc '[:lower:]' < /dev/urandom | fold -w 24 | head -n1)"
OPNSREST="$(tr -dc "a-zA-Z0-9" < /dev/urandom | fold -w 32 | head -n1)" OPNSREST="$(tr -dc "a-zA-Z0-9" < /dev/urandom | fold -w 32 | head -n1)"
@ -46,22 +27,9 @@ fts_node="fts_os-node"
max_map_count="512000" max_map_count="512000"
NL="$(printf '\n ')" NL="$(printf '\n ')"
rename_distro() {
if [ "$DIST" = "$1" ]; then
DIST="$2"
fi
}
#Trisquel distro upstream referencing.
rename_distro nabia focal
rename_distro aramo jammy
printwc() { printwc() {
printf "%b$2%b" "$1" "${Color_Off}" printf "%b$2%b" "$1" "${Color_Off}"
} }
print_title() {
printwc "${Blue}" "\n#--------------------------------------------------"
printwc "${Blue}" "\n# $1"
printwc "${Blue}" "\n#--------------------------------------------------\n"
}
install_if_not() { install_if_not() {
if [ "$(dpkg-query -W -f='${Status}' "$1" 2>/dev/null | \ if [ "$(dpkg-query -W -f='${Status}' "$1" 2>/dev/null | \
grep -c "ok installed")" == "1" ]; then grep -c "ok installed")" == "1" ]; then
@ -109,14 +77,6 @@ while [ $secs -gt 0 ]; do
: $((secs--)) : $((secs--))
done done
} }
wait_for_bootstrapping() {
if [ "$(nproc)" -gt 2 ]
then
countdown "Waiting for Docker bootstrapping..." "30"
else
countdown "Waiting for Docker bootstrapping..." "60"
fi
}
#Check if user is root #Check if user is root
if ! [ "$(id -u)" = 0 ]; then if ! [ "$(id -u)" = 0 ]; then
@ -124,31 +84,11 @@ if ! [ "$(id -u)" = 0 ]; then
exit 0 exit 0
fi fi
printf "\nOS: %s" "$(lsb_release -sd)"
if [ "$DIST" = "focal" ] || \
[ "$DIST" = "jammy" ]; then
printf "\nGood, this is a supported platform!"
else
printf "\nSorry, this platform is not supported... exiting"
exit
fi
# Suggest 22.04 LTS release over 20.04 in April 2024
if [ "$DIST" = "focal" ]; then
if [ "$TODAY" -gt "$NEXT_LTS_DATE" ]; then
echo " > $(lsb_release -sc), even when it's compatible and functional."
echo -n " We suggest to use the next (LTS) release, for longer"
echo " support and security reasons."
read -n 1 -s -r -p "Press any key to continue..."$'\n'
else
echo "Focal is supported."
fi
fi
# Check update # Check update
apt-get update -q2 apt-get update -q2
# Test RAM size (4GB min) + CPUs (min 2) # Test RAM size (4GB min) + CPUs (min 2)
print_title "Check system resources" #Check system resources
printf "\n\nVerifying System Resources:" printf "\n\nVerifying System Resources:"
if [ "$(nproc --all)" -lt 2 ];then if [ "$(nproc --all)" -lt 2 ];then
printf "\nWarning!: The system do not meet the minimum CPU" printf "\nWarning!: The system do not meet the minimum CPU"
@ -194,8 +134,7 @@ printf '\nThis server will likely have issues due the lack of resources.\n'
printf '>>> We highly recommend to increase resources of this server. <<<\n' printf '>>> We highly recommend to increase resources of this server. <<<\n'
fi fi
sleep .1 sleep .1
# Set domain
print_title "Set CA domain"
while [ "$ANS_DMN" != "yes" ] while [ "$ANS_DMN" != "yes" ]
do do
read -p "> Set your CA domain (or subdomain) here: $NL" -r DOMAIN read -p "> Set your CA domain (or subdomain) here: $NL" -r DOMAIN
@ -226,15 +165,13 @@ else
fi fi
fi fi
sleep .1 sleep .1
# Check & install docker
print_title "Set system vm.max_map_count."
sysctl -w vm.max_map_count="$max_map_count"
set_once_hash_comment "vm.max_map_count=$max_map_count" "/etc/sysctl.conf"
print_title "Install and setup Docker"
install_if_not docker.io install_if_not docker.io
install_if_not docker-compose install_if_not docker-compose
sysctl -w vm.max_map_count="$max_map_count"
set_once_hash_comment "vm.max_map_count=$max_map_count" "/etc/sysctl.conf"
mkdir -p "$OPNSDIR" mkdir -p "$OPNSDIR"
docker pull "$opens_fts" docker pull "$opens_fts"
BCRYPT_HASH="$(docker run --rm -it $opens_fts \ BCRYPT_HASH="$(docker run --rm -it $opens_fts \
@ -358,17 +295,23 @@ networks:
#[1] https://github.com/opensearch-project/performance-analyzer #[1] https://github.com/opensearch-project/performance-analyzer
YML_DOCKER_COMPOSE YML_DOCKER_COMPOSE
print_title "Prepare certs" # Prepare certs
create_certs "$DOMAIN" create_certs "$DOMAIN"
# Set permissions # Set permissions
chmod 744 -R $OPNSDIR chmod 744 -R $OPNSDIR
print_title "Launch opensearch via docker-compose" # Launch docker-compose
cd $OPNSDIR cd $OPNSDIR
docker-compose up -d docker-compose up -d
wait_for_bootstrapping # Wait for bootstrapping
if [ "$(nproc)" -gt 2 ]
then
countdown "Waiting for Docker bootstrapping..." "30"
else
countdown "Waiting for Docker bootstrapping..." "60"
fi
# Make sure password setup is enforced. # Make sure password setup is enforced.
docker-compose exec fts_os-node \ docker-compose exec fts_os-node \
@ -386,17 +329,6 @@ docker-compose exec fts_os-node \
../../../config/admin.pem \ ../../../config/admin.pem \
../../../config/admin-key.pem" ../../../config/admin-key.pem"
wait_for_bootstrapping
docker logs $fts_node docker logs $fts_node
if curl -sXGET "http://${INDEX_USER}:${OPNSREST}@localhost:9200" printwc "$Green" "\n\nYou can now use: \"http://${INDEX_USER}:${OPNSREST}@localhost:9200\"\n"
then
printwc "$Green" "\n\nYou can now use: "
printwc "$Cyan" "'http://${INDEX_USER}:${OPNSREST}@localhost:9200'\n"
else
printwc "$Red" "\n\nSetup have failed please report to: "
printwc "$Cyan" \
"'https://forge.switnet.net/switnet/simple-opensearch-installer'\n"
fi
} > >(tee -a opensearch-installer.log) 2> >(tee -a opensearch-installer.log >&2)

View File

@ -38,9 +38,5 @@ rm admin-key-temp.pem \
# Store # Store
mv client.pem \ mv client.pem \
client-key.pem \ client-key.pem \
root-ca.srl \
root-ca-key.pem -t tls_store root-ca-key.pem -t tls_store
# openssl 3.0 workaround
if [ "$(lsb_release -sc)" = "focal" ]; then
mv root-ca.srl tls_store
fi