From bd4fc495d1bfba2e3e8081265939960fc93a8aef Mon Sep 17 00:00:00 2001 From: simatec Date: Wed, 5 Jun 2024 12:08:14 +0200 Subject: [PATCH] (simatec) v0.9.4 --- README.md | 3 ++ config/piler-default.yml | 2 + config/piler-ssl.yml | 2 + patch.sh | 108 +++++++++++++++++++++++++++++++++++++++ update.sh | 5 ++ 5 files changed, 120 insertions(+) create mode 100644 patch.sh diff --git a/README.md b/README.md index 115735f..43b70c4 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,9 @@ To leave the container on the console you have to execute 2x `exit`. ## Changelog +### 0.9.4 (05.06.2024) +* (simatec) patch for Piler Update added + ### 0.9.3 (01.06.2024) * (simatec) Piler v1.4.5 updated * (simatec) MariaDB v11.1.2 updated diff --git a/config/piler-default.yml b/config/piler-default.yml index 09d666a..3076ed1 100644 --- a/config/piler-default.yml +++ b/config/piler-default.yml @@ -4,6 +4,7 @@ services: mysql: image: mariadb:${MARIA_DB_VERSION} container_name: mysql_piler + hostname: mysql restart: unless-stopped cap_drop: - ALL @@ -31,6 +32,7 @@ services: memcached: image: memcached:latest container_name: memcached + hostname: memcached restart: unless-stopped cap_drop: - ALL diff --git a/config/piler-ssl.yml b/config/piler-ssl.yml index 08e11af..6832d22 100644 --- a/config/piler-ssl.yml +++ b/config/piler-ssl.yml @@ -24,6 +24,7 @@ services: - DEFAULT_EMAIL=${LETSENCRYPT_EMAIL} mysql: image: mariadb:${MARIA_DB_VERSION} + hostname: mysql container_name: mysql-piler restart: unless-stopped cap_drop: @@ -52,6 +53,7 @@ services: memcached: image: memcached:latest container_name: memcached-piler + hostname: memcached restart: unless-stopped cap_drop: - ALL diff --git a/patch.sh b/patch.sh new file mode 100644 index 0000000..9354cf1 --- /dev/null +++ b/patch.sh @@ -0,0 +1,108 @@ +#!/bin/bash + +# Colors +if [ -z ${BASH_SOURCE} ]; then + blue=`echo "\e[1m\e[34m"` + green=`echo "\e[1m\e[32m"` + greenBold=`echo "\e[1m\e[1;32m"` + redBold=`echo "\e[1m\e[1;31m"` + red=`echo "\e[1m\e[31m"` + purple=`echo "\e[1m\e[35m"` + bold=`echo "\e[1m"` + normal=`echo "\e[0m"` +else + blue=`echo -e "\e[1m\e[34m"` + green=`echo -e "\e[1m\e[32m"` + greenBold=`echo -e "\e[1m\e[1;32m"` + redBold=`echo -e "\e[1m\e[1;31m"` + purple=`echo -e "\e[1m\e[35m"` + bold=`echo -e "\e[1m"` + normal=`echo -en "\e[0m"` +fi + +HLINE="================================================================" +HLINE_SMALL="=================================" + +BLA_metro=( 0.2 ' ' '= ' '== ' '=== ' ' ===' ' ==' ' =' ) + +BLA::play_loading_animation_loop() { + while true ; do + for frame in "${BLA_active_loading_animation[@]}" ; do + printf "\r%s" "${frame}" + sleep "${BLA_loading_animation_frame_interval}" + done + done +} + +BLA::start_loading_animation() { + BLA_active_loading_animation=( "${@}" ) + BLA_loading_animation_frame_interval="${BLA_active_loading_animation[0]}" + unset "BLA_active_loading_animation[0]" + tput civis # Hide the terminal cursor + BLA::play_loading_animation_loop & + BLA_loading_animation_pid="${!}" +} + +BLA::stop_loading_animation() { + kill "${BLA_loading_animation_pid}" &> /dev/null + printf "\n" + tput cnorm # Restore the terminal cursor +} + +####################################################################################### + +echo +echo "${greenBold}${HLINE_SMALL}" +echo "Check if patches are available" +echo "${greenBold}${HLINE_SMALL}${normal}" +echo + +####################################################################################### + +# config load +. ./piler.conf + +# Check Version +compare_versions() { + local version1=$1 + local version2=$2 + local ver1=$(echo "$version1" | awk -F. '{ printf("%03d%03d%03d", $1, $2, $3); }') + local ver2=$(echo "$version2" | awk -F. '{ printf("%03d%03d%03d", $1, $2, $3); }') + + if [[ "$ver1" -ge "$ver2" ]]; then + return 0 + else + return 1 + fi +} + +##################### Patch for Update to Piler v1.4.5 or higher ###################### +# Check the manticore.conf to see if the entry "listen = 127.0.0.1:9307:mysql_readonly" is present. +# If the entry does not exist, set the entry in the manticore.conf + +required_version="1.4.5" + +if compare_versions "$PILER_VERSION" "$required_version"; then + file="/var/lib/docker/volumes/piler-docker_piler_etc/_data/manticore.conf" + patchNum="pilerPatch_001" + + search_entry="127.0.0.1:9307:" + new_entry="${entry}\tlisten\t\t\t= 127.0.0.1:9307:mysql_readonly" + + if [ -f $file ]; then + # Check the manticore.conf to see if the entry "listen = 127.0.0.1:9307:mysql_readonly" is present + if ! grep -qF "$search_entry" "$file"; then + # If the entry does not exist, set the entry in the manticore.conf + sed -i "/listen/!b; :a; {n; /listen/!ba}; a $new_entry" "$file" + sed -i "s/\<$patchNum\>//g" "$file" + echo "Patch manticore.conf with new entry: listen = 127.0.0.1:9307:mysql_readonly" + else + echo "Patch already executed. No action required" + fi + else + echo "The file manticore.conf does not exist. The patch cannot be executed" + fi +fi +####################################################################################### + +exit 0 \ No newline at end of file diff --git a/update.sh b/update.sh index d001669..03dfd01 100644 --- a/update.sh +++ b/update.sh @@ -204,6 +204,11 @@ if [ "$USE_LETSENCRYPT" = "yes" ]; then else cp $configPth/piler-default.yml $installPth/docker-compose.yml fi +# Check for Patches before Update +bash $installPth/patch.sh +BLA::start_loading_animation "${BLA_metro[@]}" +sleep 5 +BLA::stop_loading_animation # start Update Container echo